Skip to content

Commit 7a2612d

Browse files
Add Kotlin DSL for OAuth Authorization Server configuration
Signed-off-by: Mehrdad <mehrdad.bozorgmehr@gmail.com>
1 parent 27ae318 commit 7a2612d

File tree

9 files changed

+923
-0
lines changed

9 files changed

+923
-0
lines changed

config/src/main/kotlin/org/springframework/security/config/annotation/web/HttpSecurityDsl.kt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,39 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
10591059
this.http.oauth2ResourceServer(oauth2ResourceServerCustomizer)
10601060
}
10611061

1062+
/**
1063+
* Configures OAuth 2.1 Authorization Server support.
1064+
*
1065+
* Example:
1066+
*
1067+
* ```
1068+
* @Configuration
1069+
* @EnableWebSecurity
1070+
* class SecurityConfig {
1071+
*
1072+
* @Bean
1073+
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
1074+
* http {
1075+
* oauth2AuthorizationServer {
1076+
* oidc {
1077+
* userInfoEndpoint { }
1078+
* }
1079+
* }
1080+
* }
1081+
* return http.build()
1082+
* }
1083+
* }
1084+
* ```
1085+
*
1086+
* @param oauth2AuthorizationServerConfiguration custom configuration to configure the
1087+
* OAuth 2.1 Authorization Server support
1088+
* @see [OAuth2AuthorizationServerDsl]
1089+
*/
1090+
fun oauth2AuthorizationServer(oauth2AuthorizationServerConfiguration: OAuth2AuthorizationServerDsl.() -> Unit) {
1091+
val oauth2AuthorizationServerCustomizer = OAuth2AuthorizationServerDsl().apply(oauth2AuthorizationServerConfiguration).get()
1092+
this.http.oauth2AuthorizationServer(oauth2AuthorizationServerCustomizer)
1093+
}
1094+
10621095
/**
10631096
* Configures OIDC 1.0 logout support.
10641097
*

0 commit comments

Comments
 (0)