Skip to content

Commit 9cbac3c

Browse files
committed
♻️ :: authenticationEntryPoint 수정
1 parent 8f7793f commit 9cbac3c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

git-infrastructure/src/main/kotlin/com/xquare/git/global/config/SecurityConfiguration.kt

+14-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ import org.springframework.context.annotation.Configuration
55
import org.springframework.http.HttpStatus
66
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity
77
import org.springframework.security.config.web.server.ServerHttpSecurity
8+
import org.springframework.security.core.AuthenticationException
89
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
1014

1115
@Configuration
1216
@EnableWebFluxSecurity
@@ -21,8 +25,16 @@ class SecurityConfiguration {
2125
.anyExchange().authenticated()
2226
.and()
2327
.httpBasic()
24-
.authenticationEntryPoint(HttpStatusServerEntryPoint(HttpStatus.UNAUTHORIZED))
28+
.authenticationEntryPoint(CustomAuthenticationEntryPoint())
2529
.and()
2630
.build()
2731
}
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+
}
2840
}

0 commit comments

Comments
 (0)