2023-04-27 14:48:27 -04:00
|
|
|
## Version 2023/04/27 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx/authentik-location.conf.sample
|
2023-02-01 17:17:59 -05:00
|
|
|
# Make sure that your authentik container is in the same user defined bridge network and is named authentik-server
|
2023-03-28 20:33:32 -04:00
|
|
|
# Rename /config/nginx/proxy-confs/authentik.subdomain.conf.sample to /config/nginx/proxy-confs/authentik.subdomain.conf
|
2023-02-01 17:09:59 -05:00
|
|
|
|
2023-04-27 15:34:14 -04:00
|
|
|
## Send a subrequest to Authentik to verify if the user is authenticated and has permission to access the resource
|
2023-02-05 13:05:18 -05:00
|
|
|
auth_request /outpost.goauthentik.io/auth/nginx;
|
2023-04-27 15:34:14 -04:00
|
|
|
## If the subreqest returns 200 pass to the backend, if the subrequest returns 401 redirect to the portal
|
2023-02-05 17:50:45 -05:00
|
|
|
error_page 401 = @goauthentik_proxy_signin;
|
2023-02-01 17:09:59 -05:00
|
|
|
|
2023-04-27 14:48:27 -04:00
|
|
|
## Translate the user information response headers from the auth subrequest into variables
|
2023-02-02 10:32:51 -05:00
|
|
|
auth_request_set $authentik_email $upstream_http_x_authentik_email;
|
2023-04-13 12:26:13 -04:00
|
|
|
auth_request_set $authentik_groups $upstream_http_x_authentik_groups;
|
2023-02-02 10:32:51 -05:00
|
|
|
auth_request_set $authentik_name $upstream_http_x_authentik_name;
|
|
|
|
auth_request_set $authentik_uid $upstream_http_x_authentik_uid;
|
2023-04-13 12:26:13 -04:00
|
|
|
auth_request_set $authentik_username $upstream_http_x_authentik_username;
|
2023-02-01 17:09:59 -05:00
|
|
|
|
2023-04-27 14:48:27 -04:00
|
|
|
## Inject the user information into the request made to the actual upstream
|
2023-02-02 10:32:51 -05:00
|
|
|
proxy_set_header X-authentik-email $authentik_email;
|
2023-04-13 12:26:13 -04:00
|
|
|
proxy_set_header X-authentik-groups $authentik_groups;
|
2023-02-02 10:32:51 -05:00
|
|
|
proxy_set_header X-authentik-name $authentik_name;
|
|
|
|
proxy_set_header X-authentik-uid $authentik_uid;
|
2023-04-13 12:26:13 -04:00
|
|
|
proxy_set_header X-authentik-username $authentik_username;
|
2023-02-05 13:05:18 -05:00
|
|
|
|
2023-04-27 15:34:14 -04:00
|
|
|
## Translate the Set-Cookie response header from the auth subrequest into a variable
|
2023-02-05 17:50:45 -05:00
|
|
|
auth_request_set $set_cookie $upstream_http_set_cookie;
|