Skip to content

Commit 9771362

Browse files
committed
SAML: make loggin of attirbutes configurable
1 parent 4af6769 commit 9771362

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/main/java/eu/openanalytics/containerproxy/auth/impl/saml/SAMLConfiguration.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -342,15 +342,19 @@ public SAMLAuthenticationProvider samlAuthenticationProvider() {
342342
public Object loadUserBySAML(SAMLCredential credential) throws UsernameNotFoundException {
343343
List<Attribute> attributes = credential.getAttributes();
344344

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+
}
354358

355359
String nameAttribute = environment.getProperty("proxy.saml.name-attribute", DEFAULT_NAME_ATTRIBUTE);
356360
String nameValue = credential.getAttributeAsString(nameAttribute);

0 commit comments

Comments
 (0)