Skip to content

Commit bbdbdbf

Browse files
committed
Fix Kotlin docs to use valid authorize signatures
The Real World Example used authorize(allowedPaths, permitAll) where allowedPaths is an Array<String>, but this overload does not exist in AuthorizeHttpRequestsDsl. Replace with individual authorize(pattern, access) calls per path. Also remove unused viewBalancePaths variable. Closes gh-17174 Signed-off-by: Preeti Toppo <toppopreeti191@gmail.com>
1 parent 1455798 commit bbdbdbf

File tree

1 file changed

+7
-4
lines changed
  • docs/modules/ROOT/pages/servlet/configuration

1 file changed

+7
-4
lines changed

docs/modules/ROOT/pages/servlet/configuration/kotlin.adoc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,10 @@ class BankingSecurityConfig {
301301
@Order(2) <3>
302302
open fun bankingSecurityFilterChain(http: HttpSecurity): SecurityFilterChain {
303303
val bankingPaths = arrayOf("/accounts/**", "/loans/**", "/credit-cards/**", "/balances/**")
304-
val viewBalancePaths = arrayOf("/balances/**")
305304
http {
306305
securityMatcher(*bankingPaths)
307306
authorizeHttpRequests {
308-
authorize(viewBalancePaths, hasRole("VIEW_BALANCE"))
307+
authorize("/balances/**", hasRole("VIEW_BALANCE"))
309308
authorize(anyRequest, hasRole("USER"))
310309
}
311310
}
@@ -314,10 +313,14 @@ class BankingSecurityConfig {
314313
315314
@Bean <4>
316315
open fun defaultSecurityFilterChain(http: HttpSecurity): SecurityFilterChain {
317-
val allowedPaths = arrayOf("/", "/user-login", "/user-logout", "/notices", "/contact", "/register")
318316
http {
319317
authorizeHttpRequests {
320-
authorize(allowedPaths, permitAll)
318+
authorize("/", permitAll)
319+
authorize("/user-login", permitAll)
320+
authorize("/user-logout", permitAll)
321+
authorize("/notices", permitAll)
322+
authorize("/contact", permitAll)
323+
authorize("/register", permitAll)
321324
authorize(anyRequest, authenticated)
322325
}
323326
formLogin {

0 commit comments

Comments
 (0)