Skip to content

Commit e5dcce7

Browse files
committed
wip
1 parent 0b79bcc commit e5dcce7

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
import javax.inject.Inject;
3232

3333
import org.apache.commons.httpclient.HttpClient;
34+
import org.apache.logging.log4j.LogManager;
35+
import org.apache.logging.log4j.Logger;
3436
import org.apache.velocity.app.VelocityEngine;
37+
import org.opensaml.saml2.core.Attribute;
3538
import org.opensaml.saml2.metadata.provider.HTTPMetadataProvider;
3639
import org.opensaml.saml2.metadata.provider.MetadataProvider;
3740
import org.opensaml.saml2.metadata.provider.MetadataProviderException;
@@ -285,6 +288,8 @@ public SAMLFilterSet samlFilter() throws Exception {
285288
return new SAMLFilterSet(chains);
286289
}
287290

291+
private final Logger log = LogManager.getLogger(getClass());
292+
288293
@Bean
289294
public SAMLAuthenticationProvider samlAuthenticationProvider() {
290295
SAMLAuthenticationProvider samlAuthenticationProvider = new SAMLAuthenticationProvider();
@@ -294,8 +299,19 @@ public Object loadUserBySAML(SAMLCredential credential) throws UsernameNotFoundE
294299
String nameAttribute = environment.getProperty("proxy.saml.name-attribute", DEFAULT_NAME_ATTRIBUTE);
295300
String nameValue = credential.getAttributeAsString(nameAttribute);
296301
if (nameValue == null) throw new UsernameNotFoundException("Name attribute missing from SAML assertion: " + nameAttribute);
297-
298-
List<GrantedAuthority> auth = new ArrayList<>();
302+
303+
List<Attribute> attributes = credential.getAttributes();
304+
305+
attributes.forEach((attribute) -> {
306+
log.info(String.format("[SAML] User: %s => found Attribute with name : %s (%s) and value %s - %s",
307+
nameValue,
308+
attribute.getName(),
309+
attribute.getFriendlyName(),
310+
credential.getAttributeAsString(attribute.getName()),
311+
String.join(", ", credential.getAttributeAsStringArray(attribute.getName()))));
312+
});
313+
314+
List<GrantedAuthority> auth = new ArrayList<>();
299315
String rolesAttribute = environment.getProperty("proxy.saml.roles-attribute");
300316
if (rolesAttribute != null && !rolesAttribute.trim().isEmpty()) {
301317
String[] roles = credential.getAttributeAsStringArray(rolesAttribute);

0 commit comments

Comments
 (0)