Sync: code local unifié
Synchronisation du code source local (fait foi). Signed-off-by: lions dev Team
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
package dev.lions.unionflow.server.security;
|
||||
|
||||
import jakarta.annotation.Priority;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Priorities;
|
||||
import jakarta.ws.rs.container.ContainerRequestContext;
|
||||
import jakarta.ws.rs.container.ContainerRequestFilter;
|
||||
import jakarta.ws.rs.ext.Provider;
|
||||
import org.eclipse.microprofile.jwt.JsonWebToken;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
* Filtre de débogage pour logger les rôles extraits du token JWT
|
||||
*
|
||||
* <p>Ce filtre s'exécute AVANT l'autorisation pour voir quels rôles
|
||||
* sont disponibles dans le token JWT.
|
||||
*
|
||||
* @author UnionFlow Team
|
||||
* @version 1.0
|
||||
*/
|
||||
@Provider
|
||||
@Priority(Priorities.AUTHENTICATION + 1) // S'exécute après l'authentification mais avant l'autorisation
|
||||
public class RoleDebugFilter implements ContainerRequestFilter {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(RoleDebugFilter.class);
|
||||
|
||||
@Inject
|
||||
JsonWebToken jwt;
|
||||
|
||||
@Inject
|
||||
io.quarkus.security.identity.SecurityIdentity securityIdentity;
|
||||
|
||||
@Override
|
||||
public void filter(ContainerRequestContext requestContext) {
|
||||
// Logger uniquement pour les endpoints protégés (pas pour /health, etc.)
|
||||
String path = requestContext.getUriInfo().getPath();
|
||||
if (path.startsWith("/api/")) {
|
||||
LOG.infof("=== DEBUG ROLES - Path: %s ===", path);
|
||||
|
||||
if (jwt != null) {
|
||||
LOG.infof("JWT Subject: %s", jwt.getSubject());
|
||||
LOG.infof("JWT Name: %s", jwt.getName());
|
||||
|
||||
// Extraire les rôles depuis realm_access.roles
|
||||
try {
|
||||
Object realmAccess = jwt.getClaim("realm_access");
|
||||
if (realmAccess != null) {
|
||||
LOG.infof("realm_access claim: %s", realmAccess);
|
||||
if (realmAccess instanceof java.util.Map) {
|
||||
@SuppressWarnings("unchecked")
|
||||
java.util.Map<String, Object> realmMap = (java.util.Map<String, Object>) realmAccess;
|
||||
Object rolesObj = realmMap.get("roles");
|
||||
LOG.infof("realm_access.roles: %s", rolesObj);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.warnf("Erreur lors de l'extraction de realm_access: %s", e.getMessage());
|
||||
}
|
||||
|
||||
// Extraire les rôles depuis resource_access
|
||||
try {
|
||||
Object resourceAccess = jwt.getClaim("resource_access");
|
||||
if (resourceAccess != null) {
|
||||
LOG.infof("resource_access claim: %s", resourceAccess);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.warnf("Erreur lors de l'extraction de resource_access: %s", e.getMessage());
|
||||
}
|
||||
} else {
|
||||
LOG.warn("JWT est null");
|
||||
}
|
||||
|
||||
if (securityIdentity != null) {
|
||||
LOG.infof("SecurityIdentity roles: %s", securityIdentity.getRoles());
|
||||
LOG.infof("SecurityIdentity principal: %s", securityIdentity.getPrincipal() != null ? securityIdentity.getPrincipal().getName() : "null");
|
||||
LOG.infof("SecurityIdentity isAnonymous: %s", securityIdentity.isAnonymous());
|
||||
} else {
|
||||
LOG.warn("SecurityIdentity est null");
|
||||
}
|
||||
|
||||
LOG.infof("=== FIN DEBUG ROLES ===");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user