Files

167 lines
8.0 KiB
YAML

version: 1
metadata:
name: University of Ljubljana test stand-in - provider, application, claim mappings and test users
labels:
blueprints.goauthentik.io/description: |
Throwaway local Identity Provider setup for the Terminoloski portal's dev stack. Registers
ONE OIDC provider + application standing in for the single real University of Ljubljana/
Entra ID federation (the portal's `auth_provider` enum only ever has one external value:
'uni_lj'), whose claim set is deliberately restricted to the business-relevant fields the
University of Ljubljana actually sends: sub, email, name, preferred_username (ID token) and
given_name, family_name, picture (userinfo) - deliberately NOT Microsoft/Entra-proprietary
protocol claims (rh, aud, exp, iat, iss, nbf, oid, sid, tid, uti, ver), which app code never
reads and which authentik already has its own standard-OIDC equivalents for. authentik has
no way to split claims between the ID token and userinfo per-field, so (with
include_claims_in_id_token left at its default true) authentik's ID token ends up a harmless
superset of the real Entra one (it also carries given_name/family_name/picture) - see
dev/authentik/README.md. See dev/authentik/README.md for what each seeded test user is for.
entries:
# --- Claim (scope) mappings -------------------------------------------------------------
# authentik's own built-in "email"/"profile" scopes emit extra claims (email_verified,
# nickname, groups) that the real University of Ljubljana/Entra federation does NOT send in
# this combination. These two replace them for this provider only, so dev testing matches
# production claims exactly. (name and picture ARE now included deliberately, in real-Entra
# shape - see below - unlike authentik's own defaults, which format them differently.)
- model: authentik_providers_oauth2.scopemapping
id: uni-lj-scope-email
state: present
identifiers:
name: "Univerza v Ljubljani test mapping: email"
attrs:
name: "Univerza v Ljubljani test mapping: email"
scope_name: email
description: "Only 'email' - no email_verified (the University of Ljubljana/Entra doesn't send it either)."
expression: |
return {
"email": request.user.email,
}
- model: authentik_providers_oauth2.scopemapping
id: uni-lj-scope-profile
state: present
identifiers:
name: "Univerza v Ljubljani test mapping: profile"
attrs:
name: "Univerza v Ljubljani test mapping: profile"
scope_name: profile
description: >
given_name, family_name, name, preferred_username, picture - no nickname/groups. Mirrors
the real University of Ljubljana/Entra shape: given_name/family_name come from the user's
own attributes with NO fallback (delete_none_values() drops them entirely when unset, so a
test user can simulate the IdP omitting those claims); name is derived from those same two
attributes as "<family_name>, <given_name>" (also dropped, not just blank, when either is
missing - real Entra's ID token has no given_name/family_name at all, but DOES have name in
that exact format); preferred_username comes from a dedicated "preferred_username"
attribute (NOT request.user.username, which must stay the authentik login name) in the real
IdP's UPN-style "<lastname><first-letter-of-firstname>@<domain>" format; picture is the
fixed, non-user-specific Graph API URL every real account was observed to return.
expression: |
given_name = ak_obj_attr(request.user, "given_name")
family_name = ak_obj_attr(request.user, "family_name")
name = f"{family_name}, {given_name}" if given_name and family_name else None
return delete_none_values({
"given_name": given_name,
"family_name": family_name,
"name": name,
"preferred_username": ak_obj_attr(request.user, "preferred_username"),
"picture": "https://graph.microsoft.com/v1.0/me/photo/$value",
})
# --- Provider + Application --------------------------------------------------------------
- model: authentik_providers_oauth2.oauth2provider
id: uni-lj-provider
state: present
identifiers:
name: "Univerza v Ljubljani (test stand-in)"
attrs:
name: "Univerza v Ljubljani (test stand-in)"
authorization_flow: !Find [authentik_flows.flow, [slug, default-provider-authorization-implicit-consent]]
invalidation_flow: !Find [authentik_flows.flow, [slug, default-provider-invalidation-flow]]
client_type: confidential
client_id: !Env AUTHENTIK_OIDC_CLIENT_ID
client_secret: !Env AUTHENTIK_OIDC_CLIENT_SECRET
# Not populated by any default when created via blueprint - without it the authorization
# endpoint rejects every request with "Invalid grant_type for provider" (verified locally).
grant_types:
- authorization_code
- refresh_token
redirect_uris:
- url: !Format ["http://localhost:%s/users/oidc/callback", !Env [IDP_REDIRECT_PORT, "3000"]]
matching_mode: strict
signing_key: !Find [authentik_crypto.certificatekeypair, [name, "authentik Self-signed Certificate"]]
property_mappings:
- !Find [authentik_providers_oauth2.scopemapping, [managed, "goauthentik.io/providers/oauth2/scope-openid"]]
- !KeyOf uni-lj-scope-email
- !KeyOf uni-lj-scope-profile
- model: authentik_core.application
id: uni-lj-application
state: present
identifiers:
slug: uni-lj-test
attrs:
name: "Univerza v Ljubljani (test stand-in)"
slug: uni-lj-test
provider: !KeyOf uni-lj-provider
policy_engine_mode: any
meta_description: >
Throwaway local test application standing in for the single real University of Ljubljana
OIDC federation. Not a real IdP - dev/testing use only.
# --- Test users --------------------------------------------------------------------------
# All seeded users share the same fixed password so a tester can log in without hunting for
# per-user credentials. See dev/authentik/README.md for what portal-side scenario each covers,
# and for the exact local-account value scenario B requires you to register first.
# (A) Brand new user via IdP only, every claim present.
- model: authentik_core.user
id: uni-lj-user-full
state: present
identifiers:
username: ana.novak
attrs:
name: "Ana Novak"
email: ana.novak@ff.uni-lj.si
is_active: true
attributes:
given_name: Ana
family_name: Novak
preferred_username: novaka@ff.uni-lj.si
password: "IdpTest123!"
# (B) email claim matches a pre-existing LOCAL portal account -> account-conversion test.
- model: authentik_core.user
id: uni-lj-user-email-match
state: present
identifiers:
username: berta.kolar.idp
attrs:
name: "Berta Kolar"
email: berta.kolar@fri.uni-lj.si
is_active: true
attributes:
given_name: Berta
family_name: Kolar
preferred_username: kolarb@fri.uni-lj.si
password: "IdpTest123!"
# (C) given_name/family_name attributes deliberately left unset -> those claims (and the derived
# `name`) are entirely absent from the ID token/userinfo response (not blank strings) -> the
# portal refuses to create/convert an account without a name (nothing to review or persist),
# with a clear error message rather than a blank editable form. No real first/last name
# exists to build a proper email/preferred_username from, so both deliberately reuse the same
# "brez.imena" placeholder local-part (only the domain suffix is updated for consistency).
- model: authentik_core.user
id: uni-lj-user-missing-name
state: present
identifiers:
username: brez.imena
attrs:
name: "Brez imena (missing given_name/family_name claims)"
email: brez.imena@fri.uni-lj.si
is_active: true
attributes:
preferred_username: brez.imena@fri.uni-lj.si
password: "IdpTest123!"