summaryrefslogtreecommitdiff
path: root/internal/handlers/handler_authz_impl_authrequest.go
diff options
context:
space:
mode:
authorJames Elliott <james-d-elliott@users.noreply.github.com>2023-04-08 14:48:55 +1000
committerGitHub <noreply@github.com>2023-04-08 14:48:55 +1000
commit2dcfc0b04c3fbe57ecc11322487089bc8970e79f (patch)
tree54538032cbe1cdd9220d1418251d1c848c987519 /internal/handlers/handler_authz_impl_authrequest.go
parentfa250ea7ddb902132f4df74c407be84015577fa3 (diff)
feat(handlers): authz authrequest authelia url (#5181)
This adjusts the AuthRequest Authz implementation behave similarly to the other implementations in as much as Authelia can return the relevant redirection to the proxy and the proxy just utilizes it if possible. In addition it swaps the HAProxy examples over to the ForwardAuth implementation as that's now supported. Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>
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)
+ }
}