# Single sign-on

A team that signs in to everything in one place can sign in to the wall there too, in one of two ways: OpenID Connect, where the provider's groups give the role, or a proxy in front of qKVM that names who is signed in. Both are part of the free program.

## OpenID Connect

Set it up under *Settings > Accounts > Identity provider > Set up*. Open the settings at the address your team uses, since sign-ins begin and end there.

| Setting | What it is |
|---|---|
| Redirect URI | shown in the box (the wall's address and `/api/v1/oidc/callback`): enter it at the provider |
| Issuer | the provider's address, exactly as it names itself (a slash at the end counts) |
| Client ID, client secret | from the provider; the secret is stored encrypted and never shown again |
| Scopes | `openid profile email`, and what the provider needs to send the groups |
| Groups claim | where the groups are: `groups`, `roles` for Entra's app roles, or a path such as `realm_access.roles` |
| Groups and roles | each group, written exactly as sent, and the role it gives; somebody in several gets the highest |
| Who else may sign in | nobody else, or anyone the provider signs in, as a viewer, operator or admin |
| Email domain | only verified addresses at that domain; required for Google |
| May be a private address | the provider is on your own network |

### How it behaves

- The sign-in page shows *Sign in with* and the name you gave. The wall's own passwords keep working beside it, and the last admin with a password cannot be removed, demoted or suspended.
- The first sign-in makes the account, named after the verified email; a name that is taken is never taken over.
- The role is read from the groups at every sign-in. A provider's sign-in lasts 8 hours at the most, so somebody taken out of a group loses that role within 8 hours.
- *Sign them out* ends every sign-in the provider made but your own, at once. Changing anything that decides who gets what does the same.
- The provider does its own second step.
- Started with `--locked-start`, the button works after a restart once somebody has signed in with a password.

### Provider notes

| Provider | Issuer | Groups |
|---|---|---|
| Microsoft Entra ID | `https://login.microsoftonline.com/<tenant ID>/v2.0` | add a groups claim of *Groups assigned to the application*, and map each group's Object ID; or app roles, with the claim `roles` |
| Google Workspace | `https://accounts.google.com` | none are sent: leave the claim empty, set *Who else may sign in* and the email domain; consent screen *Internal* |
| Authentik | `https://auth.example.org/application/o/<slug>/` | `groups` by name, from the `profile` scope |
| Keycloak | `https://keycloak.example.org/realms/<realm>` | a *Group Membership* mapper named `groups`, *Full group path* off |

SAML and SCIM are not offered.

## A proxy that signs people in

Where a reverse proxy signs people in (Authelia, authentik, oauth2-proxy, a company gateway), qKVM can take its word in a header:

```
qkvm --trusted-proxy 172.18.0.5 --sso-header Remote-User
```

1. Make a qKVM account for each person, with the name the proxy sends and no password (*Settings > Accounts > Add account*).
2. Have the proxy *set* the header on every request, replacing whatever a visitor sent under that name.
3. Pass the live view's WebSocket through: HTTP/1.1 with the `Upgrade` and `Connection` headers.
4. Let nothing reach qKVM's port except through the proxy: publish it to the proxy's network only, or use `--allow-from`.

- The header is believed of the proxy named with `--trusted-proxy`, and of nobody else.
- A live view ends when the proxy has not named its person for ten minutes.
- It cannot be used with `--locked-start`.
- Keep at least the first admin signing in with a password, for when the provider is down.

## Related

- [Accounts and roles](https://qkvm.com/docs/web/accounts)
- [Two-factor sign-in](https://qkvm.com/docs/web/two-factor-sign-in)
- [How it is protected](https://qkvm.com/docs/web/how-it-is-protected)

[Full reference](https://github.com/qkvm/qkvm/blob/main/GUIDE.md#sign-in-with-an-identity-provider)
