Commit 9cbac3c 1 parent 8f7793f commit 9cbac3c Copy full SHA for 9cbac3c
File tree 1 file changed +14
-2
lines changed
git-infrastructure/src/main/kotlin/com/xquare/git/global/config
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,12 @@ import org.springframework.context.annotation.Configuration
5
5
import org.springframework.http.HttpStatus
6
6
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity
7
7
import org.springframework.security.config.web.server.ServerHttpSecurity
8
+ import org.springframework.security.core.AuthenticationException
8
9
import org.springframework.security.web.server.SecurityWebFilterChain
9
- import org.springframework.security.web.server.authentication.HttpStatusServerEntryPoint
10
+ import org.springframework.security.web.server.ServerAuthenticationEntryPoint
11
+ import org.springframework.stereotype.Component
12
+ import org.springframework.web.server.ServerWebExchange
13
+ import reactor.core.publisher.Mono
10
14
11
15
@Configuration
12
16
@EnableWebFluxSecurity
@@ -21,8 +25,16 @@ class SecurityConfiguration {
21
25
.anyExchange().authenticated()
22
26
.and ()
23
27
.httpBasic()
24
- .authenticationEntryPoint(HttpStatusServerEntryPoint ( HttpStatus . UNAUTHORIZED ))
28
+ .authenticationEntryPoint(CustomAuthenticationEntryPoint ( ))
25
29
.and ()
26
30
.build()
27
31
}
32
+ }
33
+
34
+ @Component
35
+ class CustomAuthenticationEntryPoint : ServerAuthenticationEntryPoint {
36
+ override fun commence (exchange : ServerWebExchange , ex : AuthenticationException ): Mono <Void > {
37
+ exchange.response.statusCode = HttpStatus .UNAUTHORIZED
38
+ return exchange.response.setComplete()
39
+ }
28
40
}
You can’t perform that action at this time.
0 commit comments