Add access denied debug header for auth troubleshooting
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:
@@ -26,7 +26,11 @@ class SecurityConfig(
|
|||||||
}
|
}
|
||||||
.exceptionHandling {
|
.exceptionHandling {
|
||||||
it.authenticationEntryPoint(HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED))
|
it.authenticationEntryPoint(HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED))
|
||||||
it.accessDeniedHandler { _, response, _ ->
|
it.accessDeniedHandler { request, response, ex ->
|
||||||
|
if (request.getHeader("X-Debug-Auth") == "1") {
|
||||||
|
val msg = ex.message?.take(200) ?: "access_denied"
|
||||||
|
response.setHeader("X-Access-Debug", msg)
|
||||||
|
}
|
||||||
response.sendError(HttpStatus.UNAUTHORIZED.value(), "Unauthorized")
|
response.sendError(HttpStatus.UNAUTHORIZED.value(), "Unauthorized")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user