Skip to content

Commit 115fff6

Browse files
authored

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

server/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ dependencies {
2626
implementation(libraries.owaspEsapi) {
2727
transitive = false
2828
}
29+
implementation(libraries.openSamlApi)
2930
implementation(libraries.springSecuritySamlServiceProvider)
3031
implementation(libraries.jodaTime)
3132
implementation(libraries.xmlSecurity)

server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/SamlUaaAuthenticationAttributesConverter.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
package org.cloudfoundry.identity.uaa.provider.saml;
22

3-
import lombok.Getter;
43
import lombok.extern.slf4j.Slf4j;
54
import org.cloudfoundry.identity.uaa.provider.SamlIdentityProviderDefinition;
5+
import org.opensaml.core.xml.schema.XSURI;
66
import org.opensaml.saml.saml2.core.Assertion;
7+
import org.opensaml.saml.saml2.core.AuthnContext;
8+
import org.opensaml.saml.saml2.core.AuthnStatement;
79
import org.opensaml.saml.saml2.core.Response;
810
import org.springframework.util.LinkedMultiValueMap;
911
import org.springframework.util.MultiValueMap;
12+
import org.springframework.util.ObjectUtils;
1013

1114
import java.util.List;
1215
import java.util.Map;
16+
import java.util.Objects;
1317

1418
import static org.cloudfoundry.identity.uaa.provider.ExternalIdentityProviderDefinition.USER_ATTRIBUTE_PREFIX;
19+
import static org.cloudfoundry.identity.uaa.provider.saml.SamlUaaResponseAuthenticationConverter.AUTHENTICATION_CONTEXT_CLASS_REFERENCE;
1520

1621
/**
1722
* Part of the AuthenticationConverter used during SAML login flow.
@@ -40,6 +45,14 @@ public MultiValueMap<String, String> retrieveUserAttributes(SamlIdentityProvider
4045
});
4146
});
4247

48+
List<String> authnContextList = assertions.stream().flatMap(assertion -> assertion.getAuthnStatements().stream())
49+
.map(AuthnStatement::getAuthnContext).filter(Objects::nonNull)
50+
.map(AuthnContext::getAuthnContextClassRef).filter(Objects::nonNull)
51+
.map(XSURI::getURI).filter(Objects::nonNull).toList();
52+
if (!ObjectUtils.isEmpty(authnContextList)) {
53+
userAttributes.addAll(AUTHENTICATION_CONTEXT_CLASS_REFERENCE, authnContextList);
54+
}
55+
4356
if (definition != null && definition.getAttributeMappings() != null) {
4457
definition.getAttributeMappings().forEach((key, attributeKey) -> {
4558
if (attributeKey instanceof String && userAttributes.get(attributeKey) != null) {

uaa/src/test/java/org/cloudfoundry/identity/uaa/integration/feature/OIDCLoginIT.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import org.junit.Rule;
4545
import org.junit.jupiter.api.AfterEach;
4646
import org.junit.jupiter.api.BeforeEach;
47-
import org.junit.jupiter.api.Disabled;
4847
import org.junit.jupiter.api.Test;
4948
import org.junit.jupiter.api.extension.ExtendWith;
5049
import org.openqa.selenium.By;
@@ -429,7 +428,6 @@ void testShadowUserNameDefaultsToOIDCSubjectClaim() {
429428
}
430429

431430
@Test
432-
@Disabled("SAML test fails: acr value is not set in the id_token")
433431
void successfulLoginWithOIDC_and_SAML_Provider_PlusRefreshRotation() throws Exception {
434432
SamlIdentityProviderDefinition saml = IntegrationTestUtils.createSimplePHPSamlIDP("simplesamlphp", OriginKeys.UAA);
435433
saml.setLinkText("SAML Login");

0 commit comments

Comments
 (0)