From 7ec3b55ab33c2d639557dfdb28d6912177f3fe27 Mon Sep 17 00:00:00 2001 From: Steve Riesenberg Date: Fri, 3 Dec 2021 17:21:02 -0600 Subject: [PATCH] Fix Reactive OAuth2 Kotlin DSL examples Closes gh-10580 --- .../oauth2/client/authorization-grants.adoc | 12 ++----- .../pages/reactive/oauth2/client/index.adoc | 4 +-- .../pages/reactive/oauth2/login/advanced.adoc | 32 +++++-------------- .../pages/reactive/oauth2/login/core.adoc | 12 ++----- 4 files changed, 15 insertions(+), 45 deletions(-) diff --git a/docs/modules/ROOT/pages/reactive/oauth2/client/authorization-grants.adoc b/docs/modules/ROOT/pages/reactive/oauth2/client/authorization-grants.adoc index 11fe4d541b..ab33687111 100644 --- a/docs/modules/ROOT/pages/reactive/oauth2/client/authorization-grants.adoc +++ b/docs/modules/ROOT/pages/reactive/oauth2/client/authorization-grants.adoc @@ -162,7 +162,7 @@ class SecurityConfig { @Bean fun securityFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain { - http { + return http { authorizeExchange { authorize(anyExchange, authenticated) } @@ -170,8 +170,6 @@ class SecurityConfig { authorizationRequestResolver = authorizationRequestResolver(customClientRegistrationRepository) } } - - return http.build() } private fun authorizationRequestResolver( @@ -282,13 +280,11 @@ class OAuth2ClientSecurityConfig { @Bean fun securityFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain { - http { + return http { oauth2Client { authorizationRequestRepository = authorizationRequestRepository() } } - - return http.build() } } ---- @@ -363,13 +359,11 @@ class OAuth2ClientSecurityConfig { @Bean fun securityFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain { - http { + return http { oauth2Client { authenticationManager = authorizationCodeAuthenticationManager() } } - - return http.build() } private fun authorizationCodeAuthenticationManager(): ReactiveAuthenticationManager { diff --git a/docs/modules/ROOT/pages/reactive/oauth2/client/index.adoc b/docs/modules/ROOT/pages/reactive/oauth2/client/index.adoc index b04019a5a4..614a3e45fa 100644 --- a/docs/modules/ROOT/pages/reactive/oauth2/client/index.adoc +++ b/docs/modules/ROOT/pages/reactive/oauth2/client/index.adoc @@ -55,7 +55,7 @@ class OAuth2ClientSecurityConfig { @Bean fun securityFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain { - http { + return http { oauth2Client { clientRegistrationRepository = clientRegistrationRepository() authorizedClientRepository = authorizedClientRepository() @@ -64,8 +64,6 @@ class OAuth2ClientSecurityConfig { authenticationManager = authenticationManager() } } - - return http.build() } } ---- diff --git a/docs/modules/ROOT/pages/reactive/oauth2/login/advanced.adoc b/docs/modules/ROOT/pages/reactive/oauth2/login/advanced.adoc index a9b0a23e65..8dfb8c9e93 100644 --- a/docs/modules/ROOT/pages/reactive/oauth2/login/advanced.adoc +++ b/docs/modules/ROOT/pages/reactive/oauth2/login/advanced.adoc @@ -60,7 +60,7 @@ class OAuth2LoginSecurityConfig { @Bean fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain { - http { + return http { oauth2Login { authenticationConverter = authenticationConverter() authenticationMatcher = authenticationMatcher() @@ -75,8 +75,6 @@ class OAuth2LoginSecurityConfig { securityContextRepository = securityContextRepository() } } - - return http.build() } } ---- @@ -158,7 +156,7 @@ class OAuth2LoginSecurityConfig { @Bean fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain { - http { + return http { exceptionHandling { authenticationEntryPoint = RedirectServerAuthenticationEntryPoint("/login/oauth2") } @@ -166,8 +164,6 @@ class OAuth2LoginSecurityConfig { authorizationRequestResolver = authorizationRequestResolver() } } - - return http.build() } private fun authorizationRequestResolver(): ServerOAuth2AuthorizationRequestResolver { @@ -243,13 +239,11 @@ class OAuth2LoginSecurityConfig { @Bean fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain { - http { + return http { oauth2Login { authenticationMatcher = PathPatternParserServerWebExchangeMatcher("/login/oauth2/callback/{registrationId}") } } - - return http.build() } } ---- @@ -369,11 +363,9 @@ class OAuth2LoginSecurityConfig { @Bean fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain { - http { + return http { oauth2Login { } } - - return http.build() } @Bean @@ -458,11 +450,9 @@ class OAuth2LoginSecurityConfig { @Bean fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain { - http { + return http { oauth2Login { } } - - return http.build() } @Bean @@ -536,11 +526,9 @@ class OAuth2LoginSecurityConfig { @Bean fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain { - http { + return http { oauth2Login { } } - - return http.build() } @Bean @@ -594,11 +582,9 @@ class OAuth2LoginSecurityConfig { @Bean fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain { - http { + return http { oauth2Login { } } - - return http.build() } @Bean @@ -730,7 +716,7 @@ class OAuth2LoginSecurityConfig { @Bean fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain { - http { + return http { authorizeExchange { authorize(anyExchange, authenticated) } @@ -739,8 +725,6 @@ class OAuth2LoginSecurityConfig { logoutSuccessHandler = oidcLogoutSuccessHandler() } } - - return http.build() } private fun oidcLogoutSuccessHandler(): ServerLogoutSuccessHandler { diff --git a/docs/modules/ROOT/pages/reactive/oauth2/login/core.adoc b/docs/modules/ROOT/pages/reactive/oauth2/login/core.adoc index 9c6a47f752..037fcff5f1 100644 --- a/docs/modules/ROOT/pages/reactive/oauth2/login/core.adoc +++ b/docs/modules/ROOT/pages/reactive/oauth2/login/core.adoc @@ -341,14 +341,12 @@ class OAuth2LoginSecurityConfig { @Bean fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain { - http { + return http { authorizeExchange { authorize(anyExchange, authenticated) } oauth2Login { } } - - return http.build() } } ---- @@ -411,14 +409,12 @@ class OAuth2LoginConfig { @Bean fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain { - http { + return http { authorizeExchange { authorize(anyExchange, authenticated) } oauth2Login { } } - - return http.build() } @Bean @@ -505,14 +501,12 @@ class OAuth2LoginConfig { @Bean fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain { - http { + return http { authorizeExchange { authorize(anyExchange, authenticated) } oauth2Login { } } - - return http.build() } @Bean