summaryrefslogtreecommitdiff
path: root/internal/handlers/handler_authz_impl_authrequest.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/handlers/handler_authz_impl_authrequest.go')
-rw-r--r--internal/handlers/handler_authz_impl_authrequest.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/internal/handlers/handler_authz_impl_authrequest.go b/internal/handlers/handler_authz_impl_authrequest.go
index 19292201f..11b3e5371 100644
--- a/internal/handlers/handler_authz_impl_authrequest.go
+++ b/internal/handlers/handler_authz_impl_authrequest.go
@@ -36,7 +36,13 @@ func handleAuthzGetObjectAuthRequest(ctx *middlewares.AutheliaCtx) (object autho
return authorization.NewObjectRaw(targetURL, method), nil
}
-func handleAuthzUnauthorizedAuthRequest(ctx *middlewares.AutheliaCtx, authn *Authn, _ *url.URL) {
- ctx.Logger.Infof("Access to %s (method %s) is not authorized to user %s, responding with status code %d", authn.Object.URL.String(), authn.Method, authn.Username, fasthttp.StatusUnauthorized)
- ctx.ReplyUnauthorized()
+func handleAuthzUnauthorizedAuthRequest(ctx *middlewares.AutheliaCtx, authn *Authn, redirectionURL *url.URL) {
+ ctx.Logger.Infof(logFmtAuthzRedirect, authn.Object.URL.String(), authn.Method, authn.Username, fasthttp.StatusUnauthorized, redirectionURL)
+
+ switch authn.Object.Method {
+ case fasthttp.MethodHead:
+ ctx.SpecialRedirectNoBody(redirectionURL.String(), fasthttp.StatusUnauthorized)
+ default:
+ ctx.SpecialRedirect(redirectionURL.String(), fasthttp.StatusUnauthorized)
+ }
}