Skip to content

Commit 7ec3b55

Browse files
Steve Riesenbergeleftherias
Steve Riesenberg
authored andcommitted
Fix Reactive OAuth2 Kotlin DSL examples
Closes gh-10580
1 parent ed3b0fb commit 7ec3b55

File tree

4 files changed

+15
-45
lines changed

4 files changed

+15
-45
lines changed

docs/modules/ROOT/pages/reactive/oauth2/client/authorization-grants.adoc

+3-9
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,14 @@ class SecurityConfig {
162162
163163
@Bean
164164
fun securityFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
165-
http {
165+
return http {
166166
authorizeExchange {
167167
authorize(anyExchange, authenticated)
168168
}
169169
oauth2Login {
170170
authorizationRequestResolver = authorizationRequestResolver(customClientRegistrationRepository)
171171
}
172172
}
173-
174-
return http.build()
175173
}
176174
177175
private fun authorizationRequestResolver(
@@ -282,13 +280,11 @@ class OAuth2ClientSecurityConfig {
282280
283281
@Bean
284282
fun securityFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
285-
http {
283+
return http {
286284
oauth2Client {
287285
authorizationRequestRepository = authorizationRequestRepository()
288286
}
289287
}
290-
291-
return http.build()
292288
}
293289
}
294290
----
@@ -363,13 +359,11 @@ class OAuth2ClientSecurityConfig {
363359
364360
@Bean
365361
fun securityFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
366-
http {
362+
return http {
367363
oauth2Client {
368364
authenticationManager = authorizationCodeAuthenticationManager()
369365
}
370366
}
371-
372-
return http.build()
373367
}
374368
375369
private fun authorizationCodeAuthenticationManager(): ReactiveAuthenticationManager {

docs/modules/ROOT/pages/reactive/oauth2/client/index.adoc

+1-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class OAuth2ClientSecurityConfig {
5555
5656
@Bean
5757
fun securityFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
58-
http {
58+
return http {
5959
oauth2Client {
6060
clientRegistrationRepository = clientRegistrationRepository()
6161
authorizedClientRepository = authorizedClientRepository()
@@ -64,8 +64,6 @@ class OAuth2ClientSecurityConfig {
6464
authenticationManager = authenticationManager()
6565
}
6666
}
67-
68-
return http.build()
6967
}
7068
}
7169
----

docs/modules/ROOT/pages/reactive/oauth2/login/advanced.adoc

+8-24
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class OAuth2LoginSecurityConfig {
6060
6161
@Bean
6262
fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
63-
http {
63+
return http {
6464
oauth2Login {
6565
authenticationConverter = authenticationConverter()
6666
authenticationMatcher = authenticationMatcher()
@@ -75,8 +75,6 @@ class OAuth2LoginSecurityConfig {
7575
securityContextRepository = securityContextRepository()
7676
}
7777
}
78-
79-
return http.build()
8078
}
8179
}
8280
----
@@ -158,16 +156,14 @@ class OAuth2LoginSecurityConfig {
158156
159157
@Bean
160158
fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
161-
http {
159+
return http {
162160
exceptionHandling {
163161
authenticationEntryPoint = RedirectServerAuthenticationEntryPoint("/login/oauth2")
164162
}
165163
oauth2Login {
166164
authorizationRequestResolver = authorizationRequestResolver()
167165
}
168166
}
169-
170-
return http.build()
171167
}
172168
173169
private fun authorizationRequestResolver(): ServerOAuth2AuthorizationRequestResolver {
@@ -243,13 +239,11 @@ class OAuth2LoginSecurityConfig {
243239
244240
@Bean
245241
fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
246-
http {
242+
return http {
247243
oauth2Login {
248244
authenticationMatcher = PathPatternParserServerWebExchangeMatcher("/login/oauth2/callback/{registrationId}")
249245
}
250246
}
251-
252-
return http.build()
253247
}
254248
}
255249
----
@@ -369,11 +363,9 @@ class OAuth2LoginSecurityConfig {
369363
370364
@Bean
371365
fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
372-
http {
366+
return http {
373367
oauth2Login { }
374368
}
375-
376-
return http.build()
377369
}
378370
379371
@Bean
@@ -458,11 +450,9 @@ class OAuth2LoginSecurityConfig {
458450
459451
@Bean
460452
fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
461-
http {
453+
return http {
462454
oauth2Login { }
463455
}
464-
465-
return http.build()
466456
}
467457
468458
@Bean
@@ -536,11 +526,9 @@ class OAuth2LoginSecurityConfig {
536526
537527
@Bean
538528
fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
539-
http {
529+
return http {
540530
oauth2Login { }
541531
}
542-
543-
return http.build()
544532
}
545533
546534
@Bean
@@ -594,11 +582,9 @@ class OAuth2LoginSecurityConfig {
594582
595583
@Bean
596584
fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
597-
http {
585+
return http {
598586
oauth2Login { }
599587
}
600-
601-
return http.build()
602588
}
603589
604590
@Bean
@@ -730,7 +716,7 @@ class OAuth2LoginSecurityConfig {
730716
731717
@Bean
732718
fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
733-
http {
719+
return http {
734720
authorizeExchange {
735721
authorize(anyExchange, authenticated)
736722
}
@@ -739,8 +725,6 @@ class OAuth2LoginSecurityConfig {
739725
logoutSuccessHandler = oidcLogoutSuccessHandler()
740726
}
741727
}
742-
743-
return http.build()
744728
}
745729
746730
private fun oidcLogoutSuccessHandler(): ServerLogoutSuccessHandler {

docs/modules/ROOT/pages/reactive/oauth2/login/core.adoc

+3-9
Original file line numberDiff line numberDiff line change
@@ -341,14 +341,12 @@ class OAuth2LoginSecurityConfig {
341341
342342
@Bean
343343
fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
344-
http {
344+
return http {
345345
authorizeExchange {
346346
authorize(anyExchange, authenticated)
347347
}
348348
oauth2Login { }
349349
}
350-
351-
return http.build()
352350
}
353351
}
354352
----
@@ -411,14 +409,12 @@ class OAuth2LoginConfig {
411409
412410
@Bean
413411
fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
414-
http {
412+
return http {
415413
authorizeExchange {
416414
authorize(anyExchange, authenticated)
417415
}
418416
oauth2Login { }
419417
}
420-
421-
return http.build()
422418
}
423419
424420
@Bean
@@ -505,14 +501,12 @@ class OAuth2LoginConfig {
505501
506502
@Bean
507503
fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
508-
http {
504+
return http {
509505
authorizeExchange {
510506
authorize(anyExchange, authenticated)
511507
}
512508
oauth2Login { }
513509
}
514-
515-
return http.build()
516510
}
517511
518512
@Bean

0 commit comments

Comments
 (0)