Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/content/docs/helm-values-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ The following OIDC fields enable install-time role mapping and customization of
| Key | Type | Default | Description |
|---|---|---|---|
| `api.oidc.displayName` | string | `"Single sign-on"` | Label for the OIDC login button shown on the login screen (before authentication). |
| `api.oidc.groupsClaim` | string | *(empty — defaults to "groups")* | OIDC claim name containing group or role memberships. Examples: `groups`, `roles`, `membership`, `department`. When empty, the `groups` claim is read. This only chooses which claim is read; it does not turn group-based role mapping on or off (`roleMappings` does). Mapping is active whenever at least one `roleMappings` list is non-empty or an admin has set a mapping override in the dashboard. With neither, new OIDC users get `viewer` and existing users' roles are never re-evaluated. |
| `api.oidc.defaultRole` | string | *(empty — defaults to "viewer")* | Default dashboard role for new OIDC users when no group matches a configured mapping. Accepted: `viewer`, `operator`, `admin`, `deny` (deny = reject login). When empty, defaults to "viewer". |
| `api.oidc.roleMappings` | object | `{admin: [], operator: [], viewer: []}` | Map OIDC groups to dashboard roles at install/upgrade time. Example: `admin: ["gameplane-admins", "ops-team"]`. DB-managed role overrides (set via dashboard) take precedence and survive Helm upgrades. |
| `api.oidc.groupsClaim` | string | *(empty — defaults to "groups")* | OIDC claim name containing group or role memberships. Examples: `groups`, `roles`, `membership`, `department`. When empty, the `groups` claim is read. This only chooses which claim is read; it does not turn group-based role mapping on or off (`roleRules` or `roleMappings` does). Mapping is active whenever `roleRules` has a rule, at least one `roleMappings` list is non-empty, or an admin has set an override in the dashboard. With neither, new OIDC users get `viewer` and existing users' roles are never re-evaluated. |
| `api.oidc.defaultRole` | string | *(empty — defaults to "viewer")* | Fallback role for OIDC users when no rule matches. Accepted: empty (viewer), `deny` (reject login), or any role name; before the role rules release, only `viewer`, `operator`, `admin` and `deny`. A role name that does not exist is refused at sign-in, not at install time. |
| `api.oidc.roleRules` | list | `[]` | *(After v0.4.3.)* Ordered group → role rules; the first rule whose group the user is in decides the role, and any built-in or custom role can be named. Example: `[{group: "sys-admin", role: "admin"}, {group: "gameplane login only", role: "login-only"}]`. Group names are matched exactly and may contain spaces. Cannot be combined with `roleMappings`: the chart fails to render. A dashboard override replaces the whole list and survives Helm upgrades. |
| `api.oidc.roleMappings` | object | `{admin: [], operator: [], viewer: []}` | Older per-role form, still read as rules in the order admin, operator, viewer. Example: `admin: ["gameplane-admins", "ops-team"]`. Prefer `roleRules` for new installs. DB-managed overrides (set via dashboard) take precedence and survive Helm upgrades. |
</DocsCallout>

## API replicas and trusted proxies
Expand Down
8 changes: 5 additions & 3 deletions src/content/docs/user-administration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ Role changes affect global authorization; local and OIDC credentials have differ
- The user's role and email in Gameplane mirror the provider's state

Users who log in via OIDC have their role determined by:
- **Per-provider group mappings** configured under **Admin Settings → Authentication**, re-evaluated against the user's IdP groups on each login
- **Helm-seeded group mappings** (`api.oidc.groupsClaim`, `api.oidc.roleMappings`) for the Helm-configured provider, from v0.3.0; an admin can override them in the dashboard
- **Manual assignment** when no group mapping is configured: new OIDC users get the default role (`viewer`) and an admin promotes them
- **Per-provider role rules** configured under **Admin Settings → Authentication**: an ordered list where the first rule whose group the user is in decides the role (any built-in or custom role), re-evaluated on each login
- **Helm-seeded rules** (`api.oidc.groupsClaim`, `api.oidc.roleRules`, or the older `api.oidc.roleMappings`) for the Helm-configured provider; an admin can override them in the dashboard
- **Manual assignment** when no rule is configured: new OIDC users get the default role (`viewer`) and an admin promotes them

**Roles set by hand stay (after v0.4.3).** Each SSO user's card shows where their role comes from: **From SSO**, **From SSO (applies at next sign-in)** or **Set by hand**. Changing an SSO user's role on the Users page marks it **Set by hand**, and sign-in no longer changes it. To let the rules manage the role again, choose **Return to SSO control** on the user and confirm: the user keeps their role until their next sign-in, when the rule result applies. Local (password) users have no role source. See [Users, Auth & RBAC](../users-auth-rbac/) for how rules are matched.

## Review lifecycle and availability

Expand Down
70 changes: 66 additions & 4 deletions src/content/docs/users-auth-rbac.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Add OIDC providers under **Admin Settings → Authentication → Add provider**.

Supported providers include Keycloak, Authentik, Google, GitHub, and any RFC-7519 compliant OpenID Connect provider. Detailed setup guides for Keycloak, Authentik, Google, and GitHub follow the same issuer/client ID/secret pattern.

When a user logs in via OIDC for the first time, Gameplane creates a user row. Without role mappings the role is `viewer` and admins must promote new OIDC users manually via the dashboard or custom role bindings; with role mappings the role comes from the user's IdP groups (see Install-time role mappings below).
When a user logs in via OIDC for the first time, Gameplane creates a user row. Without role rules the role is `viewer` and admins must promote new OIDC users manually via the dashboard or custom role bindings; with role rules the role comes from the user's IdP groups (see SSO group role rules below).

The sequence below shows the OIDC sign-in round trip between the browser, the API, and the identity provider.

Expand All @@ -136,6 +136,51 @@ sequenceDiagram
A-->>B: Set session and CSRF cookies, 302 to /
```

### SSO group role rules

<DocsCallout icon="milestone" title="New after v0.4.3">
Role rules and role source ship in the first release after v0.4.3. Earlier releases use the per-role mappings described in Install-time role mappings below.
</DocsCallout>

Each SSO provider maps IdP groups to roles with an **ordered list of rules**. A rule says "members of group X get role Y".

- **Any role.** A rule can name a built-in role (`admin`, `operator`, `viewer`) or a custom role such as `login-only`.
- **First match wins.** Rules are checked from the top, and the first rule whose group the user is in decides the role. Order decides, not privilege: a `viewer` rule above an `admin` rule gives viewer to members of both groups.
- **Exact match.** Group names are matched exactly and case-sensitively against the groups claim. Spaces and punctuation are allowed.
- **Fallback.** If no rule matches, the fallback role applies: viewer, `deny` (refuse the sign-in), or any role that exists.
- **Missing roles.** The dashboard refuses to save a rule or fallback that names a role that does not exist, and refuses to delete a role that a rule or fallback uses.
- **Mapping off.** A provider with no rules keeps roles as they are: new users get viewer and sign-in never changes a role.

Edit the rules under **Admin Settings → Authentication**, in the provider form or, for the Helm-configured provider, in the role rule override card. The editor adds, removes and reorders rules, warns when a group already appears in an earlier rule, and asks for confirmation before a save gives a group the admin role. For the Helm provider, the dashboard override replaces the whole Helm rule list and fallback; **Reset to Helm default** removes it.

The flowchart below shows how the API picks a role from the user's groups.

```mermaid
flowchart TD
A["Groups from groupsClaim"] --> B{"Any role rules?"}
B -- no --> V["viewer, role never changed at sign-in"]
B -- yes --> C{"Next rule: is the user in its group?"}
C -- yes --> R["That rule's role"]
C -- "no, more rules" --> C
C -- "no rule left" --> F{"Fallback"}
F -- "deny" --> X["Sign-in refused"]
F -- "role" --> G["Fallback role"]
```

#### Role source

Gameplane records who set each SSO user's current role, and the Users page shows it as a badge:

| Badge | Meaning |
|---|---|
| From SSO | The rules set the role. Each sign-in applies the rule result, including demotion when the user leaves a group. |
| From SSO (applies at next sign-in) | An admin returned the user to SSO control. The role stays the same until the next sign-in. |
| Set by hand | An admin set the role on the Users page. Sign-in never changes it, and the user is let in even when no rule matches and the fallback is `deny`. |

Changing an SSO user's role on the Users page marks it **Set by hand**. To hand the role back to the rules, choose **Return to SSO control** on the user. On upgrade, users linked to an SSO account start as From SSO and all other users as Set by hand; no role changes.

Every SSO sign-in that changes, keeps or refuses a role writes an audit event of the form `oidc role decision: provider=… rule=… group=… role=… source=… result=…`, so you can see which rule matched and whether it was applied. A demotion that would remove the last user who can manage users is skipped and recorded, as before.

### Install-time role mappings

<DocsCallout icon="milestone" title="Available since v0.3.0">
Expand All @@ -144,9 +189,26 @@ sequenceDiagram

Helm role mappings eliminate the need for a `bootstrap-admin` account in OIDC-only deployments. Operators configure group mappings at install time, and the first user to log in receives the correct role immediately based on their IdP group membership.

When deploying with Helm, set `api.oidc.enabled=true`, `api.oidc.groupsClaim` to the name of your IdP's groups claim (e.g., `"groups"`), and configure `api.oidc.roleMappings.{admin,operator,viewer}` with a list of group names for each role. On first login, Gameplane matches the user's group membership against the mappings and assigns the highest-privilege matching role.
When deploying with Helm, set `api.oidc.enabled=true`, `api.oidc.groupsClaim` to the name of your IdP's groups claim (e.g., `"groups"`), and list the rules in `api.oidc.roleRules`. On first login, Gameplane matches the user's groups against the rules and assigns the first matching rule's role.

```yaml
api:
oidc:
enabled: true
groupsClaim: "groups"
defaultRole: "deny"
roleRules:
- group: "sys-admin"
role: "admin"
- group: "gameplane login only"
role: "login-only"
```

Create custom roles such as `login-only` before users sign in; a rule naming a role that does not exist refuses the sign-in.

**Old per-role keys.** `api.oidc.roleMappings.{admin,operator,viewer}` keeps working and is read as rules in the order admin, then operator, then viewer, which gives the same role as before (the highest-privilege matching role). Set either `roleRules` or `roleMappings`, not both: the chart fails to render when both are set.

The flowchart below shows how the API picks a role from the user's groups, including the case where no mapping matches.
With the old per-role keys, the role is picked as in the flowchart below.

```mermaid
flowchart TD
Expand All @@ -164,7 +226,7 @@ flowchart TD
F -- "admin or operator" --> G["defaultRole value"]
```

After deployment, admins can override role mappings through the dashboard without restarting the API. Helm upgrades preserve dashboard customizations — they do not overwrite group mappings that have already been edited in the UI. For detailed Helm value examples and troubleshooting, see the [OIDC provider setup documentation](https://github.com/GameplanePanel/Gameplane/blob/master/docs/oidc.md#role-mapping-at-install-time-no-bootstrap-admin-required) on GitHub.
After deployment, admins can override the Helm rules through the dashboard without restarting the API. Helm upgrades preserve dashboard customizations — they do not overwrite rules that have already been edited in the UI. For detailed Helm value examples and troubleshooting, see the [OIDC provider setup documentation](https://github.com/GameplanePanel/Gameplane/blob/master/docs/oidc.md#role-mapping-at-install-time-no-bootstrap-admin-required) on GitHub.

<DocsQuickReference
label="LOCKOUT PREVENTION"
Expand Down