zitadel/internal/api/http/middleware
Tim Möhlmann fd0c15dd4f
feat(oidc): use web keys for token signing and verification (#8449)
# Which Problems Are Solved

Use web keys, managed by the `resources/v3alpha/web_keys` API, for OIDC
token signing and verification,
as well as serving the public web keys on the jwks / keys endpoint.
Response header on the keys endpoint now allows caching of the response.
This is now "safe" to do since keys can be created ahead of time and
caches have sufficient time to pickup the change before keys get
enabled.

# How the Problems Are Solved

- The web key format is used in the `getSignerOnce` function in the
`api/oidc` package.
- The public key cache is changed to get and store web keys.
- The jwks / keys endpoint returns the combined set of valid "legacy"
public keys and all available web keys.
- Cache-Control max-age default to 5 minutes and is configured in
`defaults.yaml`.

When the web keys feature is enabled, fallback mechanisms are in place
to obtain and convert "legacy" `query.PublicKey` as web keys when
needed. This allows transitioning to the feature without invalidating
existing tokens. A small performance overhead may be noticed on the keys
endpoint, because 2 queries need to be run sequentially. This will
disappear once the feature is stable and the legacy code gets cleaned
up.

# Additional Changes

- Extend legacy key lifetimes so that tests can be run on an existing
database with more than 6 hours apart.
- Discovery endpoint returns all supported algorithms when the Web Key
feature is enabled.

# Additional Context

- Closes https://github.com/zitadel/zitadel/issues/8031
- Part of https://github.com/zitadel/zitadel/issues/7809
- After https://github.com/zitadel/oidc/pull/637
- After https://github.com/zitadel/oidc/pull/638
2024-08-23 14:43:46 +02:00
..
access_interceptor.go feat: trusted (instance) domains (#8369) 2024-07-31 18:00:38 +03:00
activity_interceptor.go feat: add SYSTEM_OWNER role (#6765) 2023-10-25 15:10:45 +00:00
auth_interceptor.go feat: add SYSTEM_OWNER role (#6765) 2023-10-25 15:10:45 +00:00
cache_interceptor_test.go fix: improvements for login and oidc (#227) 2020-06-17 08:06:40 +02:00
cache_interceptor.go feat(oidc): use web keys for token signing and verification (#8449) 2024-08-23 14:43:46 +02:00
call_interceptor.go perf: query data AS OF SYSTEM TIME (#5231) 2023-02-27 22:36:43 +01:00
cors_interceptor.go fix(CORS): add X-Requested-With to Access-Control-Request-Headers (#5009) 2023-01-09 13:37:10 +01:00
csp.go feat: enable iframe use (#4766) 2022-12-14 07:17:36 +01:00
instance_interceptor_test.go feat(v3alpha): read actions (#8357) 2024-08-12 22:32:01 +02:00
instance_interceptor.go feat: trusted (instance) domains (#8369) 2024-07-31 18:00:38 +03:00
metrics_interceptor.go feat: add http_server_return_code_counter metric to gateway (#8173) 2024-07-04 09:37:23 +00:00
middleware_test.go feat: restrict languages (#6931) 2023-12-05 11:12:01 +00:00
origin_interceptor_test.go feat: trusted (instance) domains (#8369) 2024-07-31 18:00:38 +03:00
origin_interceptor.go fix: respect x-zitadel-forwarded header again (#8473) 2024-08-21 16:36:16 +00:00
robots_tag_interceptor_test.go fix: introduce measures to avoid bots crawling and indexing activities (#5728) 2023-05-05 10:25:02 +02:00
robots_tag_interceptor.go fix: introduce measures to avoid bots crawling and indexing activities (#5728) 2023-05-05 10:25:02 +02:00
security_headers.go feat: enable iframe use (#4766) 2022-12-14 07:17:36 +01:00
telemetry_interceptor.go refactor(fmt): run gci on complete project (#7557) 2024-04-03 10:43:43 +00:00
user_agent_cookie.go fix: set user agent cookie on host only (without subdomains) (#7297) 2024-02-15 07:53:59 +01:00