allow generating jwt key at startup

This commit is contained in:
Robin Appelman 2026-11-04 15:08:02 +01:00
commit 44ed58f9d8
Signed by: robin
SSH key fingerprint: SHA256:kifqgrqnut7q1YUIrI0AdMNC23qiKAS/T9uGFmIYvbE
6 changed files with 369 additions and 67 deletions

View file

@ -37,15 +37,19 @@ hook = "https://hook.example.com/hook2/call"
### JWT Authorization
rss-webhook-trigger supports generating JWT tokens to use for authorization. This can be used to authenticate against various services without the need for long-lived keys.
rss-webhook-trigger supports generating JWT tokens to use for authorization. This can be used to authenticate against various services without the need for long-lived shared keys.
This current has been tested with [Forgejo's Authorized Integrations](https://forgejo.org/docs/latest/user/api/authorized-integrations).
#### With dynamic key
By default, rss-webhook-trigger will generate a new RS256 JWT key at startup, combined with serving the OIDC metadata and keys over http, this removes the need to store any long term key.
Services authenticating against the generated JWT token can lookup the public key based on the issuer to validate the token.
```toml
[jwt]
key = "RS256 JWT key, or path to the key"
issuer = "https://example.com"
# optionally, serve `/.well-known/openid-configuration` and `/.well-known/keys` with the key information
# serve `/.well-known/openid-configuration` and `/.well-known/keys`, relative to the `issuer`, with the key information
listen = { address = "0.0.0.0", port = "3000" }
# listen = {path = "/var/run/webhook.sock" }
@ -56,6 +60,19 @@ headers = { authorization = {type = "jwt", aud: "...."} }
body = { event_type = "build" }
```
#### With static key
Altnerativelly, you can specify the private RS256 key in the configuration.
```toml
[jwt]
key = "RS256 JWT key, or path to the key"
issuer = "https://example.com"
# the `listen` option can be left out in cases where the service performing authentication allows manually configuring the public key
# rest of the config as above
```
### Usage in NixOS
A NixOS module is included and can be used like this: