Skip to content

Commit 5ec3580

Browse files
committed
Merge branch '2.7.x' into 3.0.x
Closes gh-37481
2 parents 7f7b325 + 0ed455b commit 5ec3580

File tree

6 files changed

+85
-15
lines changed

6 files changed

+85
-15
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ public static class Singlesignon {
295295
/**
296296
* Whether to sign authentication requests.
297297
*/
298-
private boolean signRequest = true;
298+
private Boolean signRequest;
299299

300300
public String getUrl() {
301301
return this.url;
@@ -317,7 +317,11 @@ public boolean isSignRequest() {
317317
return this.signRequest;
318318
}
319319

320-
public void setSignRequest(boolean signRequest) {
320+
public Boolean getSignRequest() {
321+
return this.signRequest;
322+
}
323+
324+
public void setSignRequest(Boolean signRequest) {
321325
this.signRequest = signRequest;
322326
}
323327

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ private RelyingPartyRegistration asRegistration(Map.Entry<String, Registration>
7979
private RelyingPartyRegistration asRegistration(String id, Registration properties) {
8080
boolean usingMetadata = StringUtils.hasText(properties.getAssertingparty().getMetadataUri());
8181
Builder builder = (!usingMetadata) ? RelyingPartyRegistration.withRegistrationId(id)
82-
: createBuilderUsingMetadata(id, properties.getAssertingparty()).registrationId(id);
82+
: createBuilderUsingMetadata(properties.getAssertingparty()).registrationId(id);
8383
builder.assertionConsumerServiceLocation(properties.getAcs().getLocation());
8484
builder.assertionConsumerServiceBinding(properties.getAcs().getBinding());
85-
builder.assertingPartyDetails(mapAssertingParty(properties.getAssertingparty(), usingMetadata));
85+
builder.assertingPartyDetails(mapAssertingParty(properties.getAssertingparty()));
8686
builder.signingX509Credentials((credentials) -> properties.getSigning()
8787
.getCredentials()
8888
.stream()
@@ -110,7 +110,7 @@ private RelyingPartyRegistration asRegistration(String id, Registration properti
110110
return registration;
111111
}
112112

113-
private RelyingPartyRegistration.Builder createBuilderUsingMetadata(String id, AssertingParty properties) {
113+
private RelyingPartyRegistration.Builder createBuilderUsingMetadata(AssertingParty properties) {
114114
String requiredEntityId = properties.getEntityId();
115115
Collection<Builder> candidates = RelyingPartyRegistrations
116116
.collectionFromMetadataLocation(properties.getMetadataUri());
@@ -128,16 +128,13 @@ private Object getEntityId(RelyingPartyRegistration.Builder candidate) {
128128
return result[0];
129129
}
130130

131-
private Consumer<AssertingPartyDetails.Builder> mapAssertingParty(AssertingParty assertingParty,
132-
boolean usingMetadata) {
131+
private Consumer<AssertingPartyDetails.Builder> mapAssertingParty(AssertingParty assertingParty) {
133132
return (details) -> {
134133
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
135134
map.from(assertingParty::getEntityId).to(details::entityId);
136135
map.from(assertingParty.getSinglesignon()::getBinding).to(details::singleSignOnServiceBinding);
137136
map.from(assertingParty.getSinglesignon()::getUrl).to(details::singleSignOnServiceLocation);
138-
map.from(assertingParty.getSinglesignon()::isSignRequest)
139-
.when((signRequest) -> !usingMetadata)
140-
.to(details::wantAuthnRequestsSigned);
137+
map.from(assertingParty.getSinglesignon()::getSignRequest).to(details::wantAuthnRequestsSigned);
141138
map.from(assertingParty.getSinglelogout()::getUrl).to(details::singleLogoutServiceLocation);
142139
map.from(assertingParty.getSinglelogout()::getResponseUrl).to(details::singleLogoutServiceResponseLocation);
143140
map.from(assertingParty.getSinglelogout()::getBinding).to(details::singleLogoutServiceBinding);

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyAutoConfigurationTests.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.boot.autoconfigure.security.saml2;
1818

19-
import java.io.IOException;
2019
import java.io.InputStream;
2120
import java.util.List;
2221

@@ -253,7 +252,26 @@ void autoconfigurationWhenMultipleProvidersAndSpecifiedEntityId() throws Excepti
253252
testMultipleProviders("https://idp2.example.com/idp/shibboleth", "https://idp2.example.com/idp/shibboleth");
254253
}
255254

256-
private void testMultipleProviders(String specifiedEntityId, String expected) throws IOException, Exception {
255+
@Test
256+
void signRequestShouldApplyIfMetadataUriIsSet() throws Exception {
257+
try (MockWebServer server = new MockWebServer()) {
258+
server.start();
259+
String metadataUrl = server.url("").toString();
260+
setupMockResponse(server, new ClassPathResource("saml/idp-metadata"));
261+
this.contextRunner.withPropertyValues(PREFIX + ".foo.assertingparty.metadata-uri=" + metadataUrl,
262+
PREFIX + ".foo.assertingparty.singlesignon.sign-request=true",
263+
PREFIX + ".foo.signing.credentials[0].private-key-location=classpath:org/springframework/boot/autoconfigure/security/saml2/rsa.key",
264+
PREFIX + ".foo.signing.credentials[0].certificate-location=classpath:org/springframework/boot/autoconfigure/security/saml2/rsa.crt")
265+
.run((context) -> {
266+
RelyingPartyRegistrationRepository repository = context
267+
.getBean(RelyingPartyRegistrationRepository.class);
268+
RelyingPartyRegistration registration = repository.findByRegistrationId("foo");
269+
assertThat(registration.getAssertingPartyDetails().getWantAuthnRequestsSigned()).isTrue();
270+
});
271+
}
272+
}
273+
274+
private void testMultipleProviders(String specifiedEntityId, String expected) throws Exception {
257275
try (MockWebServer server = new MockWebServer()) {
258276
server.start();
259277
String metadataUrl = server.url("").toString();

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyPropertiesTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void customizeSsoSignRequests() {
6767
.get("simplesamlphp")
6868
.getAssertingparty()
6969
.getSinglesignon()
70-
.isSignRequest()).isFalse();
70+
.getSignRequest()).isFalse();
7171
}
7272

7373
@Test
@@ -93,13 +93,13 @@ void customizeAssertingPartyMetadataUri() {
9393
}
9494

9595
@Test
96-
void customizeSsoSignRequestsIsTrueByDefault() {
96+
void customizeSsoSignRequestsIsNullByDefault() {
9797
this.properties.getRegistration().put("simplesamlphp", new Saml2RelyingPartyProperties.Registration());
9898
assertThat(this.properties.getRegistration()
9999
.get("simplesamlphp")
100100
.getAssertingparty()
101101
.getSinglesignon()
102-
.isSignRequest()).isTrue();
102+
.getSignRequest()).isNull();
103103
}
104104

105105
private void bind(String name, String value) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIID1zCCAr+gAwIBAgIUCzQeKBMTO0iHVW3iKmZC41haqCowDQYJKoZIhvcNAQEL
3+
BQAwezELMAkGA1UEBhMCWFgxEjAQBgNVBAgMCVN0YXRlTmFtZTERMA8GA1UEBwwI
4+
Q2l0eU5hbWUxFDASBgNVBAoMC0NvbXBhbnlOYW1lMRswGQYDVQQLDBJDb21wYW55
5+
U2VjdGlvbk5hbWUxEjAQBgNVBAMMCWxvY2FsaG9zdDAeFw0yMzA5MjAwODI5MDNa
6+
Fw0zMzA5MTcwODI5MDNaMHsxCzAJBgNVBAYTAlhYMRIwEAYDVQQIDAlTdGF0ZU5h
7+
bWUxETAPBgNVBAcMCENpdHlOYW1lMRQwEgYDVQQKDAtDb21wYW55TmFtZTEbMBkG
8+
A1UECwwSQ29tcGFueVNlY3Rpb25OYW1lMRIwEAYDVQQDDAlsb2NhbGhvc3QwggEi
9+
MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDUfi4aaCotJZX6OSDjv6fxCCfc
10+
ihSs91Z/mmN+yc1fsxVSs53SIbqUuo+Wzhv34kp8I/r03P9LWVTkFPbeDxAl75Oa
11+
PGggxK55US0Zfy9Hj1BwWIKV3330N61emID1GDEtFKL4yJbJdreQXnIXTBL2o76V
12+
nuV/tYozyZnb07IQ1WhUm5WDxgzM0yFudMynTczCBeZHfvharDtB8PFFhCZXW2/9
13+
TZVVfW4oOML8EAX3hvnvYBlFl/foxXekZSwq/odOkmWCZavT2+0sburHUlOnPGUh
14+
Qj4tHwpMRczp7VX4ptV1D2UrxsK/2B+s9FK2QSLKQ9JzAYJ6WxQjHcvET9jvAgMB
15+
AAGjUzBRMB0GA1UdDgQWBBQjDr/1E/01pfLPD8uWF7gbaYL0TTAfBgNVHSMEGDAW
16+
gBQjDr/1E/01pfLPD8uWF7gbaYL0TTAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3
17+
DQEBCwUAA4IBAQAGjUuec0+0XNMCRDKZslbImdCAVsKsEWk6NpnUViDFAxL+KQuC
18+
NW131UeHb9SCzMqRwrY4QI3nAwJQCmilL/hFM3ss4acn3WHu1yci/iKPUKeL1ec5
19+
kCFUmqX1NpTiVaytZ/9TKEr69SMVqNfQiuW5U1bIIYTqK8xo46WpM6YNNHO3eJK6
20+
NH0MW79Wx5ryi4i4C6afqYbVbx7tqcmy8CFeNxgZ0bFQ87SiwYXIj77b6sVYbu32
21+
doykBQgSHLcagWASPQ73m73CWUgo+7+EqSKIQqORbgmTLPmOUh99gFIx7jmjTyHm
22+
NBszx1ZVWuIv3mWmp626Kncyc+LLM9tvgymx
23+
-----END CERTIFICATE-----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-----BEGIN PRIVATE KEY-----
2+
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDUfi4aaCotJZX6
3+
OSDjv6fxCCfcihSs91Z/mmN+yc1fsxVSs53SIbqUuo+Wzhv34kp8I/r03P9LWVTk
4+
FPbeDxAl75OaPGggxK55US0Zfy9Hj1BwWIKV3330N61emID1GDEtFKL4yJbJdreQ
5+
XnIXTBL2o76VnuV/tYozyZnb07IQ1WhUm5WDxgzM0yFudMynTczCBeZHfvharDtB
6+
8PFFhCZXW2/9TZVVfW4oOML8EAX3hvnvYBlFl/foxXekZSwq/odOkmWCZavT2+0s
7+
burHUlOnPGUhQj4tHwpMRczp7VX4ptV1D2UrxsK/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