Back to help

Authentik administration for the selfservice

This guide describes what must be configured in Authentik for the Gängeviertel Selfservice to work.

Overview

Authentik remains the source for:

  • user accounts,
  • groups,
  • roles and permissions,
  • user attributes,
  • sign-in.

The selfservice stores only:

  • sessions,
  • group mappings for the UI,
  • access requests,
  • memberships and expiry dates,
  • notifications and the email outbox,
  • the app list,
  • the audit log.

1. Create groups

Create at least these groups:

Group Purpose
selfservice-users May sign in to the selfservice.
selfservice-admins May manage groups and apps in the selfservice.
workshop The actual access group.
workshop-admins May manage workshop and decide requests.

Repeat the pattern for each group:

  • <name> for access,
  • <name>-admins for management.

The names are examples. The selfservice uses the names you enter for the group.

2. Roles and object permissions

For group admins to manage members, their role needs object permissions on the specific group.

Create a role workshop-manager with:

  • global: Can view user (authentik_core.view_user)
  • on the object workshop:
    • Can view group (view_group)
    • Can change group (change_group)
    • Can add user to group (add_user_to_group)
    • Can remove user from group (remove_user_from_group)

Assign the role to the group workshop-admins. The selfservice admin role (selfservice-admins) needs change_group globally or on the managed groups so admins can write their configuration.

Important: without view_user, Authentik cannot find the target user and approvals fail with 404. Without change_group, the group cannot be configured from the selfservice. Without add_user_to_group and remove_user_from_group, membership changes fail with 403.

Group admins can also add or remove co-admins from the group page. That changes the admin group (workshop-admins), so the acting group admin's role needs add_user_to_group and remove_user_from_group as object permissions on the admin group too, in addition to the permissions on workshop. The service account still reads the admin group; the change itself is made with the acting person's token.

Group configuration in Authentik attributes

The selfservice stores no group configuration of its own. Slug, display name, description, category, admin group, visibility, active state, the default expiry and the decision note template live in the Authentik group attribute gv_selfservice:

{
  "gv_selfservice": {
    "slug": "workshop",
    "name": "Werkstatt",
    "description": "Wood workshop on the ground floor",
    "category": "Craft",
    "admin_group": "workshop-admins",
    "visibility": "request",
    "active": true,
    "default_expiry": "30d",
    "decision_note": "Please confirm the safety briefing."
  }
}
  • slug: stable ID used in URLs, requests and the audit log. Do not change it later.
  • category: optional label used to group the group list in the portal.
  • visibility: public, request or private.
  • admin_group: the Authentik group whose members manage this group.
  • active: inactive groups are not shown in the portal.
  • default_expiry: optional preset that prefills the expiry for approvals and renewals. Format: a number and one unit, 12h, 30d, 2w or 6m (hours, days, weeks, months). Empty means no preset.
  • decision_note: optional free text up to 500 characters, offered as a starting point for decision notes.

The description is also stored as a top-level description attribute so other tools can read it. Other group attributes are preserved.

Naming scheme: new groups use these technical Authentik names:

  • access group: <slug>
  • admin group: <slug>-admins

The slug is the group's URL ID, for example workshop and workshop-admins. When creating, the selfservice creates both groups and adds the creator to the admin group. Imported groups may keep an arbitrary existing access name, as long as their admin group ends in -admins. The legacy scheme group-<slug> and group-<slug>-admins is still accepted, so existing configurations keep working; the portal does not force a prefix.

The app writes configuration changes with the acting person's token, so their role needs change_group on the group. The service account reads attributes and provisions new groups.

Public groups

For public groups, anyone with selfservice access can join directly. The join is performed with the person's own token. For this to work, the role of the members (the role on selfservice-users) needs:

  • global Can view user (view_user) so Authentik can find the acting user,
  • Can view group (view_group) on the specific public group,
  • Can add user to group (add_user_to_group) on the specific public group,
  • Can remove user from group (remove_user_from_group) on the specific public group, so members can leave again.

Without view_user or view_group, Authentik answers with 404 and the join fails. Grant the group permissions only on public groups, never globally. Otherwise members could add themselves or others to arbitrary groups.

Private groups have no join and no request. Only group admins can add people directly.

If group admins should also use the Authentik admin interface, give them Can access admin interface. This is not required for the selfservice. The development blueprint grants it to selfservice-admins, so the demo admin user can open /if/admin/ with its limited permissions; akadmin remains the full bootstrap administrator.

3. Service account

The selfservice needs a service account for:

  • user search,
  • group validation,
  • reading profile data,
  • removing expired memberships,
  • provisioning new groups (access and admin group), including adding the creator to the new admin group and rolling back on failure.

Create a service account svc-selfservice and a role selfservice-api with:

  • global: Can view user (authentik_core.view_user)
  • global: Can view group (authentik_core.view_group)
  • global: Can add group (authentik_core.add_group)
  • global: Can change group (authentik_core.change_group)
  • global: Can add user to group (authentik_core.add_user_to_group)
  • global: Can delete group (authentik_core.delete_group) for rollback
  • global: Can view flow (authentik_flows.view_flow)
  • global: Can view invitation (authentik_stages_invitation.view_invitation)
  • global: Can add invitation (authentik_stages_invitation.add_invitation)
  • global: Can delete invitation (authentik_stages_invitation.delete_invitation) for expired links
  • on each access group: Can remove user from group (remove_user_from_group)

The service account explicitly does not need:

  • change_user
  • add_user
  • delete_user
  • Superuser rights

Create an API token for the service account and set GV_AUTHENTIK_API_TOKEN.

When you create a group outside the selfservice, give the service account the object permission remove_user_from_group on that group. Otherwise the expiry job cannot remove members. Groups created by the selfservice follow the naming scheme; permissions still need to be granted for the specific group.

Group admins can open Invite in the user menu to get a shareable enrollment link. Each click creates an independent Authentik invitation named selfservice-<user-key>-<random>, where <user-key> is a short hash of the username (the name must be slug-safe), so a user can hand out one link per person. The page lists the active links (up to 20) and can revoke each one separately. Links have the form:

<GV_AUTHENTIK_URL>/if/flow/<flow-slug>/?itoken=<invitation-uuid>

Prerequisites:

  • an enrollment flow with an Invitation stage (continue without invitation disabled), prompt stages for username/password/name/email, a User Write stage that creates users in selfservice-users, and a User Login stage;
  • GV_INVITE_FLOW set to that flow's slug (default selfservice-enrollment);
  • GV_INVITE_EXPIRY_HOURS (default 48) and GV_INVITE_SINGLE_USE (default true).

Authentik's Example - Enrollment (2 Stage) blueprint is a good starting point; add the invitation stage to it. The development blueprint ships a complete selfservice-enrollment flow.

4. OAuth2/OpenID provider

Create a provider in Authentik:

  • name: selfservice
  • client type: Confidential
  • redirect URI: http://127.0.0.1:8090/auth/callback (later the real domain, for example https://selfservice.gaengeviertel.de/auth/callback)
  • logout URI: http://127.0.0.1:8090/auth/logged-out
  • signing key: the instance key
  • scopes: openid, profile, email, offline_access, and the managed authentik API scope mapping (scope_name goauthentik.io/api)
  • subject mode: user_uuid is a good choice.

Create an application selfservice and connect it to the provider.

Bind the application to selfservice-users, for example with an expression policy:

return ak_is_group_member(request.user, name="selfservice-users")

Set in the selfservice:

GV_OIDC_CLIENT_SECRET=<client secret>
# Optional; derived from GV_AUTHENTIK_URL and the provider name:
# GV_OIDC_ISSUER=https://login.gaengeviertel.de/application/o/selfservice/
# GV_OIDC_CLIENT_ID=selfservice

The selfservice requests these scopes:

openid profile email offline_access goauthentik.io/api

goauthentik.io/api is an Authentik-specific scope, not a standard OIDC scope. It is defined by the managed scope mapping "authentik API Access on behalf of your user". Add that mapping to the provider's scopes; the Authentik UI shows the mapping name, while the client sends the scope_name value goauthentik.io/api. It allows the access token to call the Authentik API as the signed-in person, which the selfservice uses for group changes. Without it, sign-in still works but group actions fail with 403.

offline_access is the standard OIDC scope for a refresh token. Add the managed offline_access mapping to the provider so Authentik issues a refresh token.

5. User profile and attributes

Profile and attribute edits stay in Authentik. The selfservice links to:

https://login.gaengeviertel.de/if/user/#/settings

Customize default-user-settings-flow if the community should edit custom attributes such as phone, room, pronouns, Matrix, or SSH keys.

The brand settings control what is allowed:

  • default_user_change_name
  • default_user_change_email
  • default_user_change_username

Usernames should not be self-editable. If email changes are enabled, use a verification flow.

6. Email

The selfservice sends notifications over SMTP. Set in .env:

GV_SMTP_HOST=smtp.example.org
GV_SMTP_PORT=587
GV_SMTP_USERNAME=
GV_SMTP_PASSWORD=
GV_SMTP_AUTH_METHOD=PLAIN
GV_SMTP_TLS=false
GV_SMTP_LOCAL_NAME=
GV_MAIL_FROM=selfservice@gaengeviertel.de
GV_MAIL_FROM_NAME="Gängeviertel Selfservice"

For port 465, GV_SMTP_TLS=true is common. For port 587, GV_SMTP_TLS=false is common because STARTTLS is used.

Without SMTP the app works, but only in-app notifications are delivered. Emails stay in the outbox and are retried after configuration.

7. Create groups in the selfservice

Sign in as a group admin or selfservice admin and open Groups. That is the central group catalog. Group admins can create new groups there.

Create a new group

The selfservice creates both Authentik groups itself:

  • access group: <slug>
  • admin group: <slug>-admins

Enter name, description, category, visibility, the default expiry, the decision note and active state. The slug (URL ID) is generated automatically from the name. The default expiry uses the same short format as the portal (12h, 30d, 2w, 6m). The creator is added to the new admin group automatically and can manage the group immediately. If a step fails, the groups created in that step are removed again.

Adopt existing groups

Groups that already exist in Authentik are brought in through the Import from Authentik action on Groups, which is reserved for selfservice admins. The import keeps each access group's existing name and writes the configuration to its gv_selfservice attribute. The admin group must end in -admins.

Field Example
Slug workshop
Name Werkstatt
Description Wood workshop on the ground floor
Category Craft
Visibility By request
Default expiry 30d
Decision note Please confirm the safety briefing.
Active on

Visibility controls access:

  • Public: anyone can join directly (see section 2).
  • By request: access is granted through a request.
  • Private: only group admins can add people.

Edit settings and unlink

You edit an existing group's settings on its management page: open it with Manage on the group card under Groups. That page contains the Group settings section with the edit form and Unlink below it. Unlink removes only the selfservice configuration; the Authentik groups remain.

App management lives on the Apps page and is reserved for selfservice admins. Group admins work from Groups and the individual group page.

8. Apps

On the Apps page, selfservice admins can manage the app list:

  • slug
  • name
  • description
  • URL
  • category
  • icon (optional)
  • Authentik application slug (optional)
  • sort order
  • active

Apps appear for all signed-in members under Apps.

Access-bound apps

The optional Authentik application slug field binds an app to an Authentik application. When it is set, the app is shown only to users whose policy-aware application list in Authentik contains that slug, the same list the Authentik user dashboard uses. Leave the field empty to show the link to every signed-in user, for example for external links that Authentik does not manage.

Only applications with a launch URL are considered. The list is read with the user's own OIDC token and cached for five minutes. If Authentik is unavailable, the last cached list is used when present; otherwise linked apps are hidden while unbound apps stay visible.

Permission matrix

Action Who Enforcement
Sign in selfservice-users Authentik application and app check
View own profile all members session
Edit profile all members Authentik user settings flow
Request a group all members app
Approve or deny a request <name>-admins app check and Authentik object permission
Add or remove a member directly <name>-admins app check and Authentik object permission
Add or remove a co-admin <name>-admins app check and Authentik object permission on the admin group
Manage groups and apps selfservice-admins app check
Create or delete users Authentik admins Authentik, not the selfservice
Password, MFA, sessions the person Authentik

Security

  • The service account has no profile write permission.
  • Group changes use the acting person's token.
  • Authentik also records the change in its event log.
  • The selfservice records requests, decisions, and direct changes in its own audit log.
  • The PocketBase dashboard and API are blocked by default. Set GV_ENABLE_PB_ADMIN=true only locally.
  • Session tokens are encrypted at rest. The key comes from GV_ENCRYPTION_KEY or is derived from GV_SESSION_SECRET.

Operations

  • Backups: back up pb_data/data.db regularly.
  • The expiry job runs every minute (GV_EXPIRY_SCHEDULE).
  • The expiry reminder runs daily (GV_EXPIRING_SCHEDULE).
  • The email outbox runs every minute (GV_OUTBOX_SCHEDULE).
  • Old sessions are removed hourly.

Troubleshooting

Sign-in works, but group actions are disabled. The access token is missing goauthentik.io/api. Check the requested scopes and the provider.

Approving returns 403. The role is missing an object permission on the group.

Approving returns 404 for the person. The role is missing the global view_user permission.

The expiry job removes nobody. The service account is missing remove_user_from_group on the group, or view_user/view_group is missing.

A group is shown as missing. Check the exact group name in Authentik. Names in the configuration are exact.