From dfb88a375e1b78cda99110b30a85c595aa0980c7 Mon Sep 17 00:00:00 2001 From: Thore Cimbal Date: Wed, 19 Aug 2026 12:00:00 +0000 Subject: [PATCH] feat(wiki): enrol every Authentik login into wiki-anwender Decision sorb, and it was already made in #0049: normal Authentik users read the user documentation, admins are admins. The role model was implemented; the way in was not. selfRegistration created an account on first login and autoEnrollGroups was empty, so the account landed in no group at all - and since Guests is stripped of every permission, the user saw nothing and was told nothing about why. That is #0103, and it happened to a real person. Admins stay manual: membership in "authentik Admins" arrives through the groups claim and is not affected by this baseline. betrieb/* keeps its default deny, so the separation #0049 verified end to end still holds - it only stops applying to people who were never let in at all. The lookup aborts if wiki-anwender is missing rather than silently enrolling into nothing, which would reproduce the exact failure this fixes. Co-Authored-By: Claude Opus 5 --- apps/production/wikijs-config.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/apps/production/wikijs-config.py b/apps/production/wikijs-config.py index 30becc6..e3c570a 100644 --- a/apps/production/wikijs-config.py +++ b/apps/production/wikijs-config.py @@ -155,7 +155,7 @@ def login(): return d["jwt"] if d["responseResult"]["succeeded"] else None -def _set_strategies(jwt: str, oidc_config: list): +def _set_strategies(jwt: str, oidc_config: list, auto_enroll: list | None = None): strategies = [ { # local bleibt aktiviert: der Konfig-Job loggt sich damit ein und es ist der # Break-Glass-Zugang (/login?all). Auf der Login-Seite wird es per hideLocal @@ -167,7 +167,16 @@ def _set_strategies(jwt: str, oidc_config: list): { "key": STRATEGY_KEY, "strategyKey": "oidc", "displayName": "Authentik", "order": 1, "isEnabled": True, "selfRegistration": True, - "domainWhitelist": [], "autoEnrollGroups": [], "config": oidc_config, + # autoEnrollGroups: jeder Authentik-Login landet in wiki-anwender + # (#0049: "Betrieb = Admin", Anwender lesen /anwender + Startseite). + # Ohne das legt selfRegistration zwar ein Konto an, es bekommt aber + # KEINE Gruppe - und weil Guests unten alle Rechte entzogen bekommt, + # sieht der Nutzer dann gar nichts und erfaehrt auch nicht warum + # (#0103, real passiert). Admins bleiben Handarbeit in Authentik: + # Mitgliedschaft in "authentik Admins" wird ueber den groups-Claim + # gemappt und ueberschreibt diese Grundausstattung nicht. + "domainWhitelist": [], "autoEnrollGroups": auto_enroll or [], + "config": oidc_config, }, ] r = gql( @@ -193,8 +202,14 @@ def ensure_oidc(jwt: str): "groupsClaim": "groups", "mapGroups": True, } oidc_config = [{"key": k, "value": json.dumps({"v": v})} for k, v in cfg.items()] - _set_strategies(jwt, oidc_config) - log("OIDC-Strategy gesetzt (local bleibt aktiv als Break-Glass)") + # Die Gruppe existiert hier sicher: main() legt sie vor ensure_oidc an. + anwender = group_id(jwt, "wiki-anwender") + if anwender is None: + sys.exit("ABBRUCH: Gruppe 'wiki-anwender' nicht gefunden — ohne sie liefe " + "jeder neue Login wieder ins Leere (#0103).") + _set_strategies(jwt, oidc_config, [anwender]) + log(f"OIDC-Strategy gesetzt (local bleibt aktiv als Break-Glass; " + f"Auto-Enrollment in wiki-anwender, id {anwender})") def set_hide_local(jwt: str):