Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
phjppo0918 committed Jan 7, 2024
2 parents 05e5990 + ffe8787 commit 1d6df13
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.springframework.security.config.annotation.web.configuration.EnableWe
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
import org.springframework.security.crypto.password.PasswordEncoder
import org.springframework.security.web.SecurityFilterChain
import org.springframework.security.web.authentication.AuthenticationFailureHandler
import org.springframework.security.web.authentication.AuthenticationSuccessHandler
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler
import org.springframework.web.cors.CorsConfiguration
Expand All @@ -33,6 +34,7 @@ class SecurityConfig(
it.usernameParameter("email")
it.passwordParameter("password")
it.successHandler(authenticationSuccessHandler())
it.failureHandler(authenticationFailureHandler())
}
.logout {
it.logoutUrl("/logout")
Expand Down Expand Up @@ -63,6 +65,12 @@ class SecurityConfig(
res.status = HttpServletResponse.SC_OK
}

@Bean
fun authenticationFailureHandler() =
AuthenticationFailureHandler { _, res, _ ->
res.status = HttpServletResponse.SC_UNAUTHORIZED
}

@Bean
fun logoutSuccessHandler() =
LogoutSuccessHandler { _, res, _ ->
Expand Down

0 comments on commit 1d6df13

Please sign in to comment.