Skip to content

Commit bb4bccd

Browse files
committed
Remove deprecated 'identityprovider' property
Closes gh-30751
1 parent 1950d06 commit bb4bccd

File tree

5 files changed

+51
-281
lines changed

5 files changed

+51
-281
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/ManagementWebSecurityAutoConfigurationTests.java

-13
Original file line numberDiff line numberDiff line change
@@ -144,19 +144,6 @@ void backOffIfSaml2RelyingPartyAutoConfigurationPresent() {
144144
.doesNotHaveBean(MANAGEMENT_SECURITY_FILTER_CHAIN_BEAN));
145145
}
146146

147-
@Test
148-
@Deprecated
149-
void backOffIfSaml2RelyingPartyAutoConfigurationPresentDeprecated() {
150-
this.contextRunner.withConfiguration(AutoConfigurations.of(Saml2RelyingPartyAutoConfiguration.class))
151-
.withPropertyValues(
152-
"spring.security.saml2.relyingparty.registration.simplesamlphp.identityprovider.single-sign-on.url=https://simplesaml-for-spring-saml/SSOService.php",
153-
"spring.security.saml2.relyingparty.registration.simplesamlphp.identityprovider.single-sign-on.sign-request=false",
154-
"spring.security.saml2.relyingparty.registration.simplesamlphp.identityprovider.entity-id=https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php",
155-
"spring.security.saml2.relyingparty.registration.simplesamlphp.identityprovider.verification.credentials[0].certificate-location=classpath:saml/certificate-location")
156-
.run((context) -> assertThat(context).doesNotHaveBean(ManagementWebSecurityAutoConfiguration.class)
157-
.doesNotHaveBean(MANAGEMENT_SECURITY_FILTER_CHAIN_BEAN));
158-
}
159-
160147
@Test
161148
void backOffIfRemoteDevToolsSecurityFilterChainIsPresent() {
162149
this.contextRunner.withUserConfiguration(TestRemoteDevToolsSecurityFilterChainConfig.class).run((context) -> {

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyProperties.java

+2-23
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,6 @@ public static class Registration {
6969
*/
7070
private final AssertingParty assertingParty = new AssertingParty();
7171

72-
/**
73-
* Remote SAML Identity Provider.
74-
* @deprecated use {@link #assertingParty}
75-
*/
76-
@Deprecated
77-
private final AssertingParty identityprovider = new AssertingParty();
78-
7972
public String getEntityId() {
8073
return this.entityId;
8174
}
@@ -100,16 +93,6 @@ public AssertingParty getAssertingParty() {
10093
return this.assertingParty;
10194
}
10295

103-
/**
104-
* Remote SAML Identity Provider.
105-
* @return remote SAML Identity Provider
106-
* @deprecated use {@link #getAssertingParty()}
107-
*/
108-
@Deprecated
109-
public AssertingParty getIdentityprovider() {
110-
return this.identityprovider;
111-
}
112-
11396
public static class Acs {
11497

11598
/**
@@ -299,7 +282,7 @@ public static class Singlesignon {
299282
/**
300283
* Whether to sign authentication requests.
301284
*/
302-
private Boolean signRequest;
285+
private boolean signRequest = true;
303286

304287
public String getUrl() {
305288
return this.url;
@@ -321,11 +304,7 @@ public boolean isSignRequest() {
321304
return this.signRequest;
322305
}
323306

324-
public Boolean getSignRequest() {
325-
return this.signRequest;
326-
}
327-
328-
public void setSignRequest(Boolean signRequest) {
307+
public void setSignRequest(boolean signRequest) {
329308
this.signRequest = signRequest;
330309
}
331310

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyRegistrationConfiguration.java

+11-40
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,8 @@
2323
import java.util.List;
2424
import java.util.Map;
2525
import java.util.function.Consumer;
26-
import java.util.function.Function;
2726
import java.util.stream.Collectors;
2827

29-
import org.apache.commons.logging.Log;
30-
import org.apache.commons.logging.LogFactory;
31-
3228
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
3329
import org.springframework.boot.autoconfigure.security.saml2.Saml2RelyingPartyProperties.AssertingParty;
3430
import org.springframework.boot.autoconfigure.security.saml2.Saml2RelyingPartyProperties.AssertingParty.Verification;
@@ -64,8 +60,6 @@
6460
@ConditionalOnMissingBean(RelyingPartyRegistrationRepository.class)
6561
class Saml2RelyingPartyRegistrationConfiguration {
6662

67-
private static final Log logger = LogFactory.getLog(Saml2RelyingPartyRegistrationConfiguration.class);
68-
6963
@Bean
7064
RelyingPartyRegistrationRepository relyingPartyRegistrationRepository(Saml2RelyingPartyProperties properties) {
7165
List<RelyingPartyRegistration> registrations = properties.getRegistration().entrySet().stream()
@@ -78,21 +72,19 @@ private RelyingPartyRegistration asRegistration(Map.Entry<String, Registration>
7872
}
7973

8074
private RelyingPartyRegistration asRegistration(String id, Registration properties) {
81-
boolean usingMetadata = StringUtils
82-
.hasText(getFromAssertingParty(properties, id, "metadata-uri", AssertingParty::getMetadataUri));
75+
boolean usingMetadata = StringUtils.hasText(properties.getAssertingParty().getMetadataUri());
8376
Builder builder = (usingMetadata) ? RelyingPartyRegistrations
84-
.fromMetadataLocation(
85-
getFromAssertingParty(properties, id, "metadata-uri", AssertingParty::getMetadataUri))
86-
.registrationId(id) : RelyingPartyRegistration.withRegistrationId(id);
77+
.fromMetadataLocation(properties.getAssertingParty().getMetadataUri()).registrationId(id)
78+
: RelyingPartyRegistration.withRegistrationId(id);
8779
builder.assertionConsumerServiceLocation(properties.getAcs().getLocation());
8880
builder.assertionConsumerServiceBinding(properties.getAcs().getBinding());
89-
builder.assertingPartyDetails(mapAssertingParty(properties, id, usingMetadata));
81+
builder.assertingPartyDetails(mapAssertingParty(properties.getAssertingParty(), usingMetadata));
9082
builder.signingX509Credentials((credentials) -> properties.getSigning().getCredentials().stream()
9183
.map(this::asSigningCredential).forEach(credentials::add));
9284
builder.decryptionX509Credentials((credentials) -> properties.getDecryption().getCredentials().stream()
9385
.map(this::asDecryptionCredential).forEach(credentials::add));
94-
builder.assertingPartyDetails((details) -> details.verificationX509Credentials(
95-
(credentials) -> getFromAssertingParty(properties, id, "verification", AssertingParty::getVerification)
86+
builder.assertingPartyDetails((details) -> details
87+
.verificationX509Credentials((credentials) -> properties.getAssertingParty().getVerification()
9688
.getCredentials().stream().map(this::asVerificationCredential).forEach(credentials::add)));
9789
builder.entityId(properties.getEntityId());
9890
RelyingPartyRegistration registration = builder.build();
@@ -101,35 +93,14 @@ private RelyingPartyRegistration asRegistration(String id, Registration properti
10193
return registration;
10294
}
10395

104-
@SuppressWarnings("deprecation")
105-
private <T> T getFromAssertingParty(Registration registration, String id, String name,
106-
Function<AssertingParty, T> getter) {
107-
T newValue = getter.apply(registration.getAssertingParty());
108-
if (newValue != null) {
109-
return newValue;
110-
}
111-
T deprecatedValue = getter.apply(registration.getIdentityprovider());
112-
if (deprecatedValue != null) {
113-
logger.warn(String.format(
114-
"Property 'spring.security.saml2.relyingparty.registration.identityprovider.%1$s.%2$s' is deprecated, please use 'spring.security.saml2.relyingparty.registration.asserting-party.%1$s.%2$s' instead",
115-
id, name));
116-
return deprecatedValue;
117-
}
118-
return newValue;
119-
}
120-
121-
private Consumer<AssertingPartyDetails.Builder> mapAssertingParty(Registration registration, String id,
96+
private Consumer<AssertingPartyDetails.Builder> mapAssertingParty(AssertingParty assertingParty,
12297
boolean usingMetadata) {
12398
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
12499
return (details) -> {
125-
map.from(() -> getFromAssertingParty(registration, id, "entity-id", AssertingParty::getEntityId))
126-
.to(details::entityId);
127-
map.from(() -> getFromAssertingParty(registration, id, "singlesignon.binding",
128-
(property) -> property.getSinglesignon().getBinding())).to(details::singleSignOnServiceBinding);
129-
map.from(() -> getFromAssertingParty(registration, id, "singlesignon.url",
130-
(property) -> property.getSinglesignon().getUrl())).to(details::singleSignOnServiceLocation);
131-
map.from(() -> getFromAssertingParty(registration, id, "singlesignon.sign-request",
132-
(property) -> property.getSinglesignon().getSignRequest())).when((ignored) -> !usingMetadata)
100+
map.from(assertingParty::getEntityId).to(details::entityId);
101+
map.from(assertingParty.getSinglesignon()::getBinding).to(details::singleSignOnServiceBinding);
102+
map.from(assertingParty.getSinglesignon()::getUrl).to(details::singleSignOnServiceLocation);
103+
map.from(assertingParty.getSinglesignon()::isSignRequest).when((signRequest) -> !usingMetadata)
133104
.to(details::wantAuthnRequestsSigned);
134105
};
135106
}

0 commit comments

Comments
 (0)