Ich experimentiere ja gerne mit diversen Software-Paketen – was mich nervt ist jedesmal die lokale Autorisierung, also lokale User die ich anlege, deren Passwort sich mein Browser mal merkt und mal auch nicht. Daher die Idee es mal mit Keycloak für OIDC zu versuchen. Wie immer mit caddy als Docker Reverse proxy (https://github.com/lucaslorentz/caddy-docker-proxy)
version: '3.7'
services:
postgres:
image: postgres:16.2
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
networks:
- keycloak_network
keycloak:
image: quay.io/keycloak/keycloak:latest
command: start
environment:
KEYCLOAK_FRONTEND_URL: https://keycloak.meinedomain.xyz/auth
KC_HEALTH_ENABLED: true
KEYCLOAK_ADMIN: ${KEYCLOAK_ADMIN}
KEYCLOAK_ADMIN_PASSWORD: ${KEYCLOAK_ADMIN_PASSWORD}
KC_DB: postgres
KC_DB_URL: jdbc:postgresql://postgres/${POSTGRES_DB}
KC_DB_USERNAME: ${POSTGRES_USER}
KC_DB_PASSWORD: ${POSTGRES_PASSWORD}
KC_HOSTNAME: keycloak.meinedomain.xyz
KC_HOSTNAME_STRICT_HTTPS: true
KC_HOSTNAME_STRICT: true
KC_PROXY: edge
HTTP_ADDRESS_FORWARDING: true
labels:
caddy: keycloak.meinedomain.xyz
caddy.reverse_proxy: "{{upstreams 8080}}"
restart: always
depends_on:
- postgres
networks:
- caddy
- keycloak_network
volumes:
postgres_data:
driver: local
networks:
caddy:
external: true
keycloak_network:
driver: bridge
Funktioniert gut und ich konnte gleich bei Nextcloud (via User App Plugin) und Seafile OIDC konfigurieren. Der User wird dabei beim ersten anmelden auch angelegt wenn man das will. Für User habe ich das lokale Backend des Keycloak benutzt. Keycloak kann auch andere OIDC Provider anbinden, z.B. GitHub – auch das funktionierte auf Anhieb. Allerdings: aktuell lässt Keycloak noch keine Filter zu, sprich wenn ihr das erlaubt hat jeder GitHub User dann einen Account auf eurer Nextcloud oder eurem Seafile – also habe ich das erstmal wieder abgeschaltet.
Etwas später habe ich gemerkt, dass der Keycloak Container etwas mehr als 3GiB RAM beansprucht – und leider lässt sich das auch nicht einschränken – die Antwort dazu in den Foren lautet: „hey, es ist (a) Java und (b) eine Enterprise Software also lebe damit“. Ähm – Nope.
Also umgebaut auf Authelia:
version: '3.3'
services:
authelia:
image: authelia/authelia
container_name: authelia
volumes:
- ./config:/config
- ./secrets:/secrets
networks:
- caddy
labels:
caddy: authelia.meinedomain.xyz
caddy.reverse_proxy: "{{upstreams 9091}}"
restart: unless-stopped
healthcheck:
disable: true
environment:
- TZ=Europe/Berlin
networks:
caddy:
external: true
Dazu ist es wichtig eine sinnvolle configuration.yaml zu haben:
---
jwt_secret: your_secret
default_redirection_url: https://authelia.meinedomain.xyz
server:
host: 0.0.0.0
port: 9091
log:
level: error
totp:
issuer: authelia
period: 30
skew: 1
authentication_backend:
file:
path: /config/users_database.yml
password:
algorithm: argon2id
iterations: 1
salt_length: 16
parallelism: 8
memory: 128
access_control:
default_policy: deny
rules:
- domain:
- "authelia.meinedomain.xyz"
policy: bypass
- domain:
- "nextcloud.meinedomain.xyz"
- "seafile.meinedomain.xyz"
policy: one_factor
session:
name: authelia_session
regulation:
max_retries: 3
find_time: 120
ban_time: 300
storage:
local:
path: /config/db.sqlite3
encryption_key: your_key
notifier:
smtp:
username: root@yourdomain
password: password
host: smtp.meinedomain.xyz
port: 587
sender: root@yourdomain
identity_providers:
oidc:
hmac_secret: your_secret
issuer_private_key: |
-----BEGIN PRIVATE KEY-----
abc.....
-----END PRIVATE KEY-----
access_token_lifespan: 1h
authorize_code_lifespan: 1m
id_token_lifespan: 1h
refresh_token_lifespan: 90m
enable_client_debug_messages: false
enforce_pkce: public_clients_only
cors:
endpoints:
- authorization
- token
- revocation
- introspection
- userinfo
allowed_origins_from_client_redirect_uris: false
clients:
- client_id: 'nextcloud'
client_name: 'NextCloud'
client_secret: 'your_client_secret'
public: false
authorization_policy: 'one_factor'
require_pkce: true
pkce_challenge_method: 'S256'
redirect_uris:
- 'https://nextcloud.meinedomain.xyz/apps/user_oidc/code'
scopes:
- 'openid'
- 'profile'
- 'email'
userinfo_signed_response_alg: 'none'
token_endpoint_auth_method: 'client_secret_post'
pre_configured_consent_duration: '6 week'
- client_id: 'seafile'
client_name: 'Seafile'
client_secret: 'your_client_secret'
public: false
authorization_policy: 'one_factor'
redirect_uris:
- 'https://seafile.meinedomain.xyz/oauth/callback/'
scopes:
- 'openid'
- 'profile'
- 'email'
userinfo_signed_response_alg: 'none'
token_endpoint_auth_method: 'client_secret_basic'
pre_configured_consent_duration: '6 week'
- client_id: 'immich'
client_name: 'immich'
client_secret: 'your_client_secret'
public: false
authorization_policy: 'one_factor'
redirect_uris:
- 'https://photos.meinedomain.xyz/auth/login'
- 'https://photos.meinedomain.xyz/user-settings'
- 'app.immich:/'
scopes:
- 'openid'
- 'profile'
- 'email'
userinfo_signed_response_alg: 'none'
pre_configured_consent_duration: '6 week'
- client_id: owncloud
client_name: ownCloud web client
public: true
authorization_policy: 'one_factor'
redirect_uris:
- https://ocis.meinedomain.xyz/
- https://ocis.meinedomain.xyz/oidc-callback.html
- https://ocis.meinedomain.xyz/oidc-silent-redirect.html
Wie immer, your mileage may vary – aber für mich tuts 🙂
Schreibe einen Kommentar