@@ -342,15 +342,19 @@ public SAMLAuthenticationProvider samlAuthenticationProvider() {
342
342
public Object loadUserBySAML (SAMLCredential credential ) throws UsernameNotFoundException {
343
343
List <Attribute > attributes = credential .getAttributes ();
344
344
345
- String userID = credential .getNameID ().getValue ();
346
- attributes .forEach ((attribute ) -> {
347
- log .info (String .format ("[SAML] User: %s => found Attribute with name : %s (%s) and value %s - %s" ,
348
- userID ,
349
- attribute .getName (),
350
- attribute .getFriendlyName (),
351
- credential .getAttributeAsString (attribute .getName ()),
352
- String .join (", " , credential .getAttributeAsStringArray (attribute .getName ()))));
353
- });
345
+ if (Boolean .parseBoolean (environment .getProperty ("proxy.saml.log-attributes" , "false" ))) {
346
+ // don't use nameValue from below so that in the case this attribute isn't correctly setup,
347
+ // we can still log the attribtues (and the correct attribute can be found)
348
+ String userID = credential .getNameID ().getValue ();
349
+ attributes .forEach ((attribute ) -> {
350
+ log .info (String .format ("[SAML] User: \" %s\" => attribute => name=\" %s\" (\" %s\" ) => value \" %s\" - \" %s\" " ,
351
+ userID ,
352
+ attribute .getName (),
353
+ attribute .getFriendlyName (),
354
+ credential .getAttributeAsString (attribute .getName ()),
355
+ String .join (", " , credential .getAttributeAsStringArray (attribute .getName ()))));
356
+ });
357
+ }
354
358
355
359
String nameAttribute = environment .getProperty ("proxy.saml.name-attribute" , DEFAULT_NAME_ATTRIBUTE );
356
360
String nameValue = credential .getAttributeAsString (nameAttribute );
0 commit comments