Onboard mediamark to Authentik OIDC #29
Reference in New Issue
Block a user
Delete Branch "benvin/mediamark-oidc"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
mediamark is a new Go web UI that lets authorized users mark media as kids content. It runs behind an oauth2-proxy in its own
mediamarknamespace (the watchstate model, not insidearrstack), so it needs its own Authentik application, a client secret, and a permission group to gate who can log in. Adult media users are the ones who curate the kids catalogue, so the entitlement hangs off the existing adult media role.config/providers_oauth2/mediamark.yaml: confidential clientmediamark, launch URLhttps://mediamark.unkin.net/, openid/email/profile scope mappings, and strict redirect URIs for bothhttps://mediamark.unkin.net/oauth2/callbackandhttps://mediamark.k8s.syd1.au.unkin.net/oauth2/callback(oauth2-proxy uses a relative redirect, so whichever host the user arrives on must be registered).kubernetes/namespace/mediamark/default/oauth-credentials. The runner's Vault policy grants read onkv/data/kubernetes/namespace/+/default/oauth-credentials— the+wildcards only the namespace, the trailingoauth-credentialsis literal — so this is the one shape the runner can read. This secret is already seeded, so no pre-merge action is needed.config/permissions/akP-mediamark-user.yamlbound to themediamarkapplication, so the module creates a policy binding gating the app to that group and its children. The-usersuffix follows the peer tier convention (akP-watchstate-admin,akP-arrstack-user); the filename is the Authentik group name, sinceconfig/config.hclkeyspermission_groupsby basename and the module setsname = each.key.akP-mediamark-userinconfig/roles/akR-media-adult.yaml, giving adult media users access via the hierarchicalak_groupsclaim.The
ak_groupsscope needs no per-provider entry:modules/authentik/main.tfappends the hierarchicalgroups_hierarchicalproperty mapping to every oauth2 provider, andscope_mappingsonly accepts Authentik-managed identifiers.data.vault_kv_secret_v2.oauth2is a data source, so the client secret is read at plan time — the path has to exist before CI plans, not merely before apply. It is seeded, and CI on this head is green.Review fixes pushed as
1485962(additive commit onbenvin/mediamark-oidc). This supersedes the stale namespace/path claims in the PR body.1. BLOCKING — Vault path corrected (namespace decision)
The runner's Vault policy only grants read on
kv/data/kubernetes/namespace/+/default/oauth-credentials— the trailing filename is literal, not a wildcard. The originalkubernetes/namespace/arrstack/default/mediamark-oauth-credentialsfell outside it and would have 403'd, reddening the plan.Decision: mediamark deploys in its own
mediamarknamespace (same model as watchstate), not insidearrstack. So the path is now:which the existing policy covers with no terraform-vault change needed. Hostnames are unaffected and unchanged —
launch_urlstayshttps://mediamark.unkin.net/and the redirect URIs staymediamark.unkin.net+mediamark.k8s.syd1.au.unkin.net; only the comment's namespace wording was updated.2. MINOR — permission group renamed
config/permissions/akP-mediamark.yaml->config/permissions/akP-mediamark-user.yaml, matching the peer tier-suffix convention (akP-watchstate-admin,akP-arrstack-user).Confirmed this is load-bearing, not cosmetic:
config/config.hclkeyspermission_groupsbytrimsuffix(basename(file_path), ".yaml"), andmodules/authentik/main.tfsetsauthentik_group.permissionname = each.key. The filename is the Authentik group name and theak_groupsclaim value. The reference inconfig/roles/akR-media-adult.yamlwas updated toakP-mediamark-useraccordingly (a stale reference there would have failed theauthentik_group.permission[p]lookup).application: mediamarkinside the file is unchanged.3. Mechanics correction — plan-time read, and the secret is now seeded
data "vault_kv_secret_v2" "oauth2"is a data source, so the secret is read at plan time, not apply time. The path must already exist in Vault before CI plans, otherwise the plan itself fails — "seeded out of band before apply" was not sufficient.Seeded — no action needed. A fresh 32-byte random value was written to
kv/kubernetes/namespace/mediamark/default/oauth-credentials(fieldclient_secret, version 1), so the plan on this head can read it. The value was never printed. When mediamark's oauth2-proxy is deployed, it should read its client secret from this same Vault path.Validation
uvx pre-commit run --all-filespasses clean on the new head (end-of-file-fixer, trailing-whitespace, tofu fmt, tofu validate, tflint, terragrunt hcl fmt, yamllint).