Create spring-boot-security-saml2 module

This commit is contained in:
Andy Wilkinson
2025-03-31 15:07:32 +01:00
committed by Phillip Webb
parent 4d8b558b9b
commit 4ce8b591e0
27 changed files with 84 additions and 31 deletions

View File

@@ -104,6 +104,7 @@ include "spring-boot-project:spring-boot-security"
include "spring-boot-project:spring-boot-security-oauth2-authorization-server"
include "spring-boot-project:spring-boot-security-oauth2-client"
include "spring-boot-project:spring-boot-security-oauth2-resource-server"
include "spring-boot-project:spring-boot-security-saml2"
include "spring-boot-project:spring-boot-sendgrid"
include "spring-boot-project:spring-boot-test"
include "spring-boot-project:spring-boot-test-autoconfigure"

View File

@@ -9,6 +9,14 @@ plugins {
description = "Spring Boot Actuator AutoConfigure"
configurations.all {
resolutionStrategy.eachDependency {
if (it.requested.group == 'org.opensaml') {
it.useVersion '4.0.1'
}
}
}
dependencies {
api(project(":spring-boot-project:spring-boot-actuator"))
api(project(":spring-boot-project:spring-boot-all"))
@@ -50,6 +58,7 @@ dependencies {
optional(project(":spring-boot-project:spring-boot-reactor-netty"))
optional(project(":spring-boot-project:spring-boot-security-oauth2-client"))
optional(project(":spring-boot-project:spring-boot-security-oauth2-resource-server"))
optional(project(":spring-boot-project:spring-boot-security-saml2"))
optional(project(":spring-boot-project:spring-boot-tomcat"))
optional(project(":spring-boot-project:spring-boot-undertow"))
optional(project(":spring-boot-project:spring-boot-validation"))

View File

@@ -49,9 +49,10 @@ import static org.springframework.security.config.Customizer.withDefaults;
*/
@AutoConfiguration(before = SecurityAutoConfiguration.class,
after = { HealthEndpointAutoConfiguration.class, InfoEndpointAutoConfiguration.class },
afterName = { "org.springframework.boot.security.autoconfigure.saml2.Saml2RelyingPartyAutoConfiguration",
afterName = {
"org.springframework.boot.security.oauth2.client.autoconfigure.servlet.OAuth2ClientWebSecurityAutoConfiguration",
"org.springframework.boot.security.oauth2.server.resource.autoconfigure.servlet.OAuth2ResourceServerAutoConfiguration" })
"org.springframework.boot.security.oauth2.server.resource.autoconfigure.servlet.OAuth2ResourceServerAutoConfiguration",
"org.springframework.boot.security.saml2.autoconfigure.Saml2RelyingPartyAutoConfiguration" })
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
@ConditionalOnDefaultWebSecurity
public class ManagementWebSecurityAutoConfiguration {

View File

@@ -30,9 +30,9 @@ import org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoC
import org.springframework.boot.actuate.autoconfigure.info.InfoEndpointAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.security.autoconfigure.SecurityProperties;
import org.springframework.boot.security.autoconfigure.saml2.Saml2RelyingPartyAutoConfiguration;
import org.springframework.boot.security.autoconfigure.servlet.SecurityAutoConfiguration;
import org.springframework.boot.security.oauth2.server.resource.autoconfigure.servlet.OAuth2ResourceServerAutoConfiguration;
import org.springframework.boot.security.saml2.autoconfigure.Saml2RelyingPartyAutoConfiguration;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;

View File

@@ -115,6 +115,7 @@ dependencies {
autoConfiguration(project(path: ":spring-boot-project:spring-boot-security-oauth2-authorization-server", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-security-oauth2-client", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-security-oauth2-resource-server", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-security-saml2", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-sendgrid", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-testcontainers", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-thymeleaf", configuration: "autoConfigurationMetadata"))
@@ -182,6 +183,7 @@ dependencies {
configurationProperties(project(path: ":spring-boot-project:spring-boot-security-oauth2-authorization-server", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-security-oauth2-client", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-security-oauth2-resource-server", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-security-saml2", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-sendgrid", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-test-autoconfigure", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-testcontainers", configuration: "configurationPropertiesMetadata"))

View File

@@ -0,0 +1,35 @@
plugins {
id "java-library"
id "org.springframework.boot.auto-configuration"
id "org.springframework.boot.configuration-properties"
id "org.springframework.boot.deployed"
id "org.springframework.boot.optional-dependencies"
}
description = "Spring Boot Security SAML2"
configurations.all {
resolutionStrategy.eachDependency {
if (it.requested.group == 'org.opensaml') {
it.useVersion '4.0.1'
}
}
}
dependencies {
api(project(":spring-boot-project:spring-boot"))
api("org.springframework.security:spring-security-saml2-service-provider")
implementation(project(":spring-boot-project:spring-boot-security"))
optional(project(":spring-boot-project:spring-boot-autoconfigure"))
testImplementation(project(":spring-boot-project:spring-boot-test"))
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
testImplementation(project(":spring-boot-project:spring-boot-webmvc"))
testImplementation("com.fasterxml.jackson.core:jackson-databind")
testImplementation("com.squareup.okhttp3:mockwebserver")
testImplementation("jakarta.servlet:jakarta.servlet-api")
testRuntimeOnly("ch.qos.logback:logback-classic")
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.security.autoconfigure.saml2;
package org.springframework.boot.security.saml2.autoconfigure;
import java.util.Collections;
import java.util.Map;
@@ -24,7 +24,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.security.autoconfigure.saml2.Saml2RelyingPartyProperties.Registration;
import org.springframework.boot.security.saml2.autoconfigure.Saml2RelyingPartyProperties.Registration;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.security.autoconfigure.saml2;
package org.springframework.boot.security.saml2.autoconfigure;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.security.autoconfigure.ConditionalOnDefaultWebSecurity;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.security.autoconfigure.saml2;
package org.springframework.boot.security.saml2.autoconfigure;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.security.autoconfigure.saml2;
package org.springframework.boot.security.saml2.autoconfigure;
import java.util.ArrayList;
import java.util.LinkedHashMap;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.security.autoconfigure.saml2;
package org.springframework.boot.security.saml2.autoconfigure;
import java.io.InputStream;
import java.security.PrivateKey;
@@ -27,11 +27,11 @@ import java.util.function.Consumer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.boot.security.autoconfigure.saml2.Saml2RelyingPartyProperties.AssertingParty;
import org.springframework.boot.security.autoconfigure.saml2.Saml2RelyingPartyProperties.AssertingParty.Verification;
import org.springframework.boot.security.autoconfigure.saml2.Saml2RelyingPartyProperties.Decryption;
import org.springframework.boot.security.autoconfigure.saml2.Saml2RelyingPartyProperties.Registration;
import org.springframework.boot.security.autoconfigure.saml2.Saml2RelyingPartyProperties.Registration.Signing;
import org.springframework.boot.security.saml2.autoconfigure.Saml2RelyingPartyProperties.AssertingParty;
import org.springframework.boot.security.saml2.autoconfigure.Saml2RelyingPartyProperties.AssertingParty.Verification;
import org.springframework.boot.security.saml2.autoconfigure.Saml2RelyingPartyProperties.Decryption;
import org.springframework.boot.security.saml2.autoconfigure.Saml2RelyingPartyProperties.Registration;
import org.springframework.boot.security.saml2.autoconfigure.Saml2RelyingPartyProperties.Registration.Signing;
import org.springframework.boot.ssl.pem.PemContent;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;

View File

@@ -17,4 +17,4 @@
/**
* Auto-configuration for Spring Security's SAML 2.0.
*/
package org.springframework.boot.security.autoconfigure.saml2;
package org.springframework.boot.security.saml2.autoconfigure;

View File

@@ -0,0 +1 @@
org.springframework.boot.security.saml2.autoconfigure.Saml2RelyingPartyAutoConfiguration

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.security.autoconfigure.saml2;
package org.springframework.boot.security.saml2.autoconfigure;
import java.io.InputStream;
import java.util.List;
@@ -280,8 +280,8 @@ class Saml2RelyingPartyAutoConfigurationTests {
setupMockResponse(server, new ClassPathResource("idp-metadata"));
this.contextRunner.withPropertyValues(PREFIX + ".foo.assertingparty.metadata-uri=" + metadataUrl,
PREFIX + ".foo.assertingparty.singlesignon.sign-request=true",
PREFIX + ".foo.signing.credentials[0].private-key-location=classpath:org/springframework/boot/security/autoconfigure/saml2/rsa.key",
PREFIX + ".foo.signing.credentials[0].certificate-location=classpath:org/springframework/boot/security/autoconfigure/saml2/rsa.crt")
PREFIX + ".foo.signing.credentials[0].private-key-location=classpath:org/springframework/boot/security/saml2/autoconfigure/rsa.key",
PREFIX + ".foo.signing.credentials[0].certificate-location=classpath:org/springframework/boot/security/saml2/autoconfigure/rsa.crt")
.run((context) -> {
RelyingPartyRegistrationRepository repository = context
.getBean(RelyingPartyRegistrationRepository.class);

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.security.autoconfigure.saml2;
package org.springframework.boot.security.saml2.autoconfigure;
import java.util.Collections;
import java.util.Map;

View File

@@ -32,7 +32,6 @@ dependencies {
optional("org.springframework.security:spring-security-data")
optional("org.springframework.security:spring-security-messaging")
optional("org.springframework.security:spring-security-rsocket")
optional("org.springframework.security:spring-security-saml2-service-provider")
testImplementation(project(":spring-boot-project:spring-boot-http"))
testImplementation(project(":spring-boot-project:spring-boot-jackson"))
@@ -46,6 +45,7 @@ dependencies {
testImplementation("org.springframework.security:spring-security-oauth2-client")
testImplementation("org.springframework.security:spring-security-oauth2-jose")
testImplementation("org.springframework.security:spring-security-oauth2-resource-server")
testImplementation("org.springframework.security:spring-security-saml2-service-provider")
testRuntimeOnly("ch.qos.logback:logback-classic")
testRuntimeOnly("com.zaxxer:HikariCP")

View File

@@ -1,7 +1,6 @@
org.springframework.boot.security.autoconfigure.reactive.ReactiveSecurityAutoConfiguration
org.springframework.boot.security.autoconfigure.reactive.ReactiveUserDetailsServiceAutoConfiguration
org.springframework.boot.security.autoconfigure.rsocket.RSocketSecurityAutoConfiguration
org.springframework.boot.security.autoconfigure.saml2.Saml2RelyingPartyAutoConfiguration
org.springframework.boot.security.autoconfigure.servlet.SecurityAutoConfiguration
org.springframework.boot.security.autoconfigure.servlet.SecurityFilterAutoConfiguration
org.springframework.boot.security.autoconfigure.servlet.UserDetailsServiceAutoConfiguration

View File

@@ -7,6 +7,14 @@ plugins {
description = "Spring Boot Test AutoConfigure"
configurations.all {
resolutionStrategy.eachDependency {
if (it.requested.group == 'org.opensaml') {
it.useVersion '4.0.1'
}
}
}
dependencies {
api(project(":spring-boot-project:spring-boot-all"))
api(project(":spring-boot-project:spring-boot-test"))
@@ -65,6 +73,7 @@ dependencies {
optional(project(":spring-boot-project:spring-boot-security"))
optional(project(":spring-boot-project:spring-boot-security-oauth2-client"))
optional(project(":spring-boot-project:spring-boot-security-oauth2-resource-server"))
optional(project(":spring-boot-project:spring-boot-security-saml2"))
optional(project(":spring-boot-project:spring-boot-tx"))
optional(project(":spring-boot-project:spring-boot-validation"))
optional(project(":spring-boot-project:spring-boot-webmvc"))
@@ -137,17 +146,9 @@ dependencies {
testImplementation("org.jooq:jooq")
testImplementation("org.junit.platform:junit-platform-engine")
testImplementation("org.junit.platform:junit-platform-launcher")
testImplementation("org.opensaml:opensaml-core:4.0.1")
testImplementation("org.opensaml:opensaml-saml-api:4.0.1")
testImplementation("org.opensaml:opensaml-saml-impl:4.0.1")
testImplementation("org.springframework.hateoas:spring-hateoas")
testImplementation("org.springframework.plugin:spring-plugin-core")
testImplementation("org.springframework.security:spring-security-oauth2-client")
testImplementation("org.springframework.security:spring-security-saml2-service-provider") {
exclude group: "org.opensaml", module: "opensaml-core"
exclude group: "org.opensaml", module: "opensaml-saml-api"
exclude group: "org.opensaml", module: "opensaml-saml-impl"
}
testImplementation("org.thymeleaf:thymeleaf")
testRuntimeOnly(project(":spring-boot-project:spring-boot-tomcat"))

View File

@@ -5,9 +5,9 @@ optional:org.springframework.boot.security.autoconfigure.servlet.UserDetailsServ
optional:org.springframework.boot.security.oauth2.client.autoconfigure.OAuth2ClientAutoConfiguration
optional:org.springframework.boot.security.oauth2.client.autoconfigure.servlet.OAuth2ClientWebSecurityAutoConfiguration
optional:org.springframework.boot.security.oauth2.server.resource.autoconfigure.servlet.OAuth2ResourceServerAutoConfiguration
optional:org.springframework.boot.security.saml2.autoconfigure.Saml2RelyingPartyAutoConfiguration
org.springframework.boot.test.autoconfigure.web.servlet.MockMvcAutoConfiguration
org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebClientAutoConfiguration
org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebDriverAutoConfiguration
org.springframework.boot.autoconfigure.security.saml2.Saml2RelyingPartyAutoConfiguration
org.springframework.boot.test.autoconfigure.web.servlet.MockMvcSecurityConfiguration
org.springframework.boot.test.autoconfigure.web.reactive.WebTestClientAutoConfiguration

View File

@@ -15,7 +15,7 @@ configurations.all {
dependencies {
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-security"))
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web"))
implementation("org.springframework.security:spring-security-saml2-service-provider")
implementation(project(":spring-boot-project:spring-boot-security-saml2"))
testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
testImplementation("org.apache.httpcomponents.client5:httpclient5")