Align relying party entity ID property with Spring Security

Closes gh-23745
pull/23755/head
Andy Wilkinson 4 years ago
parent 3657c6c85d
commit 4a38401cef

@ -51,11 +51,10 @@ public class Saml2RelyingPartyProperties {
public static class Registration { public static class Registration {
/** /**
* Relying party's entity ID template. Can generate its entity ID based on * Relying party's entity ID. The value may contain a number of placeholders. They
* possible variables of "baseUrl", "registrationId", "baseScheme", "baseHost", * are "baseUrl", "registrationId", "baseScheme", "baseHost", and "basePort".
* and "basePort".
*/ */
private String relyingPartyEntityId = "{baseUrl}/saml2/service-provider-metadata/{registrationId}"; private String entityId = "{baseUrl}/saml2/service-provider-metadata/{registrationId}";
private final Signing signing = new Signing(); private final Signing signing = new Signing();
@ -64,12 +63,12 @@ public class Saml2RelyingPartyProperties {
*/ */
private final Identityprovider identityprovider = new Identityprovider(); private final Identityprovider identityprovider = new Identityprovider();
public String getRelyingPartyEntityId() { public String getEntityId() {
return this.relyingPartyEntityId; return this.entityId;
} }
public void setRelyingPartyEntityId(String entityId) { public void setEntityId(String entityId) {
this.relyingPartyEntityId = entityId; this.entityId = entityId;
} }
public Signing getSigning() { public Signing getSigning() {

@ -82,7 +82,7 @@ class Saml2RelyingPartyRegistrationConfiguration {
builder.assertingPartyDetails((details) -> details builder.assertingPartyDetails((details) -> details
.verificationX509Credentials((credentials) -> properties.getIdentityprovider().getVerification() .verificationX509Credentials((credentials) -> properties.getIdentityprovider().getVerification()
.getCredentials().stream().map(this::asVerificationCredential).forEach(credentials::add))); .getCredentials().stream().map(this::asVerificationCredential).forEach(credentials::add)));
builder.entityId(properties.getRelyingPartyEntityId()); builder.entityId(properties.getEntityId());
RelyingPartyRegistration registration = builder.build(); RelyingPartyRegistration registration = builder.build();
boolean signRequest = registration.getAssertingPartyDetails().getWantAuthnRequestsSigned(); boolean signRequest = registration.getAssertingPartyDetails().getWantAuthnRequestsSigned();
validateSigningCredentials(properties, signRequest); validateSigningCredentials(properties, signRequest);

@ -186,7 +186,7 @@ class Saml2RelyingPartyAutoConfigurationTests {
PREFIX + ".foo.identityprovider.singlesignon.sign-request=false", PREFIX + ".foo.identityprovider.singlesignon.sign-request=false",
PREFIX + ".foo.identityprovider.entity-id=https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php", PREFIX + ".foo.identityprovider.entity-id=https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php",
PREFIX + ".foo.identityprovider.verification.credentials[0].certificate-location=classpath:saml/certificate-location", PREFIX + ".foo.identityprovider.verification.credentials[0].certificate-location=classpath:saml/certificate-location",
PREFIX + ".foo.relying-party-entity-id={baseUrl}/saml2/foo-entity-id" }; PREFIX + ".foo.entity-id={baseUrl}/saml2/foo-entity-id" };
} }
private boolean hasFilter(AssertableWebApplicationContext context, Class<? extends Filter> filter) { private boolean hasFilter(AssertableWebApplicationContext context, Class<? extends Filter> filter) {

@ -90,16 +90,16 @@ class Saml2RelyingPartyPropertiesTests {
@Test @Test
void customizeRelyingPartyEntityId() { void customizeRelyingPartyEntityId() {
bind("spring.security.saml2.relyingparty.registration.simplesamlphp.relying-party-entity-id", bind("spring.security.saml2.relyingparty.registration.simplesamlphp.entity-id",
"{baseUrl}/saml2/custom-entity-id"); "{baseUrl}/saml2/custom-entity-id");
assertThat(this.properties.getRegistration().get("simplesamlphp").getRelyingPartyEntityId()) assertThat(this.properties.getRegistration().get("simplesamlphp").getEntityId())
.isEqualTo("{baseUrl}/saml2/custom-entity-id"); .isEqualTo("{baseUrl}/saml2/custom-entity-id");
} }
@Test @Test
void customizeRelyingPartyEntityIdDefaultsToServiceProviderMetadata() { void customizeRelyingPartyEntityIdDefaultsToServiceProviderMetadata() {
assertThat(RelyingPartyRegistration.withRegistrationId("id")).extracting("entityId") assertThat(RelyingPartyRegistration.withRegistrationId("id")).extracting("entityId")
.isEqualTo(new Saml2RelyingPartyProperties.Registration().getRelyingPartyEntityId()); .isEqualTo(new Saml2RelyingPartyProperties.Registration().getEntityId());
} }
@Test @Test

Loading…
Cancel
Save