Add access denied debug header for auth troubleshooting
All checks were successful
build-and-deploy / build-deploy (push) Successful in 27s

This commit is contained in:
androidlover5842
2026-01-27 02:14:38 +05:30
parent 3f05484498
commit be814eb0d5

View File

@@ -26,7 +26,11 @@ class SecurityConfig(
}
.exceptionHandling {
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")
}
}