Docker container for use as Identity Provider and authentication portal in front of a Traefik reverse-proxy.
- 1. Docker Setup
- 2. Authentik Setup
- 3. Autentik configuration
- 4. Applications setup
- Initialize config by running init.sh:
./init.sh - Input personal information into
.env - Generate postgresql password and authentik secret key, by using e.g.
openssl rand 56 | base64, and input into.env - Make sure that Docker network
traefikexists,docker network ls - Run
docker compose upand check logs
Updated for version 2025.6.3
- Open browser and go to
auth.YOURDOMAIN.COMand verify that you reach the Authentik login screen - Add
/if/flow/initial-setup/at the end of the URL to reach the dialogue for setting up the initial admin account - Input the email and password you want to use for the default
akadminaccount and pressContinue - Log into the default admin account using either usename
akadminor the email you entered in the previous step - Click the
Admin interfacebutton on the top-right - Go to
Directory->Usersin the menu on the left side and clickCreate - Input
UsernameandName, selectUser type: Internal, inputEmail, finally click Create - Click on your recently created user and go to the
Groupstab and clickAdd to existing group - Click on the plus sign, select
authentik Adminsand pressAdd, then pressAddagain - Go back to the
Overviewtab and clickSet passwordunder theRecoverysection - Log out of the current session and log in with your new user account instead
- Go back to
Directory->Usersand click on theakadminuser - In the
User Infopane scroll down to theActionssection and press theDeactivatebutton, then pressUpdatein the popup prompt
You have now logged in for the first time, created your own user account and disabled the default admin account.
- In the
Admin interface, go toApplications->Outposts, locate theauthentik Embedded Outpostand verify that is saysLoggin in via https://auth.YOURDOMAIN.COMin green below the name - Go to
Applications->Providersand clickCreate - Select
Proxy Providerand clickNext - Input a
Name, e.g.Traefik Providerand selectAuthorization flowwith either implicit or explicit consent (determines if you are presented with an explicit prompt when being forwarded after logging in or not, prefer implicit) - Click
Forward auth (domain level), check thatAuthentication URLishttps://auth.YOURDOMAIN.COMand setCookie domainsimply asYOURDOMAIN.COM - Change
Token validityto your taste and clickFinish - Go to
Applications->Applicationsand clickCreate - Input
NameandSlug, e.g.Traefik//traefik - Click the
Providerfield and selectTraefik Provider(or whatever you named it in the previous step) and finally clickCreate - Go back to
Applications->Providersand verify thatTraefik Providerhas a green checkmark and the textAssigned to application Traefikunder theApplicationcolumn - Go back to
Applications->Outpostsand click theEditbutton for theauthentik Embedded Outpost(under theActionscolumn) - In the
Applicationssection click onTraefikand press the > button to add it toSelected Applications, then pressUpdate
You have now set up Authentik to be ready to be used with Traefik reverse-proxy with domain level forward auth.
- Go to your Traefik dir and open
dynamic_config.yml - Add an Authentik middleware:
middlewares: authentik-auth: forwardAuth: # Match base url to authentik server container name address: http://authentik-server:9000/outpost.goauthentik.io/auth/traefik trustForwardHeader: true authResponseHeaders: - X-authentik-username - X-authentik-groups - X-authentik-email - X-authentik-name - X-authentik-uid - X-authentik-jwt - X-authentik-meta-jwks - X-authentik-meta-outpost - X-authentik-meta-provider - X-authentik-meta-app - X-authentik-meta-version - Optionally create a middleware chain that includes default security headers:
middlewares: authentik: chain: middlewares: - authentik-auth - default-security-headers
Now you can use Authentik together with Traefik by including the authentik middleware in container labels, e.g.: traefik.http.routers.APP_NAME.middlewares=authentik@file.
To verify that the email settings in .env are correct run docker compose exec worker ak test_email RECIPIENT_EMAIL to send a test email to RECIPIENT_EMAIL.
Certain password managers will have an easier time auto-typing your login info if the username and password fields are both presented at once.
- Go to
Flows and Stages->Stagesand clickEditfor thedefault-authentication-identificationstage - Under
Password stageselectdefault-authentication-password - (Optional) Enable
Enable "Remember me on this device" - Click
Update - Go to
Flows and Stages->Flowsand click thedefault-authentication-flowstage - Go to the
Stage Bindingstab and delete thedefault-authentication-passwordstage
It's a good idea to enforce some kind of password policy.
- Go to
Customisation->Policiesand clickCreate - Select
Password Policyand clickNext - Set a suitable
Name, e.g.password-complexity - Expand the
Static rulessection - Input your choice of rules and enter an
Error messagethat reflects the requirements, e.g.Please enter a minimum of 12 characters with at least 1 uppercase, 1 lowercase, 1 digit and 1 symbol character. - Click
Finish - Go to
Flows and Stages->Stages, clickEditfor thedefault-source-enrollment-promptstage - Scroll down to
Validation Policies, select the password policy created previously underAvailable Policiesand click>to add it to `Selected Policies. - Make sure to remove any other default policies and click
Update - Repeat above for the
default-password-change-promptstage while also removing thedefault-password-change-password-policyif present
It's a good idea to enforce MFA for something that provides such powerful means of access. Here's how to force setup of MFA using TOTP using e.g. Google Authenticator app.
- Go to
Flows and Stages->Stages, clickEditfordefault-authentication-mfa-validation - Under
Stage-specific settings->Device classesselect the MFA types you want to allow, in this case onlyTOTP Authenticatorsfor Google Authenticator app - Set
Not configured actiontoForce the user to configure an authenticator - Under
Configuration stagesselect onlydefault-authenticator-totp-setup, clickUpdate - Go to
Flows and Stages->Flowsand click ondefault-source-enrollment - Go to the
Stage Bindingstab, clickBind existing stageand input:- Stage:
default-authentication-mfa-validation - Order: 2
- Stage:
- Update the order of the
default-source-enrollment-loginstage to 3, the resulting list should be:Order Name 0 default-source-enrollment-prompt 1 default-source-enrollment-write 2 default-authentication-mfa-validation 3 default-source-enrollment-login
If users forget their password it's nice if they're able to reset their passwords on their own.
- Go to
Flows and Stages->Stagesand clickCreate - Select
Identification Stageand clickNext - Set a suitable name, e.g.
recovery-authentication-identification, underUser fieldsselectUsernameandEmailand clickFinish - Click
Createagain and selectEmail Stage, clickNext - Set a suitable
Name, e.g.recovery-email - Set
Subjectto e.g.Authentik password recovery, clickFinish - Go to
Flows and Stages->Flowsand clickCreate - Set
Name/Title/SlugasRecovery/Recovery/recovery - Set
DesignationasRecovery - Click
Create - Click on the
recoveryflow we just created and go to theStage Bindingstab - Add bindings by clicking
Bind existing stageand setting up according to the table below:Order Stage Type 10 recovery-authentication-identification Identification Stage 20 recovery-email Email Stage 30 default-password-change-prompt Prompt Stage 40 default-password-change-write User Write Stage - Go to
Flows and Stages->Stagesand clickEditfor thedefault-authentication-identificationstage - Under
Flow settings->Recovery flowselectrecovery (Recovery)and clickUpdate
It's a bad idea to allow anyone visiting the login page to register for an account. Invitation link with a set expiration time is a better solution.
-
Go to
Directory->Groupsand clickCreate -
Set a suitable name, e.g.
authentik Users -
Make sure
Is superuseris switched OFF, clickCreate -
Click on your recently created group, go to the
Userstab and click onAdd existing user -
Click on the plus sign, select your currently existing normal user accounts, press
Addand then pressAddagain -
Go to
Flows and Stages->Stagesand clickCreate -
Select
User Write Stageand clickNext -
Set a suitable name, e.g.
enrollment-invitation-write -
Under
Stage-specific settingsmake sureCreate users when requiredis selected and uncheckCreate users as inactive -
Under
User typemake sureInternalis selected -
Under
Groupselect the recently createdauthentik Usersgroup -
Click
Finish -
Click
Createagain and selectInvitation Stage, clickNext -
Set a suitable name, e.g.
enrollment-invitation -
Make sure
Continue flow without invitationis OFF and clickFinish -
Click
Createagain and selectEmail Stage -
Set
Nametoenrollment-invitation-email,SubjecttoAccount ConfirmationandTemplatetoAccount Confirmation, finally clickFinish -
Go to
Flows and Stages->Flowsand clickCreate -
Set
NameandTitletoEnrollment Invitation -
Set
DesignationtoEnrollment -
Under
Behavior settingscheckCompatibility modeand clickCreate -
Click the recently created
enrollment-invitationflow and go to theStage Bindingstab -
Add bindings by clicking
Bind existing stageand setting up according to the table below:Order Stage Type 10 enrollment-invitation Invitation Stage 20 default-source-enrollment-prompt Prompt Stage 30 enrollment-invitation-write User Write Stage 40 enrollment-invitation-email Email Stage 50 default-source-enrollment-login User Login Stage -
Click on
Edit Stagefor thedefault-source-enrollment-promptstage -
Under
Stage-specific settings->Fieldsselect the following entries:- default-user-settings-field-username
- default-user-settings-field-name
- default-user-settings-field-email
- initial-setup-field-password
- initial-setup-field-password-repeat
-
Check under
Validation Policiesthatpassword-complexityis selected, clickUpdate
You can now go to Directory->Invitations and click Create to create an invitation link. Set a suitable name and expiration time. Make sure to select the enrollment-invitation flow and make sure Single use is checked.
- Expand the recently created invite and
Link to use the invitationwill contain the link to be distributed.
If you want to allow API calls to a certain application to bypass authentication simply add ^\/api\/.* to Advanced protocol settings->Unauthenticated Paths under the relevant Provider.
Authentik can be set up to contain the user//pass for the HTTP logins for the various Servarr apps and to forward credentials to the respective app after authentication via Authentik. This way you can keep authentication activated for each app but still only have to log in once when going through Authentik.
- Go to your Traefik dir and open your
dynamic_config.yml - Create a middleware similar to the one in the general Traefik setup above but including the
authorizationheader (this is required for Authentik to be able to forward the credentials):middlewares: authentik-auth-http: forwardAuth: # Match base url to authentik server container name address: http://authentik-server:9000/outpost.goauthentik.io/auth/traefik trustForwardHeader: true authResponseHeaders: - X-authentik-username - X-authentik-groups - X-authentik-email - X-authentik-name - X-authentik-uid - X-authentik-jwt - X-authentik-meta-jwks - X-authentik-meta-outpost - X-authentik-meta-provider - X-authentik-meta-app - X-authentik-meta-version - authorization - Optionally create a middleware chain similar to above:
middlewares: authentik-http: chain: middlewares: - authentik-auth-http - default-security-headers
For the services where you want to use the HTTP-Basic authentication forwarding via Authentik you need to replace the default authentik middleware chain with the authentik-http created above instead.
- Open the Authentik Admin Interface
- Go to
Directory->Groupsand clickCreate - Set a suitable name, e.g.
Servarr Users - Under
Attributesinput a list of usernames//passwords for the different Servarr apps, e.g.:- prowlarr_user: PROWLARR_USERNAME
- prowlarr_password: PROWLARR_PASSWORD
- sonarr_user: SONARR_USERNAME
- sonarr_password: SONARR_PASSWORD
- etc...
- Click
Create - Click on the recently created group, go to the
Userstab and clickAdd existing user - Click the plus sign, select the users you want to be able to access the Servarr apps, click
Addand thenAddagain - Go to
Applications->Providersand clickCreate - Select
Proxy Providerand clickNext - Set a suitable name, e.g.
Prowlarr Providerand selectimplicit-concentunderAuthorization flow - Click
Forward auth (single application) - Set
External hostto the externally accessible address for the app, e.g.https://prowlarr.DOMAIN.COM - Expand
Authntication settingsand make sure that bothIntercept header authenticationandSend HTTP-Basic Authenticationare ON - Set
HTTP-Basic Username KeyandHTTP-Basic Password Keytoprowlarr_userandprowlarr_passwordrespectively (matching the keys in the list set up above) - Click
Finish - Repeat Provider creation for each individual app in your stack
- Go to
Applications->Applicationsand clickCreate - Set a suitable name, e.g.
Prowlarrand the slug similarly toprowlarr - Under
Providerselect theProwlarr Providercreated previously and clickCreate - Repeat Application creation for each individual app in your stack
- Go to
Applications->Outpostsand openauthentik Embedded Outpostfor editing - Under
Applicationsselect each application created previously and click > to add them to `Selected Applications - Click
Update - The previously created providers should now be listed in the
Providerstab forauthentik Embedded Outpost
Authentik has a community integration for Nextcloud to allow user login and provisioning via Authentik.
Make sure usernames are immutable by going to System->Settings in the Admin Interface and checking that Allow users to change username is OFF.
- Open the Authentik Admin Interface
- Go to
Directory->Groupsand clickCreate - Create a group called
nextcloud Admins, this will control which users are given admin permissions inNextcloud - Create a group called
nextcloud Users, this will control which users are allowed to accessNextcloud(to prevent Nextcloud accounts from being provisioned for users who aren't supposed to have access) - Go to
Customization->Property Mappingsand clickCreate - Select
Scope Mappingand clickNext - Set
NametoNextcloud ProfileandScope nametoprofile - In
Expressionenter the following:# Extract all groups the user is a member of groups = [group.name for group in user.ak_groups.all()] # Nextcloud admins must be members of a group called "admin". # This is static and cannot be changed. # We append a fictional "admin" group to the user's groups if they are a member of "nextcloud Admins" in authentik. # This group would only be visible in Nextcloud and does not exist in authentik. if "nextcloud Admins" in groups: groups = ["admin"] else: groups = [] return { # Display name "name": request.user.name, "groups": groups, # To set a quota set the "nextcloud_quota" property in the user's attributes "quota": user.group_attributes().get("nextcloud_quota", None), # To connect an already existing user, set the "nextcloud_user_id" property in the # user's attributes to the username of the corresponding user on Nextcloud. # Uses the Authentik username if attribute is not set. "user_id": user.attributes.get("nextcloud_user_id", str(user.username)), } - Click
Finish - Go to
Applications->Providersand clickCreate - Select
OAuth2/OpenID Providerand clickNext - Enter the following:
- Name:
Nextcloud Provider - Authorization flow:
implicit-consent - Client type:
Confidential - Redirect URIs/Origins (RegEx):
https://nc.DOMAIN.COM/apps/user_oidc/code(make sure you're using the correct path prefix)
- Name:
- Under
Advanced protocol settings->Scopesselect:authentik default OAuth Mapping: OpenID 'email'authentik default OAuth Mapping: OpenID 'openid'authentik default OAuth Mapping: OpenID 'profile'Nextcloud Profile
- Make sure that
Advanced protocol settings->Subject mode: Based on the User's usernameis selected - Make sure that
Include claims in id_tokenat the bottom is ON - Take note of your
Client IDandClient Secret, you will use this in the Nextcloud stage - Go to
Applications->Applicationsand clickCreate - Enter the following:
- Name:
Nextcloud - Slug:
nextcloud - Provider:
Nextcloud Provider
- Name:
- Click
Create - Click on the recently created application and go to the
Policy / Group/ User Bindingstab - Click
Bind existing Policy / Group / User, select theGroupoption and then select thenextcloud Usersgroup
To map an Authentik user to an existing Nextcloud account give the user an attribute like nextcloud_user_id: NEXTCLOUD_ACCOUNT_NAME. To give a user a quota limit give it an atrtibute like nextcloud_quota: 10 GB.
- Log into the web UI using an admin account, click on the profile icon in the top-right and then click on
Apps - Select the
Integrationcategory to the left and look forOpenID Connect user backend, enable it - Go to the top-right menu again and this time click
Administration Settings - In the left-side menu list click on
OpenID Connect - Click the plus sign under
Registered Providersand enter the following:- Identifier:
Authentik - Client ID: See the Authentik section
- Client secret: See the Authentik section
- Discovery endpoint:
https://auth.DOMAIN.COM/application/o/nextcloud/.well-known/openid-configuration - Scope:
openid email profile - User ID mapping:
user_id - Quota mapping:
quota - Groups mapping:
groups(RequiresUse group provisioningto be checked further down) - Display name mapping:
name(UnderExtra attributes mapping) - Email mapping:
email(UnderExtra attributes mapping) - Use unique user id: Turn this OFF
- Identifier:
To make Authentik the default login method for Nextcloud go to your Nextcloud docker directory and run docker compose exec -u www-data nextcloud php occ config:app:set --value=0 user_oidc allow_multiple_user_backends.
Authentik has a community integration for Synology DSM to allow user login via Authentik.
- Open the Authentik Admin Interface
- Go to
Applications->Providersand clickCreate - Select
OAuth2/OpenID Providerand clickNext - Enter the following:
- Name: Synology Provider
- Authorization flow: implicit-consent
- Client type:
Confidential - Redirect URIs/Origins (RegEx):
https://nas.DOMAIN.COM/#/signin(use whatever subdomain you set up in your Traefik dynamic_config.yml) - Subject mode:
Based on the User's username
- Click
Finish - Go to
Applications->Applicationsand clickCreate - Enter
Name//SlugasNAS//nasand select the recently created provider, clickCreate
- Log in to DSM with an admin account
- Go to
Control Panel->Domain/LDAPand click on theSSO Clienttab - Check the
Enable OpenID Connect SSO servicebox and click theOpenID Connect SSO Settingsbutton below it - Enter the following:
- Name:
Authentik - Wellknown URL:
https://auth.DOMAIN.COM/application/o/nas/.well-known/openid-configuration - Application ID: Client ID from the Synology Provider
- Application Key: Client Secret from the Synology Provider
- Redirect URL:
https://nas.DOMAIN.COM/#/signin - Authorization scope:
openid profile email - Username claim:
preferred_username
- Name:
Currently doesn't work properly with DSM <7.2 so TBC...
Authentik has a community integration for Immich to allow user login and provisioning via Authentik.
- Open the Authentik Admin Interface
- Go to
Applications->Providersand clickCreate - Select
OAuth2/OpenID Providerand clickNext - Enter the following:
- Name:
Immich Provider - Authorization flow:
implicit-consent - Client type:
Confidential - Redirect URIs/Origins (RegEx):
https://immich.DOMAIN.COM/auth/loginhttps://immich.DOMAIN.COM/user-settingsapp.immich://oauth-callback
- Name:
- Take note of the
Client IDandClient Secret, we will need these in the Immich setup - Click
Finish - Go to
Applications->Applicationsand clickCreate - Enter the following:
- Name:
Immich - Slug:
immich - Provider:
Immich Provider
- Name:
- Click
Create
- Log in with the admin account initially set up for Immich
- Click the top-right circle icon and select
Administration - From the left-side menu select
Settingsand thenAuthentication Settings->OAuth - Enable
Login with OAuthand fill out:- ISSUER_URL:
https://auth.DOMAIN.COM/application/o/immich/ - CLIENT_ID: Use value from Authentik Provider setup
- CLIENT_SECRET: Use value from Authentik Provider setup
- AUTO LAUNCH: Set to ON
- ISSUER_URL:
- Click
Saveat the bottom of the form
Authentik doesn't have an outright integration for Inventree but Inventree supports general OIDC.
- Go to
Applications->Providersand clickCreate - Select
OAuth2/OpenID Providerand clickNext - Enter the following:
- Name:
Inventree Provider - Authorization flow::
implicit-consent - Client type:
Confidential - Redirect URIs/Origins (RegEx): ("authentik" refers to the provider id set in Inventree)
https://parts.DOMAIN.COM/accounts/authentik/login/callback/https://inventree.DOMAIN.COM/accounts/authentik/login/callback/
- Name:
- Take note of the
Client IDandClient Secret, we will need these in the Inventree setup - Click
Finish - Go to
Applications->Applicationsand clickCreate - Enter the following:
- Name:
Inventree - Slug:
inventree - Provider:
Inventree Provider
- Name:
- Click
Create
- Log in as superuser/admin and go to
Admin Center - Under
Operations->Users / Access, expand theGroupssection and add groups calledAdminsandUsers - Go to
System Settings - Make sure that the following options are ON:
- Enable SSO
- Enable SSO registration
- Auto-fill SSO users
- Enable SSO group sync
- Remove groups outside of SSO
- Make sure that the following option is OFF:
- Enable registration
- Set
SSO group mapto{"inventree Users": "Users", "inventree Admins": "Admins"} - Set
Group on signuptoUsers - Go to the Django admin panel by entering
https://inventree.DOMAIN.COM/admin/, scroll down toSOCIAL ACCOUNTSand click onSocial applications - Click
ADD SOCIAL APPLICATION +and enter:- Provider:
OpenID Connect - Provider ID:
authentik - Name:
Authentik - Client id: As per the Authentik Provider
- Secret key: As per the Authentik Provider
- Settings:
{"server_url": "https://auth.DOMAIN.COM/application/o/inventree/"}
- Provider:
- Click
SAVE