Skip to content

Commit 948196c

Browse files
committed
fix: oidc
1 parent cf61685 commit 948196c

3 files changed

Lines changed: 143 additions & 14 deletions

File tree

.vitepress/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default defineConfig({
2828
{text: 'Intro', link: '/docs/'},
2929
{text: 'Installation', link: '/docs/install'},
3030
{text: 'Configuration', link: '/docs/config'},
31+
{text: 'OpenID Connect (OIDC)', link: '/docs/oidc'},
3132
{text: 'First Login', link: '/docs/first-login'},
3233
{text: 'Push messages', link: '/docs/pushmsg'},
3334
{text: 'Message Extras', link: '/docs/msgextras'},

docs/config.md

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,33 +40,46 @@ server:
4040
enabled: false # if the certificate should be requested from letsencrypt
4141
accepttos: false # if you accept the tos from letsencrypt
4242
cache: data/certs # the directory of the cache from letsencrypt
43+
directoryurl: # override the directory url of the ACME server
44+
# Let's Encrypt highly recommend testing against their staging environment before using their production environment.
45+
# Staging server has high rate limits for testing and debugging, issued certificates are not valid
46+
# example: https://acme-staging-v02.api.letsencrypt.org/directory
4347
hosts: # the hosts for which letsencrypt should request certificates
44-
# - mydomain.tld
45-
# - myotherdomain.tld
48+
# - mydomain.tld
49+
# - myotherdomain.tld
4650
responseheaders: # response headers are added to every response (default: none)
47-
# X-Custom-Header: "custom value"
51+
# X-Custom-Header: "custom value"
52+
4853
trustedproxies: # IPs or IP ranges of trusted proxies. Used to obtain the remote ip via the X-Forwarded-For header. (configure 127.0.0.1 to trust sockets)
49-
# - 127.0.0.1
50-
# - 192.168.178.0/24
54+
# - 127.0.0.1/32
5155
# - ::1
56+
securecookie: true # If the secure flag should be set on cookies. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie#secure
5257

5358
cors: # Sets cors headers only when needed and provides support for multiple allowed origins. Overrides Access-Control-* Headers in response headers.
5459
alloworigins:
55-
# - ".+.example.com"
56-
# - "otherdomain.com"
60+
# - ".+.example.com"
61+
# - "otherdomain.com"
5762
allowmethods:
58-
# - "GET"
59-
# - "POST"
63+
# - "GET"
64+
# - "POST"
6065
allowheaders:
61-
# - "Authorization"
62-
# - "content-type"
63-
66+
# - "Authorization"
67+
# - "content-type"
6468
stream:
6569
pingperiodseconds: 45 # the interval in which websocket pings will be sent. Only change this value if you know what you are doing.
66-
allowedorigins: # allowed origins for websocket connections (same origin is always allowed, default only same origin)
70+
allowedorigins: # allowed origins for websocket connections (same origin is always allowed)
6771
# - ".+.example.com"
6872
# - "otherdomain.com"
69-
database: # see below
73+
oidc:
74+
enabled: false # Enable OpenID Connect login, allowing users to authenticate via an external identity provider (e.g. Keycloak, Authelia, Google).
75+
issuer: # The OIDC issuer URL. This is the base URL of your identity provider, used to discover endpoints. Example: "https://auth.example.com/realms/myrealm"
76+
clientid: # The client ID registered with your identity provider for this application.
77+
clientsecret: # The client secret for the registered client. May be omitted if using a public client with PKCE.
78+
redirecturl: http://gotify.example.org/auth/oidc/callback # The callback URL that the identity provider redirects to after authentication. Must match exactly what is configured in your identity provider.
79+
pkce: true # If PKCE should be used. https://oauth.net/2/pkce/
80+
autoregister: true # If true, automatically create a new user on first OIDC login. If false, only existing users can log in via OIDC.
81+
82+
database: # for database see (configure database section)
7083
dialect: sqlite3
7184
connection: data/gotify.db
7285
defaultuser: # on database creation, gotify creates an admin user (these values will only be used for the first start, if you want to edit the user after the first start use the WebUI)
@@ -135,4 +148,11 @@ GOTIFY_PASSSTRENGTH=10
135148
GOTIFY_UPLOADEDIMAGESDIR=data/images
136149
GOTIFY_PLUGINSDIR=data/plugins
137150
GOTIFY_REGISTRATION=false
151+
GOTIFY_OIDC_ENABLED=false
152+
GOTIFY_OIDC_ISSUER=
153+
GOTIFY_OIDC_CLIENTID=
154+
GOTIFY_OIDC_CLIENTSECRET=
155+
GOTIFY_OIDC_REDIRECTURL=http://gotify.example.org/auth/oidc/callback
156+
GOTIFY_OIDC_PKCE=true
157+
GOTIFY_OIDC_AUTOREGISTER=true
138158
```

docs/oidc.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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+
## Configuration
8+
9+
| Key | Description |
10+
| :------------- | :--------------------------------------------------------------------------------------------------------- |
11+
| `enabled` | Enable OIDC login. |
12+
| `issuer` | The OIDC issuer URL. Used to discover endpoints via `/.well-known/openid-configuration`. |
13+
| `clientid` | The client ID registered with your identity provider. |
14+
| `clientsecret` | The client secret. May be omitted if using a public client with PKCE. |
15+
| `redirecturl` | The callback URL the identity provider redirects to after authentication. Must match your provider config. |
16+
| `pkce` | Enable [PKCE](https://oauth.net/2/pkce/) for the authorization flow. |
17+
| `autoregister` | Automatically create a new Gotify user on first OIDC login. |
18+
19+
::: details Gotify configuration (config.yml)
20+
21+
```yml
22+
oidc:
23+
enabled: true
24+
issuer: https://auth.example.org
25+
clientid: gotify
26+
clientsecret: YOUR_CLIENT_SECRET
27+
redirecturl: https://gotify.example.org/auth/oidc/callback
28+
pkce: true
29+
autoregister: true
30+
```
31+
32+
:::
33+
34+
::: details Gotify configuration via environment variables
35+
36+
```bash
37+
GOTIFY_OIDC_ENABLED=true
38+
GOTIFY_OIDC_ISSUER=https://auth.example.org
39+
GOTIFY_OIDC_CLIENTID=gotify
40+
GOTIFY_OIDC_CLIENTSECRET=YOUR_CLIENT_SECRET
41+
GOTIFY_OIDC_REDIRECTURL=https://gotify.example.org/auth/oidc/callback
42+
GOTIFY_OIDC_PKCE=true
43+
GOTIFY_OIDC_AUTOREGISTER=true
44+
```
45+
46+
:::
47+
48+
See the [Configuration](/docs/config) page for the full config reference.
49+
50+
### Redirect URL
51+
52+
- The redirect URL must always end with `/auth/oidc/callback`.
53+
- If Gotify is served at the root, the redirect URL is `https://gotify.example.org/auth/oidc/callback`.
54+
- 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`.
55+
56+
This URL must match **exactly** between the Gotify config and your identity provider's client configuration.
57+
58+
## Authelia
59+
60+
[Authelia](https://www.authelia.com/) is a self-hosted authentication and authorization server.
61+
62+
::: details Authelia configuration (configuration.yml)
63+
64+
```yml
65+
identity_providers:
66+
oidc:
67+
clients:
68+
- client_id: 'gotify'
69+
client_name: 'gotify'
70+
client_secret: '$pbkdf2-sha512$310000$...' # generate with: authelia crypto hash generate pbkdf2
71+
public: false
72+
authorization_policy: 'two_factor'
73+
require_pkce: true
74+
pkce_challenge_method: 'S256'
75+
consent_mode: implicit
76+
redirect_uris:
77+
- 'https://gotify.example.org/auth/oidc/callback' # See redirect url docs
78+
scopes:
79+
- 'openid'
80+
- 'profile'
81+
- 'email'
82+
response_types:
83+
- 'code'
84+
grant_types:
85+
- 'authorization_code'
86+
access_token_signed_response_alg: 'none'
87+
userinfo_signed_response_alg: 'none'
88+
token_endpoint_auth_method: 'client_secret_basic'
89+
```
90+
91+
:::
92+
93+
## Dex
94+
95+
[Dex](https://dexidp.io/) is a federated OpenID Connect provider.
96+
97+
::: details Dex configuration
98+
99+
```yml
100+
staticClients:
101+
- id: gotify
102+
redirectURIs:
103+
- 'https://gotify.example.org/auth/oidc/callback' # See redirect url docs
104+
name: 'Gotify'
105+
secret: secret
106+
```
107+
108+
:::

0 commit comments

Comments
 (0)