|
| 1 | +# OpenID Connect (OIDC) |
| 2 | + |
| 3 | +[[toc]] |
| 4 | + |
| 5 | +Gotify supports OpenID Connect for Single Sign-On (SSO), allowing users to authenticate via an external identity provider such as Authelia or Dex. |
| 6 | + |
| 7 | +::: warning |
| 8 | +The identity provider **must** support [PKCE](https://oauth.net/2/pkce/) (Proof Key for Code Exchange). IdPs without PKCE support are currently unsupported. |
| 9 | +::: |
| 10 | + |
| 11 | +## Configuration |
| 12 | + |
| 13 | +| Key | Description | |
| 14 | +| :-------------- | :--------------------------------------------------------------------------------------------------------- | |
| 15 | +| `enabled` | Enable OIDC login. | |
| 16 | +| `issuer` | The OIDC issuer URL. Used to discover endpoints via `/.well-known/openid-configuration`. | |
| 17 | +| `clientid` | The client ID registered with your identity provider. | |
| 18 | +| `clientsecret` | The client secret. May be omitted if using a public client with PKCE. | |
| 19 | +| `redirecturl` | The callback URL the identity provider redirects to after authentication. Must match your provider config. | |
| 20 | +| `autoregister` | Automatically create a new Gotify user on first OIDC login. | |
| 21 | +| `usernameclaim` | The OIDC claim used to determine the username. Common values: `preferred_username` or `email`. | |
| 22 | + |
| 23 | +::: details Gotify configuration (config.yml) |
| 24 | + |
| 25 | +```yml |
| 26 | +oidc: |
| 27 | + enabled: true |
| 28 | + issuer: https://auth.example.org |
| 29 | + clientid: gotify |
| 30 | + clientsecret: YOUR_CLIENT_SECRET |
| 31 | + redirecturl: https://gotify.example.org/auth/oidc/callback |
| 32 | + autoregister: true |
| 33 | + usernameclaim: preferred_username |
| 34 | +``` |
| 35 | +
|
| 36 | +::: |
| 37 | +
|
| 38 | +::: details Gotify configuration via environment variables |
| 39 | +
|
| 40 | +```bash |
| 41 | +GOTIFY_OIDC_ENABLED=true |
| 42 | +GOTIFY_OIDC_ISSUER=https://auth.example.org |
| 43 | +GOTIFY_OIDC_CLIENTID=gotify |
| 44 | +GOTIFY_OIDC_CLIENTSECRET=YOUR_CLIENT_SECRET |
| 45 | +GOTIFY_OIDC_REDIRECTURL=https://gotify.example.org/auth/oidc/callback |
| 46 | +GOTIFY_OIDC_AUTOREGISTER=true |
| 47 | +GOTIFY_OIDC_USERNAMECLAIM=preferred_username |
| 48 | +``` |
| 49 | + |
| 50 | +::: |
| 51 | + |
| 52 | +See the [Configuration](/docs/config) page for the full config reference. |
| 53 | + |
| 54 | +### Redirect URL |
| 55 | + |
| 56 | +- The redirect URL must always end with `/auth/oidc/callback`. |
| 57 | +- If Gotify is served at the root, the redirect URL is `https://gotify.example.org/auth/oidc/callback`. |
| 58 | +- If Gotify is served on a sub-path (e.g. behind a reverse proxy at `/gotify/`), the sub-path must be included: `https://example.org/gotify/auth/oidc/callback`. |
| 59 | +- For the **Android app** to support OIDC login, you must add `gotify://oidc/callback` as an additional redirect URL in your identity provider's client configuration. |
| 60 | + |
| 61 | +This URL must match **exactly** between the Gotify config and your identity provider's client configuration. |
| 62 | + |
| 63 | +## Authelia |
| 64 | + |
| 65 | +[Authelia](https://www.authelia.com/) is a self-hosted authentication and authorization server. |
| 66 | + |
| 67 | +::: details Authelia configuration (configuration.yml) |
| 68 | + |
| 69 | +```yml |
| 70 | +identity_providers: |
| 71 | + oidc: |
| 72 | + clients: |
| 73 | + - client_id: 'gotify' |
| 74 | + client_name: 'gotify' |
| 75 | + client_secret: '$pbkdf2-sha512$310000$...' # generate with: authelia crypto hash generate pbkdf2 |
| 76 | + public: false |
| 77 | + authorization_policy: 'two_factor' |
| 78 | + require_pkce: true |
| 79 | + pkce_challenge_method: 'S256' |
| 80 | + consent_mode: implicit |
| 81 | + redirect_uris: |
| 82 | + - 'https://gotify.example.org/auth/oidc/callback' # See redirect url docs |
| 83 | + - 'gotify://oidc/callback' # Required for Android app OIDC login |
| 84 | + scopes: |
| 85 | + - 'openid' |
| 86 | + - 'profile' |
| 87 | + - 'email' |
| 88 | + response_types: |
| 89 | + - 'code' |
| 90 | + grant_types: |
| 91 | + - 'authorization_code' |
| 92 | + access_token_signed_response_alg: 'none' |
| 93 | + userinfo_signed_response_alg: 'none' |
| 94 | + token_endpoint_auth_method: 'client_secret_basic' |
| 95 | +``` |
| 96 | +
|
| 97 | +::: |
| 98 | +
|
| 99 | +## Dex |
| 100 | +
|
| 101 | +[Dex](https://dexidp.io/) is a federated OpenID Connect provider. |
| 102 | +
|
| 103 | +::: details Dex configuration |
| 104 | +
|
| 105 | +```yml |
| 106 | +staticClients: |
| 107 | + - id: gotify |
| 108 | + redirectURIs: |
| 109 | + - 'https://gotify.example.org/auth/oidc/callback' # See redirect url docs |
| 110 | + - 'gotify://oidc/callback' # Required for Android app OIDC login |
| 111 | + name: 'Gotify' |
| 112 | + secret: secret |
| 113 | +``` |
| 114 | +
|
| 115 | +::: |
0 commit comments