Skip to content

Commit d88f2e5

Browse files
committed
Merge branch '5.8.x' into 6.1.x
Closes gh-14957
2 parents 3f7d9e3 + c35e107 commit d88f2e5

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/authentication/OpenSaml4AuthenticationProvider.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -54,6 +54,7 @@
5454
import org.opensaml.saml.saml2.assertion.impl.AudienceRestrictionConditionValidator;
5555
import org.opensaml.saml.saml2.assertion.impl.BearerSubjectConfirmationValidator;
5656
import org.opensaml.saml.saml2.assertion.impl.DelegationRestrictionConditionValidator;
57+
import org.opensaml.saml.saml2.assertion.impl.ProxyRestrictionConditionValidator;
5758
import org.opensaml.saml.saml2.core.Assertion;
5859
import org.opensaml.saml.saml2.core.Attribute;
5960
import org.opensaml.saml.saml2.core.AttributeStatement;
@@ -804,6 +805,7 @@ public ValidationResult validate(Condition condition, Assertion assertion, Valid
804805
return ValidationResult.VALID;
805806
}
806807
});
808+
conditions.add(new ProxyRestrictionConditionValidator());
807809
subjects.add(new BearerSubjectConfirmationValidator() {
808810
@Override
809811
protected ValidationResult validateAddress(SubjectConfirmation confirmation, Assertion assertion,

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/provider/service/authentication/OpenSaml4AuthenticationProviderTests.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -53,6 +53,7 @@
5353
import org.opensaml.saml.saml2.core.EncryptedID;
5454
import org.opensaml.saml.saml2.core.NameID;
5555
import org.opensaml.saml.saml2.core.OneTimeUse;
56+
import org.opensaml.saml.saml2.core.ProxyRestriction;
5657
import org.opensaml.saml.saml2.core.Response;
5758
import org.opensaml.saml.saml2.core.StatusCode;
5859
import org.opensaml.saml.saml2.core.SubjectConfirmation;
@@ -61,6 +62,7 @@
6162
import org.opensaml.saml.saml2.core.impl.EncryptedAssertionBuilder;
6263
import org.opensaml.saml.saml2.core.impl.EncryptedIDBuilder;
6364
import org.opensaml.saml.saml2.core.impl.NameIDBuilder;
65+
import org.opensaml.saml.saml2.core.impl.ProxyRestrictionBuilder;
6466
import org.opensaml.xmlsec.encryption.impl.EncryptedDataBuilder;
6567
import org.opensaml.xmlsec.signature.support.SignatureConstants;
6668
import org.w3c.dom.Element;
@@ -741,6 +743,19 @@ public void authenticateWhenAssertionIssuerNotValidThenFailsWithInvalidIssuer()
741743
.withMessageContaining("did not match any valid issuers");
742744
}
743745

746+
// gh-14931
747+
@Test
748+
public void authenticateWhenAssertionHasProxyRestrictionThenParses() {
749+
OpenSaml4AuthenticationProvider provider = new OpenSaml4AuthenticationProvider();
750+
Response response = response();
751+
Assertion assertion = assertion();
752+
ProxyRestriction condition = new ProxyRestrictionBuilder().buildObject();
753+
assertion.getConditions().getConditions().add(condition);
754+
response.getAssertions().add(assertion);
755+
Saml2AuthenticationToken token = token(signed(response), verifying(registration()));
756+
provider.authenticate(token);
757+
}
758+
744759
private <T extends XMLObject> T build(QName qName) {
745760
return (T) XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(qName).buildObject(qName);
746761
}

0 commit comments

Comments
 (0)