|
8 | 8 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
9 | 9 | import org.springframework.security.config.web.server.SecurityWebFiltersOrder; |
10 | 10 | import org.springframework.security.config.web.server.ServerHttpSecurity; |
| 11 | +import org.springframework.security.core.AuthenticationException; |
11 | 12 | import org.springframework.security.web.server.SecurityWebFilterChain; |
12 | 13 | import org.springframework.security.web.server.ServerAuthenticationEntryPoint; |
| 14 | +import org.springframework.security.web.server.WebFilterExchange; |
13 | 15 | import org.springframework.security.web.server.authentication.AuthenticationWebFilter; |
14 | 16 | import org.springframework.security.web.server.authentication.ServerAuthenticationConverter; |
15 | 17 | import org.springframework.security.web.server.authentication.ServerAuthenticationFailureHandler; |
@@ -44,8 +46,8 @@ public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) |
44 | 46 | return http |
45 | 47 | .securityContextRepository(NoOpServerSecurityContextRepository.getInstance()) |
46 | 48 | .exceptionHandling() |
47 | | - .accessDeniedHandler(accessDeniedHandler()) |
48 | | - .authenticationEntryPoint(authenticationEntryPoint()) |
| 49 | + .accessDeniedHandler((exchange, exception) -> Mono.error(exception)) |
| 50 | + .authenticationEntryPoint((exchange, exception) -> Mono.error(exception)) |
49 | 51 | .and() |
50 | 52 | .cors() |
51 | 53 | .and() |
@@ -86,7 +88,7 @@ protected AuthenticationWebFilter tokenAuthenticationFilter() { |
86 | 88 |
|
87 | 89 | AuthenticationWebFilter filter = new AuthenticationWebFilter(tokenAuthenticationManager()); |
88 | 90 | filter.setServerAuthenticationConverter(tokenAuthenticationConverter()); |
89 | | - filter.setAuthenticationFailureHandler(authenticationFailureHandler()); |
| 91 | + filter.setAuthenticationFailureHandler((exchange, exception) -> Mono.error(exception)); |
90 | 92 |
|
91 | 93 | return filter; |
92 | 94 | } |
@@ -136,20 +138,4 @@ protected ServerAuthenticationConverter tokenAuthenticationConverter() { |
136 | 138 | return Mono.just(new UsernamePasswordAuthenticationToken(null, authorization.substring(LecUtils.TOKEN_PREFIX_LENGTH))); |
137 | 139 | }; |
138 | 140 | } |
139 | | - |
140 | | - protected ServerAuthenticationFailureHandler authenticationFailureHandler() { |
141 | | - |
142 | | - return (webFilterExchange, exception) -> Mono.error(exception); |
143 | | - } |
144 | | - |
145 | | - protected ServerAccessDeniedHandler accessDeniedHandler() { |
146 | | - |
147 | | - return (exchange, exception) -> Mono.error(exception); |
148 | | - } |
149 | | - |
150 | | - protected ServerAuthenticationEntryPoint authenticationEntryPoint() { |
151 | | - |
152 | | - return (exchange, exception) -> Mono.error(exception); |
153 | | - } |
154 | | - |
155 | 141 | } |
0 commit comments