7.5 KiB
Authentik Overview
Authentik is an open-source Identity Provider (IdP) that allows users to self-host authentication and single sign-on (SSO)
GitHub Repository Official Documentation
Pre-Install
Dependencies
- None
Generate PG_PASS for .env
openssl rand -base64 36
Generate AUTHENTIK_SECRET_KEY for .env
openssl rand -base64 60
Create Volume Folders
- certs
- custom-templates
- database
- media
- redis
Create a .env file
AUTHENTIK_PORT_HTTP=9000
AUTHENTIK_PORT_HTTPS=9443
PG_PASS=
AUTHENTIK_SECRET_KEY=
AUTHENTIK_ERROR_REPORTING__ENABLED=true
AUTHENTIK_EMAIL__HOST=
AUTHENTIK_EMAIL__PORT=25
AUTHENTIK_EMAIL__USERNAME=
AUTHENTIK_EMAIL__PASSWORD=
AUTHENTIK_EMAIL__USE_TLS=true
AUTHENTIK_EMAIL__USE_SSL=false
AUTHENTIK_EMAIL__TIMEOUT=10
AUTHENTIK_EMAIL__FROM=
Post-Install
[ ⚠️ Warning ] Wait a few minutes before attempting to connect for the first time. All servers need to show as Healthy in Dockge
Go to http://your-server-ip:9000/if/flow/initial-setup/
- Create a unique email and password for admin account
- Don't use your primary email address for this account as it will conflict when you register yourself as a user
NGINX Proxy Manager
Details
- Domain Names: auth.ignitedinspirations.net
- Scheme: http
- Forward Hostname / IP: 172.18.1.10
- Forward Port: 9443
- Cache Assets: True
- Block Common Exploits: True
- Websockets Support: True
- Access Lists: Publicly Accessible
Custom Locations
- None
SSL
- SSL Certificate: Let's Encrypt
- Force SSL: True
- HTTP/2 Support: True
- HSTS Enabled: False
- HSTS Subdomains: False
Advanced
The following code needs to be entered into the Custom Nginx Configuration in order to have Authentik protect this app
# Increase buffer size for large headers
# This is needed only if you get 'upstream sent too big header while reading response
# header from upstream' error when trying to access an application protected by goauthentik
proxy_buffers 8 16k;
proxy_buffer_size 32k;
location / {
# Put your proxy_pass to your application here
proxy_pass $forward_scheme://$server:$port;
# authentik-specific config
auth_request /outpost.goauthentik.io/auth/nginx;
error_page 401 = @goauthentik_proxy_signin;
auth_request_set $auth_cookie $upstream_http_set_cookie;
add_header Set-Cookie $auth_cookie;
# translate headers from the outposts back to the actual upstream
auth_request_set $authentik_username $upstream_http_x_authentik_username;
auth_request_set $authentik_groups $upstream_http_x_authentik_groups;
auth_request_set $authentik_email $upstream_http_x_authentik_email;
auth_request_set $authentik_name $upstream_http_x_authentik_name;
auth_request_set $authentik_uid $upstream_http_x_authentik_uid;
proxy_set_header X-authentik-username $authentik_username;
proxy_set_header X-authentik-groups $authentik_groups;
proxy_set_header X-authentik-email $authentik_email;
proxy_set_header X-authentik-name $authentik_name;
proxy_set_header X-authentik-uid $authentik_uid;
}
# all requests to /outpost.goauthentik.io must be accessible without authentication
location /outpost.goauthentik.io {
proxy_pass https://<IP_ADDRESS>:9443/outpost.goauthentik.io;
# ensure the host of this vserver matches your external URL you've configured
# in authentik
proxy_set_header Host $host;
proxy_set_header X-Original-URL $scheme://$http_host$request_uri;
add_header Set-Cookie $auth_cookie;
auth_request_set $auth_cookie $upstream_http_set_cookie;
# required for POST requests to work
proxy_pass_request_body off;
proxy_set_header Content-Length "";
}
# Special location for when the /auth endpoint returns a 401,
# redirect to the /start URL which initiates SSO
location @goauthentik_proxy_signin {
internal;
add_header Set-Cookie $auth_cookie;
return 302 /outpost.goauthentik.io/start?rd=$request_uri;
# For domain level, use the below error_page to redirect to your authentik server with the full redirect path
# return 302 https://authentik-server:9443/outpost.goauthentik.io/start?rd=$scheme://$http_host$request_uri;
}
Note
If you are using Portainer to manage your Docker environment, you need to specify the ENV_FILE name to be
stacks.env
Edit the IP address in proxy_pass
above and make sure it matches the one you specify in the Authentik docker-compose file
Authentik
Create Google OAuth2 token
- Go to Official Documentation and follow steps there
- Make note of the Client ID and Client Secret
- Add
https://your-authentik-domain-name/source/oauth/callback/google
to list of Authorized redirect URI
Add Google SSO Support
- Click on Directory and then click on Federation & Social login
- Click on Create
- Click on Google OAuth Source and click Next
- Enter Google for the Name
- The Slug will automatically be filled
- Enter your Client ID and Client Secret generated when creating Google OAuth2 token
- Click Finish
Add Google as a Login Source
- Click on Flow and Stages then click on Stages
- Find the
default-authentication-identification
stage and click on the Edit button - Under Source settings click on
google
and then click on>
to add it
Add User to Directory
- Navigate to Directory then click on Users
- Enter your email address for the Username
- Enter your full name for Name
- Set User type to Internal
- Enter your email address for Email
- Click Create
Add User to Admin Group
- Navigate to Directory then click on Groups
- Click on
authentik Admins
- Click on Users tab
- Click on Add existing user
- Click on
+
then select your account and click Add - Click Add
Set New Users to Inactive by Default
- Click on Flow and Stages then click on Stages
- Find the
default-source-enrollment-write
stage and click the Edit button - Toggle the Create users as inactive to On
Create Application & Provider
- Click on Create with Wizard
- Enter the Application's Name
- This will automatically fill the Slug name
- Do not enter a Group Name
- Set Policy engine mode to
any
and click Next - Select Proxy Provider and click Next
- Name will automatically be filled in
- Select
default-provider-authorization-explicit-consent
for Authorization Flow - Click on Forward auth (single application)
- Enter the External host name and click Next
- This is generally the proxy hostname (ex. https://docker.mysite.com)
- Skip Policy/User/Group Bindings step and click Next
- Click Close
Add Application to Outpost
- Click on Application then click on Outposts
- Find the
authentik Embedded Outpost
and click the Edit button on the right - Click on the application under the Available Applications and then click on the
>
button - Click on Update
Additional Information
[ ⚠️ Warning ] If you are using Portainer to manage your Docker environment, you need to specify the ENV_FILE name to be
stacks.env