content:serverbasics:docker-authentik
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
| Nächste Überarbeitung | Vorherige Überarbeitung | ||
| content:serverbasics:docker-authentik [2025/03/28 21:04] – angelegt obel1x | content:serverbasics:docker-authentik [2025/06/05 23:25] (aktuell) – [Dockerfile] obel1x | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| ====== Docker: Authentik ====== | ====== Docker: Authentik ====== | ||
| - | Authentik is a middleware expanding the basic authentication- features of FreeIPA by many additional, modern ways of authentication which is used by modern Software. It will make SSO possible (Single-Sign-On: | + | Authentik is a middleware expanding the basic authentication- features of FreeIPA by many additional, modern ways of authentication which is used by modern Software. It will make SSO possible (Single-Sign-On: |
| - | TODO | + | ===== Dockerfile ===== |
| + | |||
| + | Usually, i link the env-File to some central File. This time, as there are Passwords included, i will setup an own file. File '' | ||
| + | < | ||
| + | #Common Docker-Parameters | ||
| + | COMPOSE_PROJECT_NAME=servername | ||
| + | COMPOSE_HTTP_TIMEOUT=180 | ||
| + | |||
| + | #Authentik: https:// | ||
| + | AUTHENTIK_TAG=latest | ||
| + | #use maybe: openssl rand -base64 60 | tr -d ' | ||
| + | AUTHENTIK_SECRET_KEY=SEEDOCS | ||
| + | AUTHENTIK_ERROR_REPORTING__ENABLED=true | ||
| + | # | ||
| + | # | ||
| + | AUTHENTIK_POSTGRESQL__HOST=servername-authentik_pgsql-1 | ||
| + | AUTHENTIK_POSTGRESQL__USER=authentik | ||
| + | AUTHENTIK_POSTGRESQL__NAME=authentik | ||
| + | AUTHENTIK_POSTGRESQL__PASSWORD=YOURPGPASS | ||
| + | # | ||
| + | #Redis - we are using nextcloud here | ||
| + | AUTHENTIK_REDIS__HOST=nextcloud-aio-redis | ||
| + | AUTHENTIK_REDIS__PASSWORD=SeeInNextcloudSettings_nextcloud_data_config/ | ||
| + | # | ||
| + | ## SMTP Host Emails are sent to | ||
| + | # | ||
| + | # | ||
| + | ## Optionally authenticate (don't add quotation marks to your password) | ||
| + | # | ||
| + | # | ||
| + | ## Use StartTLS | ||
| + | # | ||
| + | ## Use SSL | ||
| + | # | ||
| + | # | ||
| + | ## Email address authentik will send from, should have a correct @domain | ||
| + | # | ||
| + | |||
| + | </ | ||
| + | |||
| + | The File '' | ||
| + | < | ||
| + | |||
| + | # Source: https:// | ||
| + | # wget -O docker-compose.yml https:// | ||
| + | |||
| + | services: | ||
| + | authentik_pgsql: | ||
| + | image: docker.io/ | ||
| + | restart: always | ||
| + | healthcheck: | ||
| + | test: [" | ||
| + | start_period: | ||
| + | interval: 30s | ||
| + | retries: 5 | ||
| + | timeout: 5s | ||
| + | volumes: | ||
| + | - authentik_pgsql_data:/ | ||
| + | - authentik_backup:/ | ||
| + | #Defined in .env | ||
| + | # environment: | ||
| + | # POSTGRES_PASSWORD: | ||
| + | # POSTGRES_USER: | ||
| + | # POSTGRES_DB: | ||
| + | env_file: | ||
| + | - .env | ||
| + | |||
| + | # Using nextcloud-aio-redis | ||
| + | # redis: | ||
| + | # image: docker.io/ | ||
| + | # command: --save 60 1 --loglevel warning | ||
| + | # restart: unless-stopped | ||
| + | # healthcheck: | ||
| + | # test: [" | ||
| + | # start_period: | ||
| + | # interval: 30s | ||
| + | # retries: 5 | ||
| + | # timeout: 3s | ||
| + | # volumes: | ||
| + | # - redis:/ | ||
| + | |||
| + | # Authentik Server | ||
| + | authentik_server: | ||
| + | image: ${AUTHENTIK_IMAGE: | ||
| + | restart: always | ||
| + | command: server | ||
| + | # When Upgrading: Check for new Parameters and add to env, not here | ||
| + | # Possible Parameters: https:// | ||
| + | environment: | ||
| + | # AUTHENTIK_REDIS__HOST: | ||
| + | # AUTHENTIK_POSTGRESQL__HOST: | ||
| + | # AUTHENTIK_POSTGRESQL__USER: | ||
| + | # AUTHENTIK_POSTGRESQL__NAME: | ||
| + | # AUTHENTIK_POSTGRESQL__PASSWORD: | ||
| + | KRB5_TRACE: / | ||
| + | volumes: | ||
| + | - authentik_media:/ | ||
| + | - authentik_custom_templates:/ | ||
| + | env_file: | ||
| + | - .env | ||
| + | # Caddy virtualised | ||
| + | # ports: | ||
| + | # - " | ||
| + | # - " | ||
| + | | ||
| + | - nextcloud-aio | ||
| + | - default | ||
| + | |||
| + | # Authentik Worker | ||
| + | authentik_worker: | ||
| + | image: ${AUTHENTIK_IMAGE: | ||
| + | restart: always | ||
| + | command: worker | ||
| + | #Se above | ||
| + | # environment: | ||
| + | # AUTHENTIK_REDIS__HOST: | ||
| + | # AUTHENTIK_POSTGRESQL__HOST: | ||
| + | # AUTHENTIK_POSTGRESQL__USER: | ||
| + | # AUTHENTIK_POSTGRESQL__NAME: | ||
| + | # AUTHENTIK_POSTGRESQL__PASSWORD: | ||
| + | # `user: root` and the docker socket volume are optional. | ||
| + | # See more for the docker socket integration here: | ||
| + | # https:// | ||
| + | # Removing `user: root` also prevents the worker from fixing the permissions | ||
| + | # on the mounted folders, so when removing this make sure the folders have the correct UID/GID | ||
| + | # (1000:1000 by default) | ||
| + | user: root | ||
| + | volumes: | ||
| + | # No Docker integration / LDAP- Outpost not needed (will be freeipa) | ||
| + | # - / | ||
| + | - authentik_media:/ | ||
| + | - authentik_certs:/ | ||
| + | - authentik_custom_templates:/ | ||
| + | depends_on: | ||
| + | - authentik_server | ||
| + | env_file: | ||
| + | - .env | ||
| + | | ||
| + | - nextcloud-aio | ||
| + | - default | ||
| + | |||
| + | volumes: | ||
| + | authentik_pgsql_data: | ||
| + | authentik_backup: | ||
| + | authentik_media: | ||
| + | authentik_custom_templates: | ||
| + | authentik_certs: | ||
| + | # redis: | ||
| + | |||
| + | networks: | ||
| + | | ||
| + | | ||
| + | # Still needs to be defined while without it won't enable ipv6 | ||
| + | default: | ||
| + | driver: bridge | ||
| + | enable_ipv6: | ||
| + | |||
| + | </ | ||
| + | |||
| + | Carefully look at each line to fit your needs. | ||
| + | |||
| + | |||
| + | ===== Caddy ===== | ||
| + | |||
| + | in docker Caddy- Service enhance the lines: | ||
| + | < | ||
| + | |||
| + | # Authentik | ||
| + | https:// | ||
| + | | ||
| + | | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | ===== First start ===== | ||
| + | |||
| + | After doing '' | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | and set the Password for the admin user '' | ||
| + | ===== Backup PostgresSQL Database ===== | ||
| + | |||
| + | This is really VERY Important! The reason is, that every PostgresDB- Version has it own Database- File- Format and if you update Postgres from on Major Version to the next, you WILL NOT BE ABLE to start your DB with the old Volume- Data! | ||
| + | |||
| + | You NEED to have the DB-Backed up and restored to the next Version! | ||
| + | |||
| + | Create a File in your Docker- Dir named e.g. '' | ||
| + | < | ||
| + | |||
| + | # | ||
| + | # Make Postgres-Backup of Authentik | ||
| + | echo " | ||
| + | / | ||
| + | echo "Done Backup of Authentik-DB." | ||
| + | |||
| + | </ | ||
| + | |||
| + | Now add this script to '' | ||
| + | |||
| + | Don't forget to extend your '' | ||
| + | |||
| + | If you Update the Major- Version, make sure to create a new Volume for your pgsql- data. | ||
| + | |||
| + | ===== Configuring ===== | ||
| + | |||
| + | Now that Authentik is working, we are glueing all services together. | ||
| + | |||
| + | ==== Sync of FreeIPA/ | ||
| + | |||
| + | Don't use Kerberos-Sync, | ||
| + | |||
| + | To Sync FreeIPA with Authentik, follow this Guide: [[https:// | ||
| + | |||
| + | When the Sync has been configured, all FreeIPA- Users should show up in Authentik. | ||
| + | |||
| + | After SVC- user is created, use the following commands to modify password reset as written in the doc: | ||
| + | < | ||
| + | |||
| + | ldapmodify -x -D " | ||
| + | dn: cn=ipa_pwd_extop, | ||
| + | changetype: modify | ||
| + | add: passSyncManagersDNs | ||
| + | passSyncManagersDNs: | ||
| + | |||
| + | </ | ||
| + | |||
| + | At the next line, hit CTRL+D and the modification should be set, check with: | ||
| + | |||
| + | < | ||
| + | ldapsearch -xv -Z -W -H ldap:// | ||
| + | |||
| + | </ | ||
| + | |||
| + | which should show the entry for '' | ||
| + | === Secure LDAP- Users with TOTP === | ||
| + | |||
| + | Now any User can login with its FreeIPA- Password, also if SPNEGO/ kerberos as beneath is not setup yet. | ||
| + | |||
| + | This is quite insecure, so you shoul add a second factor for that type of Login (for SPNEGO the second factor is your integrated Machine, which has the key stored already). | ||
| + | |||
| + | To do so, in the Autentik Admin- Panel go to Stages and edit the Stage " | ||
| + | Change "Not configured action" | ||
| + | At " | ||
| + | |||
| + | The Next time you are logging in with User and Password in Authentik, it will ask to setup a TOTP- Device. You can for example use [[https:// | ||
| + | |||
| + | Hint: There is also an default Flow for this to import in Authentik here [[https:// | ||
| + | |||
| + | == Current Bug == | ||
| + | |||
| + | At the time of writing this, there was a bug here: https:// | ||
| + | |||
| + | So if you have to enter the OTP twice, than go to Flows, click on '' | ||
| + | |||
| + | |||
| + | ==== Attaching SPNEGO ==== | ||
| + | |||
| + | With SPNEGO, you gain access to SSO in Authentik. | ||
| + | |||
| + | Here is the link to the Docs: [[https:// | ||
| + | |||
| + | You need to logon to FreeIPA as Admin and do the following: | ||
| + | |||
| + | * Go to Hosts, add Host '' | ||
| + | * Go to Services, Add an new HTTP- Service for that Host, called HTTP/ | ||
| + | * Add the Ipa- User admin to the " | ||
| + | |||
| + | After that, you need to the Docker- Console into the running FreeIPA-Container and use the commands there: | ||
| + | < | ||
| + | |||
| + | #~> docker exec -it servername-ipa-1 bash | ||
| + | # Logon as Admin | ||
| + | kinit admin | ||
| + | # Create and read the Keytab for that service | ||
| + | ipa-getkeytab -s ipa.domain.tld -p HTTP/ | ||
| + | cat / | ||
| + | rm / | ||
| + | |||
| + | </ | ||
| + | |||
| + | This is the Keytab (a better " | ||
| + | |||
| + | Use the Servicename '' | ||
| + | |||
| + | Important: Use "User matching mode" = "Link to User with identical Username. …“ - otherwise Kerberos may fail! | ||
| + | |||
| + | Than activate Kerberos in Flows and Stages > Stages > default-authentication-identification > Source settings | ||
| + | |||
| + | Make sure, that your client is able to login with FreeIPA using SSSD/ | ||
content/serverbasics/docker-authentik.1743192247.txt.gz · Zuletzt geändert: von obel1x
