From 7a69e6c4914a08677e412bc2e49f067760337c18 Mon Sep 17 00:00:00 2001 From: Orlando M Guerreiro Date: Thu, 12 Jun 2025 14:49:12 +0100 Subject: [PATCH] =?UTF-8?q?root/resilient#8=20Inicializar=20o=20User.=20Co?= =?UTF-8?q?rrigir=20as=20ROLES=20na=20autentica=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resilient/security/saml2/Saml2AuthenticationHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/oguerreiro/resilient/security/saml2/Saml2AuthenticationHandler.java b/src/main/java/com/oguerreiro/resilient/security/saml2/Saml2AuthenticationHandler.java index 3d2b3db..dcdc5d6 100644 --- a/src/main/java/com/oguerreiro/resilient/security/saml2/Saml2AuthenticationHandler.java +++ b/src/main/java/com/oguerreiro/resilient/security/saml2/Saml2AuthenticationHandler.java @@ -82,7 +82,7 @@ public class Saml2AuthenticationHandler implements AuthenticationSuccessHandler, return; } - User user = userRepository.findOneByLogin(username).orElse(null); + User user = userRepository.findOneWithAuthoritiesByLogin(username).orElse(null); if (user != null) { // This user can login with SAML2 ? if (!user.getAllowSamlAuthentication()) { @@ -159,7 +159,7 @@ public class Saml2AuthenticationHandler implements AuthenticationSuccessHandler, userOrganization, "pt-PT"); Saml2Authentication newAuthentication = new Saml2Authentication(userdetails, samlXMLResponse, - authentication.getAuthorities()); + userdetails.getAuthorities()); SecurityContextHolder.getContext().setAuthentication(newAuthentication); // This is a sugar-code when in development environment.