mirror of
https://github.com/mother-of-all-self-hosting/mash-playbook
synced 2024-11-10 06:14:17 +00:00
Add authentik
This commit is contained in:
parent
05aa3d9d0f
commit
96540561ec
5 changed files with 292 additions and 0 deletions
228
docs/services/authentik.md
Normal file
228
docs/services/authentik.md
Normal file
|
@ -0,0 +1,228 @@
|
|||
# Authentik
|
||||
|
||||
[authentik](https://goauthentik.io/) is an open-source Identity Provider focused on flexibility and versatility. MASH can install authentik with the [`mother-of-all-self-hosting/ansible-role-authentik`](https://github.com/mother-of-all-self-hosting/ansible-role-authentik) ansible role.
|
||||
|
||||
## Dependencies
|
||||
|
||||
This service requires the following other services:
|
||||
|
||||
- a [Postgres](postgres.md) database
|
||||
- a [Redis](redis.md) data-store, installation details [below](#redis)
|
||||
- a [Traefik](traefik.md) reverse-proxy server
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
To enable this service, add the following configuration to your `vars.yml` file and re-run the [installation](../installing.md) process:
|
||||
|
||||
```yaml
|
||||
########################################################################
|
||||
# #
|
||||
# authentik #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
authentik_enabled: true
|
||||
authentik_hostname: authentik.example.com
|
||||
authentik_secret_key: 'verysecret'
|
||||
|
||||
########################################################################
|
||||
# #
|
||||
# /authentik #
|
||||
# #
|
||||
########################################################################
|
||||
```
|
||||
|
||||
### Redis
|
||||
|
||||
As described on the [Redis](redis.md) documentation page, if you're hosting additional services which require Redis on the same server, you'd better go for installing a separate Redis instance for each service. See [Creating a Redis instance dedicated to authentik](#creating-a-redis-instance-dedicated-to-authentik).
|
||||
|
||||
If you're only running authentik on this server and don't need to use Redis for anything else, you can [use a single Redis instance](#using-the-shared-redis-instance-for-authentik).
|
||||
|
||||
#### Using the shared Redis instance for authentik
|
||||
|
||||
To install a single (non-dedicated) Redis instance (`mash-redis`) and hook authentik to it, add the following **additional** configuration:
|
||||
|
||||
```yaml
|
||||
########################################################################
|
||||
# #
|
||||
# redis #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
redis_enabled: true
|
||||
|
||||
########################################################################
|
||||
# #
|
||||
# /redis #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
|
||||
########################################################################
|
||||
# #
|
||||
# authentik #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
# Base configuration as shown above
|
||||
|
||||
# Point authentik to the shared Redis instance
|
||||
authentik_config_redis_hostname: "{{ redis_identifier }}"
|
||||
|
||||
# Make sure the authentik service (mash-authentik.service) starts after the shared Redis service (mash-redis.service)
|
||||
authentik_systemd_required_services_list_custom:
|
||||
- "{{ redis_identifier }}.service"
|
||||
|
||||
# Make sure the authentik container is connected to the container network of the shared Redis service (mash-redis)
|
||||
authentik_container_additional_networks_custom:
|
||||
- "{{ redis_identifier }}"
|
||||
|
||||
########################################################################
|
||||
# #
|
||||
# /authentik #
|
||||
# #
|
||||
########################################################################
|
||||
```
|
||||
|
||||
This will create a `mash-redis` Redis instance on this host.
|
||||
|
||||
This is only recommended if you won't be installing other services which require Redis. Alternatively, go for [Creating a Redis instance dedicated to authentik](#creating-a-redis-instance-dedicated-to-authentik).
|
||||
|
||||
|
||||
#### Creating a Redis instance dedicated to authentik
|
||||
|
||||
The following instructions are based on the [Running multiple instances of the same service on the same host](../running-multiple-instances.md) documentation.
|
||||
|
||||
Adjust your `inventory/hosts` file as described in [Re-do your inventory to add supplementary hosts](../running-multiple-instances.md#re-do-your-inventory-to-add-supplementary-hosts), adding a new supplementary host (e.g. if `authentik.example.com` is your main one, create `authentik.example.com-deps`).
|
||||
|
||||
Then, create a new `vars.yml` file for the
|
||||
|
||||
`inventory/host_vars/authentik.example.com-deps/vars.yml`:
|
||||
|
||||
```yaml
|
||||
---
|
||||
|
||||
########################################################################
|
||||
# #
|
||||
# Playbook #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
# Put a strong secret below, generated with `pwgen -s 64 1` or in another way
|
||||
# Various other secrets will be derived from this secret automatically.
|
||||
mash_playbook_generic_secret_key: ''
|
||||
|
||||
# Override service names and directory path prefixes
|
||||
mash_playbook_service_identifier_prefix: 'mash-authentik-'
|
||||
mash_playbook_service_base_directory_name_prefix: 'authentik-'
|
||||
|
||||
########################################################################
|
||||
# #
|
||||
# /Playbook #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
|
||||
########################################################################
|
||||
# #
|
||||
# redis #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
redis_enabled: true
|
||||
|
||||
########################################################################
|
||||
# #
|
||||
# /redis #
|
||||
# #
|
||||
########################################################################
|
||||
```
|
||||
|
||||
This will create a `mash-authentik-redis` instance on this host with its data in `/mash/authentik-redis`.
|
||||
|
||||
Then, adjust your main inventory host's variables file (`inventory/host_vars/authentik.example.com/vars.yml`) like this:
|
||||
|
||||
```yaml
|
||||
########################################################################
|
||||
# #
|
||||
# authentik #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
# Base configuration as shown above
|
||||
|
||||
|
||||
# Point authentik to its dedicated Redis instance
|
||||
authentik_environment_variable_redis_host: mash-authentik-redis
|
||||
authentik_environment_variable_redis_cache_host: mash-authentik-redis
|
||||
|
||||
# Make sure the authentik service (mash-authentik.service) starts after its dedicated Redis service (mash-authentik-redis.service)
|
||||
authentik_systemd_required_services_list_custom:
|
||||
- "mash-authentik-redis.service"
|
||||
|
||||
# Make sure the authentik container is connected to the container network of its dedicated Redis service (mash-authentik-redis)
|
||||
authentik_container_additional_networks_custom:
|
||||
- "mash-authentik-redis"
|
||||
|
||||
########################################################################
|
||||
# #
|
||||
# /authentik #
|
||||
# #
|
||||
########################################################################
|
||||
```
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
If you've decided to install a dedicated Redis instance for authentik, make sure to first do [installation](../installing.md) for the supplementary inventory host (e.g. `authentik.example.com-deps`), before running installation for the main one (e.g. `authentik.example.com`).
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
After installation, you can go to the authentik URL, as defined in `authentik_hostname`. Set the admin password there and start adding applications and users! Refer to the [official documentation]() to learn how to integrate services. Below are some tested examples
|
||||
|
||||
### Grafana
|
||||
|
||||
To enable SSO for Grafana you should
|
||||
|
||||
* Create a new OAUTH provider in authentik called `grafana`
|
||||
* Create an application also named `grafana` in authentik using this provider
|
||||
* Add the following configuration to your `vars.yml` file and re-run the [installation](../installing.md) process (make sure to adjust `authentik.example.com`)
|
||||
|
||||
```yaml
|
||||
grafana_environment_variables_additional_variables: |
|
||||
GF_AUTH_GENERIC_OAUTH_ENABLED=true
|
||||
GF_AUTH_GENERIC_OAUTH_NAME=authentik
|
||||
GF_AUTH_GENERIC_OAUTH_CLIENT_ID=COPIED-CLIENTID
|
||||
GF_AUTH_GENERIC_OAUTH_CLIENT_SECRET=COPIED-CLIENTSECRET
|
||||
GF_AUTH_GENERIC_OAUTH_SCOPES=openid profile email
|
||||
GF_AUTH_GENERIC_OAUTH_AUTH_URL=https://authentik.example.com/application/o/authorize/
|
||||
GF_AUTH_GENERIC_OAUTH_TOKEN_URL=https://authentik.example.com/application/o/token/
|
||||
GF_AUTH_GENERIC_OAUTH_API_URL=https://authentik.example.com/application/o/userinfo/
|
||||
GF_AUTH_SIGNOUT_REDIRECT_URL=https://authentik.example.com/application/o/grafana/end-session/
|
||||
# Optionally enable auto-login (bypasses Grafana login screen)
|
||||
#GF_AUTH_OAUTH_AUTO_LOGIN="true"
|
||||
GF_AUTH_GENERIC_OAUTH_ALLOW_ASSIGN_GRAFANA_ADMIN=true
|
||||
# Optionally map user groups to Grafana roles
|
||||
GF_AUTH_GENERIC_OAUTH_ROLE_ATTRIBUTE_PATH="contains(groups[*], 'Grafana Admins') && 'Admin' || contains(groups[*], 'Grafana Editors') && 'Editor' || 'Viewer'"
|
||||
|
||||
```
|
||||
|
||||
### Nextcloud
|
||||
|
||||
**The official documentation of authentik to connect nextcloud via SAML seems broken**
|
||||
|
||||
MASH can connect Nextcloud with authentik via OIDC. The setup is quite straightforward, refer to [this blogpost by Jack](https://blog.cubieserver.de/2022/complete-guide-to-nextcloud-oidc-authentication-with-authentik/) for a full explanation.
|
||||
|
||||
In short you shoudl
|
||||
|
||||
* Create a new provider in authentik and trimm the client secret to <64 characters
|
||||
* Create an application in authentik using this provider
|
||||
* Install the app `user_oidc` in Nextcloud
|
||||
* Fill in the details from authentik in the app settings
|
||||
|
||||
**Troubleshooting**
|
||||
|
||||
If you encounter problems during login check (error message containes `SHA1 mismatch`) that
|
||||
* Nextcloud users and authentik users do not have the same name -> if they do check `Use unique user ID` in the OIDC App settings
|
|
@ -4,6 +4,7 @@
|
|||
| ------------------------------ | ------------------------------------- | ------------- |
|
||||
| [AUX](https://github.com/mother-of-all-self-hosting/ansible-role-aux) | Auxiliary file/directory management on your server via Ansible | [Link](services/auxiliary.md) |
|
||||
| [AdGuard Home](https://adguard.com/en/adguard-home/overview.html/) | A network-wide DNS software for blocking ads & tracking | [Link](services/adguard-home.md) |
|
||||
| [authentik](https://goauthentik.io/) | An open-source Identity Provider focused on flexibility and versatility. | [Link](services/authentik.md) |
|
||||
| [Collabora Online](https://www.collaboraoffice.com/) | Your Private Office Suite In The Cloud | [Link](services/collabora-online.md) |
|
||||
| [Docker](https://www.docker.com/) | Open-source software for deploying containerized applications | [Link](services/docker.md) |
|
||||
| [Docker Registry](https://docs.docker.com/registry/) | A container image distribution registry | [Link](services/docker-registry.md) |
|
||||
|
|
|
@ -65,6 +65,10 @@ devture_systemd_service_manager_services_list_auto: |
|
|||
{{
|
||||
([{'name': (adguard_home_identifier + '.service'), 'priority': 2000, 'groups': ['mash', 'adguard-home']}] if adguard_home_enabled else [])
|
||||
+
|
||||
([{'name': (authentik_server_identifier + '.service'), 'priority': 2000, 'groups': ['mash', 'authentik']}] if authentik_enabled else [])
|
||||
+
|
||||
([{'name': (authentik_worker_identifier + '.service'), 'priority': 2000, 'groups': ['mash', 'authentik']}] if authentik_enabled else [])
|
||||
+
|
||||
([{'name': (collabora_online_identifier + '.service'), 'priority': 2000, 'groups': ['mash', 'collabora-online']}] if collabora_online_enabled else [])
|
||||
+
|
||||
([{'name': (devture_postgres_identifier + '.service'), 'priority': 500, 'groups': ['mash', 'postgres']}] if devture_postgres_enabled else [])
|
||||
|
@ -209,6 +213,11 @@ devture_postgres_systemd_services_to_stop_for_maintenance_list: |
|
|||
devture_postgres_managed_databases_auto: |
|
||||
{{
|
||||
([{
|
||||
'name': authentik_database_name,
|
||||
'username': authentik_database_username,
|
||||
'password': authentik_database_password,
|
||||
}] if authentik_enabled and authentik_database_hostname == devture_postgres_identifier else [])
|
||||
+([{
|
||||
'name': focalboard_database_name,
|
||||
'username': focalboard_database_username,
|
||||
'password': focalboard_database_password,
|
||||
|
@ -501,6 +510,55 @@ adguard_home_container_labels_traefik_tls_certResolver: "{{ devture_traefik_cert
|
|||
# #
|
||||
########################################################################
|
||||
|
||||
########################################################################
|
||||
# #
|
||||
# authentik #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
authentik_enabled: false
|
||||
|
||||
authentik_identifier: "{{ mash_playbook_service_identifier_prefix }}authentik"
|
||||
|
||||
authentik_base_path: "{{ mash_playbook_base_path }}/{{ mash_playbook_service_base_directory_name_prefix }}authentik"
|
||||
|
||||
authentik_uid: "{{ mash_playbook_uid }}"
|
||||
authentik_gid: "{{ mash_playbook_gid }}"
|
||||
|
||||
authentik_database_hostname: "{{ devture_postgres_identifier if devture_postgres_enabled else '' }}"
|
||||
authentik_database_port: "{{ '5432' if devture_postgres_enabled else '' }}"
|
||||
authentik_database_password: "{{ '%s' | format(mash_playbook_generic_secret_key) | password_hash('sha512', 'db.authentik', rounds=655555) | to_uuid }}"
|
||||
authentik_database_username: "{{ authentik_identifier }}"
|
||||
|
||||
authentik_server_systemd_required_services_list_auto: |
|
||||
{{
|
||||
([devture_postgres_identifier ~ '.service'] if devture_postgres_enabled and authentik_database_hostname == devture_postgres_identifier else [])
|
||||
}}
|
||||
|
||||
authentik_server_container_additional_networks_auto: |
|
||||
{{
|
||||
([mash_playbook_reverse_proxyable_services_additional_network] if mash_playbook_reverse_proxyable_services_additional_network else [])
|
||||
+
|
||||
([devture_postgres_container_network] if devture_postgres_enabled and authentik_database_hostname == devture_postgres_identifier and authentik_server_container_network != devture_postgres_container_network else [])
|
||||
}}
|
||||
|
||||
authentik_frontend_container_additional_networks_auto: |
|
||||
{{
|
||||
([devture_postgres_container_network] if devture_postgres_enabled and authentik_database_hostname == devture_postgres_identifier and authentik_frontend_container_network != devture_postgres_container_network else [])
|
||||
+
|
||||
([mash_playbook_reverse_proxyable_services_additional_network] if mash_playbook_reverse_proxyable_services_additional_network else [])
|
||||
}}
|
||||
|
||||
authentik_server_container_labels_traefik_enabled: "{{ mash_playbook_traefik_labels_enabled }}"
|
||||
authentik_server_container_labels_traefik_docker_network: "{{ mash_playbook_reverse_proxyable_services_additional_network }}"
|
||||
authentik_server_container_labels_traefik_entrypoints: "{{ devture_traefik_entrypoint_primary }}"
|
||||
authentik_server_container_labels_traefik_tls_certResolver: "{{ devture_traefik_certResolver_primary }}"
|
||||
|
||||
########################################################################
|
||||
# #
|
||||
# /funkwhale #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
|
||||
########################################################################
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
- src: git+https://github.com/mother-of-all-self-hosting/ansible-role-adguard-home.git
|
||||
version: v0.107.26-1
|
||||
name: adguard_home
|
||||
- src: git+https://github.com/mother-of-all-self-hosting/ansible-role-authentik.git
|
||||
version: v2023.4.0-1
|
||||
name: authentik
|
||||
- src: git+https://github.com/mother-of-all-self-hosting/ansible-role-aux.git
|
||||
version: v1.0.0-0
|
||||
name: aux
|
||||
|
|
|
@ -56,6 +56,8 @@
|
|||
|
||||
- role: galaxy/adguard_home
|
||||
|
||||
- role: galaxy/authentik
|
||||
|
||||
- role: galaxy/collabora_online
|
||||
|
||||
- role: galaxy/docker_registry
|
||||
|
|
Loading…
Reference in a new issue