Go API Documentation

github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy/forwardauth

No package summary is available.

Package

Files: 1. Third party imports: 0. Imports from organisation: 0. Tests: 0. Benchmarks: 0.

Private functions

func init

init ()
References: httpcaddyfile.RegisterDirective.

func parseCaddyfile

parseCaddyfile parses the forward_auth directive, which has the same syntax as the reverse_proxy directive (in fact, the reverse_proxy's directive Unmarshaler is invoked by this function) but the resulting proxy is specially configured for most™️ auth gateways that support forward auth. The typical config which looks something like this:

forward_auth auth-gateway:9091 {
    uri /authenticate?redirect=https://auth.example.com
    copy_headers Remote-User Remote-Email
}

is equivalent to a reverse_proxy directive like this:

reverse_proxy auth-gateway:9091 {
    method GET
    rewrite /authenticate?redirect=https://auth.example.com

    header_up X-Forwarded-Method {method}
    header_up X-Forwarded-Uri {uri}

    @good status 2xx
    handle_response @good {
        request_header {
            Remote-User {http.reverse_proxy.header.Remote-User}
            Remote-Email {http.reverse_proxy.header.Remote-Email}
        }
    }
}

parseCaddyfile (h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error)
References: caddyconfig.JSONModuleObject, caddyhttp.MatchNot, caddyhttp.ResponseHandler, caddyhttp.ResponseMatcher, caddyhttp.Route, caddyhttp.VarsMatcher, caddyhttp.VarsMiddleware, headers.Handler, headers.HeaderOps, http.CanonicalHeaderKey, http.Header, httpcaddyfile.ConfigValue, json.RawMessage, reverseproxy.Handler, rewrite.Rewrite, sort.Strings, strings.Contains, strings.Split.