Skip to content

Commit 7778198

Browse files
committed
Merge remote-tracking branch 'origin/main' into draft-interface-clients-autoconfiguration
2 parents 5d9a0c4 + cc3e62d commit 7778198

File tree

20 files changed

+97
-37
lines changed

20 files changed

+97
-37
lines changed

.github/actions/prepare-gradle-build/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ runs:
3232
${{ inputs.java-early-access == 'true' && format('{0}-ea', inputs.java-version) || inputs.java-version }}
3333
${{ inputs.java-toolchain == 'true' && '17' || '' }}
3434
- name: Set Up Gradle
35-
uses: gradle/actions/setup-gradle@d9c87d481d55275bb5441eef3fe0e46805f9ef70 # v3.5.0
35+
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
3636
with:
3737
cache-read-only: false
3838
develocity-access-key: ${{ inputs.develocity-access-key }}

.github/actions/publish-gradle-plugin/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ runs:
2121
using: composite
2222
steps:
2323
- name: Set Up JFrog CLI
24-
uses: jfrog/setup-jfrog-cli@105617d23456a69a92485207c4f28ae12297581d # v4.2.1
24+
uses: jfrog/setup-jfrog-cli@26532cdb5b1ea07940f10d57666fd988048fc903 # v4.2.2
2525
env:
2626
JF_ENV_SPRING: ${{ inputs.jfrog-cli-config-token }}
2727
- name: Download Artifacts

.github/actions/sync-to-maven-central/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ runs:
2020
using: composite
2121
steps:
2222
- name: Set Up JFrog CLI
23-
uses: jfrog/setup-jfrog-cli@105617d23456a69a92485207c4f28ae12297581d # v4.2.1
23+
uses: jfrog/setup-jfrog-cli@26532cdb5b1ea07940f10d57666fd988048fc903 # v4.2.2
2424
env:
2525
JF_ENV_SPRING: ${{ inputs.jfrog-cli-config-token }}
2626
- name: Download Release Artifacts

.github/workflows/build-pull-request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ jobs:
2323
- name: Check Out
2424
uses: actions/checkout@v4
2525
- name: Validate Gradle Wrapper
26-
uses: gradle/actions/wrapper-validation@d9c87d481d55275bb5441eef3fe0e46805f9ef70 # v3.5.0
26+
uses: gradle/actions/wrapper-validation@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
2727
- name: Set Up Gradle
28-
uses: gradle/actions/setup-gradle@d9c87d481d55275bb5441eef3fe0e46805f9ef70 # v3.5.0
28+
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
2929
- name: Build
3030
env:
3131
CI: 'true'

.github/workflows/release-milestone.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
runs-on: ubuntu-latest
5454
steps:
5555
- name: Set up JFrog CLI
56-
uses: jfrog/setup-jfrog-cli@105617d23456a69a92485207c4f28ae12297581d # v4.2.1
56+
uses: jfrog/setup-jfrog-cli@26532cdb5b1ea07940f10d57666fd988048fc903 # v4.2.2
5757
env:
5858
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
5959
- name: Promote build

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
runs-on: ubuntu-latest
7070
steps:
7171
- name: Set up JFrog CLI
72-
uses: jfrog/setup-jfrog-cli@105617d23456a69a92485207c4f28ae12297581d # v4.2.1
72+
uses: jfrog/setup-jfrog-cli@26532cdb5b1ea07940f10d57666fd988048fc903 # v4.2.2
7373
env:
7474
JF_ENV_SPRING: ${{ secrets.JF_ARTIFACTORY_SPRING }}
7575
- name: Promote build

.github/workflows/validate-gradle-wrapper.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows/verify.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- name: Set Up Homebrew
4343
uses: Homebrew/actions/setup-homebrew@7657c9512f50e1c35b640971116425935bab3eea
4444
- name: Set Up Gradle
45-
uses: gradle/actions/setup-gradle@d9c87d481d55275bb5441eef3fe0e46805f9ef70 # v3.5.0
45+
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
4646
with:
4747
cache-read-only: false
4848
- name: Configure Gradle Properties

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package org.springframework.boot.autoconfigure.security.saml2;
1818

1919
import java.io.InputStream;
20-
import java.security.cert.CertificateFactory;
20+
import java.security.PrivateKey;
2121
import java.security.cert.X509Certificate;
2222
import java.security.interfaces.RSAPrivateKey;
2323
import java.util.Collection;
@@ -32,11 +32,11 @@
3232
import org.springframework.boot.autoconfigure.security.saml2.Saml2RelyingPartyProperties.Registration;
3333
import org.springframework.boot.autoconfigure.security.saml2.Saml2RelyingPartyProperties.Registration.Signing;
3434
import org.springframework.boot.context.properties.PropertyMapper;
35+
import org.springframework.boot.ssl.pem.PemContent;
3536
import org.springframework.context.annotation.Bean;
3637
import org.springframework.context.annotation.Conditional;
3738
import org.springframework.context.annotation.Configuration;
3839
import org.springframework.core.io.Resource;
39-
import org.springframework.security.converter.RsaKeyConverters;
4040
import org.springframework.security.saml2.core.Saml2X509Credential;
4141
import org.springframework.security.saml2.core.Saml2X509Credential.Saml2X509CredentialType;
4242
import org.springframework.security.saml2.provider.service.registration.AssertingPartyMetadata;
@@ -57,6 +57,7 @@
5757
* @author Moritz Halbritter
5858
* @author Lasse Lindqvist
5959
* @author Lasse Wulff
60+
* @author Scott Frederick
6061
*/
6162
@Configuration(proxyBeanMethods = false)
6263
@Conditional(RegistrationConfiguredCondition.class)
@@ -172,7 +173,11 @@ private RSAPrivateKey readPrivateKey(Resource location) {
172173
Assert.state(location != null, "No private key location specified");
173174
Assert.state(location.exists(), () -> "Private key location '" + location + "' does not exist");
174175
try (InputStream inputStream = location.getInputStream()) {
175-
return RsaKeyConverters.pkcs8().convert(inputStream);
176+
PemContent pemContent = PemContent.load(inputStream);
177+
PrivateKey privateKey = pemContent.getPrivateKey();
178+
Assert.isInstanceOf(RSAPrivateKey.class, privateKey,
179+
"PrivateKey in resource '" + location + "' must be an RSAPrivateKey");
180+
return (RSAPrivateKey) privateKey;
176181
}
177182
catch (Exception ex) {
178183
throw new IllegalArgumentException(ex);
@@ -183,7 +188,9 @@ private X509Certificate readCertificate(Resource location) {
183188
Assert.state(location != null, "No certificate location specified");
184189
Assert.state(location.exists(), () -> "Certificate location '" + location + "' does not exist");
185190
try (InputStream inputStream = location.getInputStream()) {
186-
return (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(inputStream);
191+
PemContent pemContent = PemContent.load(inputStream);
192+
List<X509Certificate> certificates = pemContent.getCertificates();
193+
return certificates.get(0);
187194
}
188195
catch (Exception ex) {
189196
throw new IllegalArgumentException(ex);

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
* @author Madhura Bhave
5959
* @author Moritz Halbritter
6060
* @author Lasse Lindqvist
61+
* @author Scott Frederick
6162
*/
6263
class Saml2RelyingPartyAutoConfigurationTests {
6364

@@ -273,6 +274,38 @@ void signRequestShouldApplyIfMetadataUriIsSet() throws Exception {
273274
}
274275
}
275276

277+
@Test
278+
void autoconfigurationWithInvalidPrivateKeyShouldFail() {
279+
this.contextRunner.withPropertyValues(
280+
PREFIX + ".foo.signing.credentials[0].private-key-location=classpath:saml/certificate-location",
281+
PREFIX + ".foo.signing.credentials[0].certificate-location=classpath:saml/certificate-location",
282+
PREFIX + ".foo.assertingparty.singlesignon.url=https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/SSOService.php",
283+
PREFIX + ".foo.assertingparty.singlesignon.binding=post",
284+
PREFIX + ".foo.assertingparty.singlesignon.sign-request=false",
285+
PREFIX + ".foo.assertingparty.entity-id=https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php",
286+
PREFIX + ".foo.assertingparty.verification.credentials[0].certificate-location=classpath:saml/certificate-location")
287+
.run((context) -> assertThat(context).hasFailed()
288+
.getFailure()
289+
.rootCause()
290+
.hasMessageContaining("Missing private key or unrecognized format"));
291+
}
292+
293+
@Test
294+
void autoconfigurationWithInvalidCertificateShouldFail() {
295+
this.contextRunner.withPropertyValues(
296+
PREFIX + ".foo.signing.credentials[0].private-key-location=classpath:saml/private-key-location",
297+
PREFIX + ".foo.signing.credentials[0].certificate-location=classpath:saml/private-key-location",
298+
PREFIX + ".foo.assertingparty.singlesignon.url=https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/SSOService.php",
299+
PREFIX + ".foo.assertingparty.singlesignon.binding=post",
300+
PREFIX + ".foo.assertingparty.singlesignon.sign-request=false",
301+
PREFIX + ".foo.assertingparty.entity-id=https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php",
302+
PREFIX + ".foo.assertingparty.verification.credentials[0].certificate-location=classpath:saml/certificate-location")
303+
.run((context) -> assertThat(context).hasFailed()
304+
.getFailure()
305+
.rootCause()
306+
.hasMessageContaining("Missing certificates or unrecognized format"));
307+
}
308+
276309
private void testMultipleProviders(String specifiedEntityId, String expected) throws Exception {
277310
try (MockWebServer server = new MockWebServer()) {
278311
server.start();

0 commit comments

Comments
 (0)