@@ -296,21 +296,22 @@ public SAMLAuthenticationProvider samlAuthenticationProvider() {
296
296
samlAuthenticationProvider .setUserDetails (new SAMLUserDetailsService () {
297
297
@ Override
298
298
public Object loadUserBySAML (SAMLCredential credential ) throws UsernameNotFoundException {
299
- String nameAttribute = environment .getProperty ("proxy.saml.name-attribute" , DEFAULT_NAME_ATTRIBUTE );
300
- String nameValue = credential .getAttributeAsString (nameAttribute );
301
- if (nameValue == null ) throw new UsernameNotFoundException ("Name attribute missing from SAML assertion: " + nameAttribute );
302
-
303
299
List <Attribute > attributes = credential .getAttributes ();
304
300
301
+ String userID = credential .getNameID ().getValue ();
305
302
attributes .forEach ((attribute ) -> {
306
303
log .info (String .format ("[SAML] User: %s => found Attribute with name : %s (%s) and value %s - %s" ,
307
- nameValue ,
304
+ userID ,
308
305
attribute .getName (),
309
306
attribute .getFriendlyName (),
310
- credential .getAttributeAsString (attribute .getName ()),
307
+ credential .getAttributeAsString (attribute .getName ()),
311
308
String .join (", " , credential .getAttributeAsStringArray (attribute .getName ()))));
312
309
});
313
310
311
+ String nameAttribute = environment .getProperty ("proxy.saml.name-attribute" , DEFAULT_NAME_ATTRIBUTE );
312
+ String nameValue = credential .getAttributeAsString (nameAttribute );
313
+ if (nameValue == null ) throw new UsernameNotFoundException ("Name attribute missing from SAML assertion: " + nameAttribute );
314
+
314
315
List <GrantedAuthority > auth = new ArrayList <>();
315
316
String rolesAttribute = environment .getProperty ("proxy.saml.roles-attribute" );
316
317
if (rolesAttribute != null && !rolesAttribute .trim ().isEmpty ()) {
0 commit comments