Create spring-boot-security-oauth2-authorization-server

Issue: 46136
This commit is contained in:
Andy Wilkinson 2025-03-28 13:21:19 +00:00 committed by Phillip Webb
parent 2d838546c3
commit a67f0dd705
21 changed files with 76 additions and 25 deletions

View File

@ -117,6 +117,7 @@ include "spring-boot-project:spring-boot-r2dbc"
include "spring-boot-project:spring-boot-reactor-netty"
include "spring-boot-project:spring-boot-rsocket"
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-sendgrid"

View File

@ -18,8 +18,6 @@ org.springframework.boot.autoconfigure.http.client.reactive.service.ReactiveHttp
org.springframework.boot.autoconfigure.http.codec.CodecsAutoConfiguration
org.springframework.boot.autoconfigure.netty.NettyAutoConfiguration
org.springframework.boot.autoconfigure.reactor.ReactorAutoConfiguration
org.springframework.boot.autoconfigure.security.oauth2.server.servlet.OAuth2AuthorizationServerAutoConfiguration
org.springframework.boot.autoconfigure.security.oauth2.server.servlet.OAuth2AuthorizationServerJwtAutoConfiguration
org.springframework.boot.autoconfigure.session.SessionAutoConfiguration
org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration
org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration

View File

@ -2047,6 +2047,7 @@ bom {
"spring-boot-reactor-netty",
"spring-boot-rsocket",
"spring-boot-security",
"spring-boot-security-oauth2-authorization-server",
"spring-boot-security-oauth2-client",
"spring-boot-security-oauth2-resource-server",
"spring-boot-sendgrid",

View File

@ -128,6 +128,7 @@ dependencies {
autoConfiguration(project(path: ":spring-boot-project:spring-boot-reactor-netty", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-rsocket", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-security", configuration: "autoConfigurationMetadata"))
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-sendgrid", configuration: "autoConfigurationMetadata"))
@ -194,6 +195,7 @@ dependencies {
configurationProperties(project(path: ":spring-boot-project:spring-boot-reactor-netty", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-rsocket", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-security", configuration: "configurationPropertiesMetadata"))
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-sendgrid", configuration: "configurationPropertiesMetadata"))

View File

@ -0,0 +1,42 @@
/*
* Copyright 2012-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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 OAuth2 Authorization Server"
dependencies {
api(project(":spring-boot-project:spring-boot"))
api("org.springframework.security:spring-security-oauth2-authorization-server")
implementation(project(":spring-boot-project:spring-boot-security"))
optional(project(":spring-boot-project:spring-boot-autoconfigure"))
optional(project(":spring-boot-project:spring-boot-security-oauth2-resource-server"))
testImplementation(project(":spring-boot-project:spring-boot-test"))
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
testImplementation("jakarta.servlet:jakarta.servlet-api")
testRuntimeOnly("ch.qos.logback:logback-classic")
}

View File

@ -14,12 +14,13 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.security.oauth2.server.servlet;
package org.springframework.boot.security.oauth2.server.authorization.autoconfigure.servlet;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.security.autoconfigure.servlet.SecurityAutoConfiguration;
import org.springframework.boot.security.autoconfigure.servlet.UserDetailsServiceAutoConfiguration;
import org.springframework.context.annotation.Import;
import org.springframework.security.oauth2.server.authorization.OAuth2Authorization;
@ -37,11 +38,11 @@ import org.springframework.security.oauth2.server.authorization.OAuth2Authorizat
* if necessary.
*
* @author Steve Riesenberg
* @since 3.1.0
* @since 4.0.0
* @see OAuth2AuthorizationServerJwtAutoConfiguration
*/
@AutoConfiguration(beforeName = { "org.springframework.boot.security.autoconfigure.servlet.SecurityAutoConfiguration",
"org.springframework.boot.autoconfigure.security.oauth2.resource.servlet.OAuth2ResourceServerAutoConfiguration" })
@AutoConfiguration(before = SecurityAutoConfiguration.class,
beforeName = "org.springframework.boot.security.oauth2.server.resource.autoconfigure.servlet.OAuth2ResourceServerAutoConfiguration")
@ConditionalOnClass(OAuth2Authorization.class)
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
@Import({ OAuth2AuthorizationServerConfiguration.class, OAuth2AuthorizationServerWebSecurityConfiguration.class })

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.security.oauth2.server.servlet;
package org.springframework.boot.security.oauth2.server.authorization.autoconfigure.servlet;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.security.oauth2.server.servlet;
package org.springframework.boot.security.oauth2.server.authorization.autoconfigure.servlet;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
@ -34,6 +34,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.security.autoconfigure.servlet.UserDetailsServiceAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Role;
@ -46,10 +47,9 @@ import org.springframework.security.oauth2.server.authorization.config.annotatio
* OAuth2 authorization server that require it (e.g. User Info, Client Registration).
*
* @author Steve Riesenberg
* @since 3.1.0
* @since 4.0.0
*/
@AutoConfiguration(
afterName = "org.springframework.boot.security.autoconfigure.servlet.UserDetailsServiceAutoConfiguration")
@AutoConfiguration(after = UserDetailsServiceAutoConfiguration.class)
@ConditionalOnClass({ OAuth2Authorization.class, JWKSource.class })
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
public class OAuth2AuthorizationServerJwtAutoConfiguration {

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.security.oauth2.server.servlet;
package org.springframework.boot.security.oauth2.server.authorization.autoconfigure.servlet;
import java.time.Duration;
import java.util.HashMap;
@ -32,7 +32,7 @@ import org.springframework.util.StringUtils;
* OAuth 2.0 Authorization Server properties.
*
* @author Steve Riesenberg
* @since 3.1.0
* @since 4.0.0
*/
@ConfigurationProperties("spring.security.oauth2.authorizationserver")
public class OAuth2AuthorizationServerProperties implements InitializingBean {

View File

@ -14,15 +14,15 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.security.oauth2.server.servlet;
package org.springframework.boot.security.oauth2.server.authorization.autoconfigure.servlet;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import org.springframework.boot.autoconfigure.security.oauth2.server.servlet.OAuth2AuthorizationServerProperties.Client;
import org.springframework.boot.autoconfigure.security.oauth2.server.servlet.OAuth2AuthorizationServerProperties.Registration;
import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.boot.security.oauth2.server.authorization.autoconfigure.servlet.OAuth2AuthorizationServerProperties.Client;
import org.springframework.boot.security.oauth2.server.authorization.autoconfigure.servlet.OAuth2AuthorizationServerProperties.Registration;
import org.springframework.security.oauth2.core.AuthorizationGrantType;
import org.springframework.security.oauth2.core.ClientAuthenticationMethod;
import org.springframework.security.oauth2.jose.jws.JwsAlgorithm;

View File

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

View File

@ -17,4 +17,4 @@
/**
* Auto-configuration for Spring Security's OAuth2 authorization server.
*/
package org.springframework.boot.autoconfigure.security.oauth2.server.servlet;
package org.springframework.boot.security.oauth2.server.authorization.autoconfigure.servlet;

View File

@ -0,0 +1,2 @@
org.springframework.boot.security.oauth2.server.authorization.autoconfigure.servlet.OAuth2AuthorizationServerAutoConfiguration
org.springframework.boot.security.oauth2.server.authorization.autoconfigure.servlet.OAuth2AuthorizationServerJwtAutoConfiguration

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.security.oauth2.server.servlet;
package org.springframework.boot.security.oauth2.server.authorization.autoconfigure.servlet;
import org.junit.jupiter.api.Test;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.security.oauth2.server.servlet;
package org.springframework.boot.security.oauth2.server.authorization.autoconfigure.servlet;
import com.nimbusds.jose.jwk.source.ImmutableJWKSet;
import com.nimbusds.jose.jwk.source.JWKSource;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.security.oauth2.server.servlet;
package org.springframework.boot.security.oauth2.server.authorization.autoconfigure.servlet;
import java.time.Duration;
import java.util.List;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.security.oauth2.server.servlet;
package org.springframework.boot.security.oauth2.server.authorization.autoconfigure.servlet;
import org.junit.jupiter.api.Test;

View File

@ -23,5 +23,5 @@ description = "Starter for using Spring Authorization Server features"
dependencies {
api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-security"))
api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web"))
api("org.springframework.security:spring-security-oauth2-authorization-server")
api(project(":spring-boot-project:spring-boot-security-oauth2-authorization-server"))
}