mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-01 09:42:13 +00:00
Remove WebSecurityConfigurerAdapter in Kotlin DSL
Issue gh-11277 Closes gh-11646
This commit is contained in:
parent
c4a4524f4b
commit
2e26e875c8
@ -33,9 +33,10 @@ import javax.servlet.http.HttpServletRequest
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* authorizeRequests {
|
* authorizeRequests {
|
||||||
* authorize("/public", permitAll)
|
* authorize("/public", permitAll)
|
||||||
@ -45,6 +46,7 @@ import javax.servlet.http.HttpServletRequest
|
|||||||
* loginPage = "/log-in"
|
* loginPage = "/log-in"
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -83,15 +85,17 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* securityMatcher("/private/**")
|
* securityMatcher("/private/**")
|
||||||
* formLogin {
|
* formLogin {
|
||||||
* loginPage = "/log-in"
|
* loginPage = "/log-in"
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -123,15 +127,17 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* securityMatcher(AntPathRequestMatcher("/private/**"))
|
* securityMatcher(AntPathRequestMatcher("/private/**"))
|
||||||
* formLogin {
|
* formLogin {
|
||||||
* loginPage = "/log-in"
|
* loginPage = "/log-in"
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -152,14 +158,16 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* formLogin {
|
* formLogin {
|
||||||
* loginPage = "/log-in"
|
* loginPage = "/log-in"
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -180,15 +188,17 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* authorizeRequests {
|
* authorizeRequests {
|
||||||
* authorize("/public", permitAll)
|
* authorize("/public", permitAll)
|
||||||
* authorize(anyRequest, authenticated)
|
* authorize(anyRequest, authenticated)
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -241,14 +251,16 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* httpBasic {
|
* httpBasic {
|
||||||
* realmName = "Custom Realm"
|
* realmName = "Custom Realm"
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -269,14 +281,16 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* passwordManagement {
|
* passwordManagement {
|
||||||
* changePasswordPage = "/custom-change-password-page"
|
* changePasswordPage = "/custom-change-password-page"
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -298,9 +312,10 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* headers {
|
* headers {
|
||||||
* referrerPolicy {
|
* referrerPolicy {
|
||||||
@ -308,6 +323,7 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -328,14 +344,16 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* cors {
|
* cors {
|
||||||
* disable()
|
* disable()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -356,9 +374,10 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* sessionManagement {
|
* sessionManagement {
|
||||||
* invalidSessionUrl = "/invalid-session"
|
* invalidSessionUrl = "/invalid-session"
|
||||||
@ -367,6 +386,7 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -387,14 +407,16 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* portMapper {
|
* portMapper {
|
||||||
* map(80, 443)
|
* map(80, 443)
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -415,15 +437,17 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* requiresChannel {
|
* requiresChannel {
|
||||||
* secure("/public", requiresInsecure)
|
* secure("/public", requiresInsecure)
|
||||||
* secure(anyRequest, requiresSecure)
|
* secure(anyRequest, requiresSecure)
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -444,12 +468,14 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* x509 { }
|
* x509 { }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -471,12 +497,14 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* requestCache { }
|
* requestCache { }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -497,14 +525,16 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* exceptionHandling {
|
* exceptionHandling {
|
||||||
* accessDeniedPage = "/access-denied"
|
* accessDeniedPage = "/access-denied"
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -525,12 +555,14 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* csrf { }
|
* csrf { }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -550,14 +582,16 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* logout {
|
* logout {
|
||||||
* logoutUrl = "/log-out"
|
* logoutUrl = "/log-out"
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -580,14 +614,16 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* saml2Login {
|
* saml2Login {
|
||||||
* relyingPartyRegistration = getSaml2RelyingPartyRegistration()
|
* relyingPartyRegistration = getSaml2RelyingPartyRegistration()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -608,14 +644,16 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* anonymous {
|
* anonymous {
|
||||||
* authorities = listOf(SimpleGrantedAuthority("ROLE_ANON"))
|
* authorities = listOf(SimpleGrantedAuthority("ROLE_ANON"))
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -638,14 +676,16 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* oauth2Login {
|
* oauth2Login {
|
||||||
* clientRegistrationRepository = getClientRegistrationRepository()
|
* clientRegistrationRepository = getClientRegistrationRepository()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -666,12 +706,14 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* oauth2Client { }
|
* oauth2Client { }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -692,14 +734,16 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* oauth2ResourceServer {
|
* oauth2ResourceServer {
|
||||||
* jwt { }
|
* jwt { }
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -720,14 +764,16 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* rememberMe {
|
* rememberMe {
|
||||||
* tokenValiditySeconds = 604800
|
* tokenValiditySeconds = 604800
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -747,12 +793,14 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* addFilterAt(CustomFilter(), UsernamePasswordAuthenticationFilter::class.java)
|
* addFilterAt(CustomFilter(), UsernamePasswordAuthenticationFilter::class.java)
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -774,12 +822,14 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* addFilterAt<UsernamePasswordAuthenticationFilter>(CustomFilter())
|
* addFilterAt<UsernamePasswordAuthenticationFilter>(CustomFilter())
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -800,12 +850,14 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* addFilterAfter(CustomFilter(), UsernamePasswordAuthenticationFilter::class.java)
|
* addFilterAfter(CustomFilter(), UsernamePasswordAuthenticationFilter::class.java)
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -827,12 +879,14 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* addFilterAfter<UsernamePasswordAuthenticationFilter>(CustomFilter())
|
* addFilterAfter<UsernamePasswordAuthenticationFilter>(CustomFilter())
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -853,12 +907,14 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* addFilterBefore(CustomFilter(), UsernamePasswordAuthenticationFilter::class.java)
|
* addFilterBefore(CustomFilter(), UsernamePasswordAuthenticationFilter::class.java)
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -880,12 +936,14 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* addFilterBefore<UsernamePasswordAuthenticationFilter>(CustomFilter())
|
* addFilterBefore<UsernamePasswordAuthenticationFilter>(CustomFilter())
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -914,14 +972,16 @@ class HttpSecurityDsl(private val http: HttpSecurity, private val init: HttpSecu
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
* http {
|
* http {
|
||||||
* securityContext {
|
* securityContext {
|
||||||
* securityContextRepository = SECURITY_CONTEXT_REPOSITORY
|
* securityContextRepository = SECURITY_CONTEXT_REPOSITORY
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -65,16 +65,18 @@ class OAuth2ClientDsl {
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
* httpSecurity(http) {
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
|
* http {
|
||||||
* oauth2Client {
|
* oauth2Client {
|
||||||
* authorizationCodeGrant {
|
* authorizationCodeGrant {
|
||||||
* authorizationRequestResolver = getAuthorizationRequestResolver()
|
* authorizationRequestResolver = getAuthorizationRequestResolver()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -97,16 +97,18 @@ class OAuth2LoginDsl {
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
* httpSecurity(http) {
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
|
* http {
|
||||||
* oauth2Login {
|
* oauth2Login {
|
||||||
* authorizationEndpoint {
|
* authorizationEndpoint {
|
||||||
* baseUri = "/auth"
|
* baseUri = "/auth"
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -126,16 +128,18 @@ class OAuth2LoginDsl {
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
* httpSecurity(http) {
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
|
* http {
|
||||||
* oauth2Login {
|
* oauth2Login {
|
||||||
* tokenEndpoint {
|
* tokenEndpoint {
|
||||||
* accessTokenResponseClient = getAccessTokenResponseClient()
|
* accessTokenResponseClient = getAccessTokenResponseClient()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -155,16 +159,18 @@ class OAuth2LoginDsl {
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
* httpSecurity(http) {
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
|
* http {
|
||||||
* oauth2Login {
|
* oauth2Login {
|
||||||
* redirectionEndpoint {
|
* redirectionEndpoint {
|
||||||
* baseUri = "/home"
|
* baseUri = "/home"
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -184,16 +190,18 @@ class OAuth2LoginDsl {
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
* httpSecurity(http) {
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
|
* http {
|
||||||
* oauth2Login {
|
* oauth2Login {
|
||||||
* userInfoEndpoint {
|
* userInfoEndpoint {
|
||||||
* userService = getUserService()
|
* userService = getUserService()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -56,16 +56,18 @@ class OAuth2ResourceServerDsl {
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
* httpSecurity(http) {
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
|
* http {
|
||||||
* oauth2ResourceServer {
|
* oauth2ResourceServer {
|
||||||
* jwt {
|
* jwt {
|
||||||
* jwkSetUri = "https://example.com/oauth2/jwk"
|
* jwkSetUri = "https://example.com/oauth2/jwk"
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -84,14 +86,16 @@ class OAuth2ResourceServerDsl {
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
* httpSecurity(http) {
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
|
* http {
|
||||||
* oauth2ResourceServer {
|
* oauth2ResourceServer {
|
||||||
* opaqueToken { }
|
* opaqueToken { }
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -51,14 +51,16 @@ class SessionManagementDsl {
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
* httpSecurity(http) {
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
|
* http {
|
||||||
* sessionManagement {
|
* sessionManagement {
|
||||||
* sessionFixation { }
|
* sessionFixation { }
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -78,10 +80,11 @@ class SessionManagementDsl {
|
|||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @EnableWebSecurity
|
* @EnableWebSecurity
|
||||||
* class SecurityConfig : WebSecurityConfigurerAdapter() {
|
* class SecurityConfig {
|
||||||
*
|
*
|
||||||
* override fun configure(http: HttpSecurity) {
|
* @Bean
|
||||||
* httpSecurity(http) {
|
* fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
|
||||||
|
* http {
|
||||||
* sessionManagement {
|
* sessionManagement {
|
||||||
* sessionConcurrency {
|
* sessionConcurrency {
|
||||||
* maximumSessions = 1
|
* maximumSessions = 1
|
||||||
@ -89,6 +92,7 @@ class SessionManagementDsl {
|
|||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
* return http.build()
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user