Return 401 for auth failures and log verify
All checks were successful
build-and-deploy / build-deploy (push) Successful in 27s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 27s
This commit is contained in:
@@ -7,6 +7,8 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity
|
||||
import org.springframework.security.config.http.SessionCreationPolicy
|
||||
import org.springframework.security.web.SecurityFilterChain
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
|
||||
import org.springframework.security.web.authentication.HttpStatusEntryPoint
|
||||
import org.springframework.http.HttpStatus
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableMethodSecurity
|
||||
@@ -22,6 +24,12 @@ class SecurityConfig(
|
||||
it.requestMatchers("/", "/health", "/auth/**").permitAll()
|
||||
it.anyRequest().authenticated()
|
||||
}
|
||||
.exceptionHandling {
|
||||
it.authenticationEntryPoint(HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED))
|
||||
it.accessDeniedHandler { _, response, _ ->
|
||||
response.sendError(HttpStatus.UNAUTHORIZED.value(), "Unauthorized")
|
||||
}
|
||||
}
|
||||
.httpBasic { it.disable() }
|
||||
.formLogin { it.disable() }
|
||||
.addFilterBefore(firebaseAuthFilter, UsernamePasswordAuthenticationFilter::class.java)
|
||||
|
||||
Reference in New Issue
Block a user