Skip to content

Integrating with external authelia by forward_auth #6559

Description

@idavollen

https://caddyserver.com/docs/caddyfile/directives/forward_auth as well as the Expand Form


# Serve the authentication gateway itself
auth.example.com {
	reverse_proxy authelia:9091
}

# Serve your app
app1.example.com {
	forward_auth authelia:9091 {
		uri /api/verify?rd=https://auth.example.com
		copy_headers Remote-User Remote-Groups Remote-Name Remote-Email
	}

	reverse_proxy app1:8080
}

This directive makes a GET request to the configured upstream with the uri rewritten:

If the upstream responds with a 2xx status code, then access is granted and the header fields in copy_headers are copied to the original request, and handling continues.
Otherwise, if the upstream responds with any other status code, then the upstream's response is copied back to the client. This response should typically involve a redirect to login page of the authentication gateway.

The above mentioned documentation is a bit absurb or difficult to understand. If the upstream responds with a 2xx status code, what is the mentioned upstream here? if it is the auth.example.com, its index page showing the Sign-in Web GUI page has already returned 200 as following:

Request URL:
https://authelia.example.com/?rd=https%3A%2F%2Ftraefik.example.com%2Frest%2Fhallos&rm=GET
Request Method:
GET
Status Code:
200 OK
Remote Address:
127.0.0.1:443
Referrer Policy:
strict-origin-when-cross-origin

Or if the upstream is the app1:8080, what if the app1:8080 backend doesn't well follow the security principle, implicit-deny or even has bad access control implementation? I'm looking forward to a clearly technical elaberation!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions