zitadel/internal/api/oidc
Livio Spring 3d071fc505
feat: trusted (instance) domains (#8369)
# Which Problems Are Solved

ZITADEL currently selects the instance context based on a HTTP header
(see https://github.com/zitadel/zitadel/issues/8279#issue-2399959845 and
checks it against the list of instance domains. Let's call it instance
or API domain.
For any context based URL (e.g. OAuth, OIDC, SAML endpoints, links in
emails, ...) the requested domain (instance domain) will be used. Let's
call it the public domain.
In cases of proxied setups, all exposed domains (public domains) require
the domain to be managed as instance domain.
This can either be done using the "ExternalDomain" in the runtime config
or via system API, which requires a validation through CustomerPortal on
zitadel.cloud.

# How the Problems Are Solved

- Two new headers / header list are added:
- `InstanceHostHeaders`: an ordered list (first sent wins), which will
be used to match the instance.
(For backward compatibility: the `HTTP1HostHeader`, `HTTP2HostHeader`
and `forwarded`, `x-forwarded-for`, `x-forwarded-host` are checked
afterwards as well)
- `PublicHostHeaders`: an ordered list (first sent wins), which will be
used as public host / domain. This will be checked against a list of
trusted domains on the instance.
- The middleware intercepts all requests to the API and passes a
`DomainCtx` object with the hosts and protocol into the context
(previously only a computed `origin` was passed)
- HTTP / GRPC server do not longer try to match the headers to instances
themself, but use the passed `http.DomainContext` in their interceptors.
- The `RequestedHost` and `RequestedDomain` from authz.Instance are
removed in favor of the `http.DomainContext`
- When authenticating to or signing out from Console UI, the current
`http.DomainContext(ctx).Origin` (already checked by instance
interceptor for validity) is used to compute and dynamically add a
`redirect_uri` and `post_logout_redirect_uri`.
- Gateway passes all configured host headers (previously only did
`x-zitadel-*`)
- Admin API allows to manage trusted domain

# Additional Changes

None

# Additional Context

- part of #8279 
- open topics: 
  - "single-instance" mode
  - Console UI
2024-07-31 18:00:38 +03:00
..
access_token.go perf(oidc): optimize token creation (#7822) 2024-05-16 07:07:56 +02:00
amr_test.go feat(oidc): token exchange impersonation (#7516) 2024-03-20 10:18:46 +00:00
amr.go perf(oidc): optimize token creation (#7822) 2024-05-16 07:07:56 +02:00
auth_request_converter_test.go fix(oidc): store requested response_mode (#8145) 2024-06-17 09:50:12 +00:00
auth_request_converter_v2.go fix(oidc): store requested response_mode (#8145) 2024-06-17 09:50:12 +00:00
auth_request_converter.go fix(oidc): store requested response_mode (#8145) 2024-06-17 09:50:12 +00:00
auth_request_integration_test.go feat: api v2beta to api v2 (#8283) 2024-07-26 22:39:55 +02:00
auth_request.go fix: error handling to prevent panics (#8248) 2024-07-04 14:11:06 +00:00
client_converter.go feat(oidc): organization roles scope (#8120) 2024-06-14 10:00:43 +02:00
client_credentials.go perf(oidc): optimize token creation (#7822) 2024-05-16 07:07:56 +02:00
client_integration_test.go feat: api v2beta to api v2 (#8283) 2024-07-26 22:39:55 +02:00
client.go perf(oidc): optimize token creation (#7822) 2024-05-16 07:07:56 +02:00
device_auth.go perf(oidc): optimize token creation (#7822) 2024-05-16 07:07:56 +02:00
error_test.go fix: uniform oidc errors (#7237) 2024-01-18 07:10:49 +01:00
error.go fix(oidc): return bad request for base64 errors (#7730) 2024-04-09 08:42:59 +02:00
introspect.go fix(oauth): ensure client error is prioritized over token error (#8133) 2024-06-17 09:09:00 +00:00
jwt-profile.go fix: uniform oidc errors (#7237) 2024-01-18 07:10:49 +01:00
key_test.go chore(deps): update all go deps (#7773) 2024-04-15 09:17:36 +00:00
key.go chore(deps): update all go deps (#7773) 2024-04-15 09:17:36 +00:00
oidc_integration_test.go feat: api v2beta to api v2 (#8283) 2024-07-26 22:39:55 +02:00
op.go feat: trusted (instance) domains (#8369) 2024-07-31 18:00:38 +03:00
server_integration_test.go chore(oidc): add refresh token error integration test (#7766) 2024-04-17 08:38:03 +00:00
server_test.go fix(oidc): store requested response_mode (#8145) 2024-06-17 09:50:12 +00:00
server.go fix(oidc): store requested response_mode (#8145) 2024-06-17 09:50:12 +00:00
token_client_credentials_integration_test.go fix(oidc): respect role assertion and idTokenInfo flags and trigger preAccessToken trigger (#8046) 2024-05-31 10:10:18 +00:00
token_client_credentials.go fix(oauth2): correctly return an error on client_credentials and jwt_profile (#8092) 2024-06-12 06:42:50 +00:00
token_code.go fix: correctly set user agent / fingerprint id on user sessions (#8231) 2024-07-03 09:43:34 +02:00
token_device.go fix(oidc): respect role assertion and idTokenInfo flags and trigger preAccessToken trigger (#8046) 2024-05-31 10:10:18 +00:00
token_exchange_converter.go perf(oidc): optimize token creation (#7822) 2024-05-16 07:07:56 +02:00
token_exchange_integration_test.go feat: api v2beta to api v2 (#8283) 2024-07-26 22:39:55 +02:00
token_exchange.go fix(oidc): upgrade zitadel/oidc to allow scope without openid (#8109) 2024-06-13 09:32:27 +00:00
token_jwt_profile_integration_test.go fix(oidc): respect role assertion and idTokenInfo flags and trigger preAccessToken trigger (#8046) 2024-05-31 10:10:18 +00:00
token_jwt_profile.go fix(oauth2): correctly return an error on client_credentials and jwt_profile (#8092) 2024-06-12 06:42:50 +00:00
token_refresh.go fix(oidc): respect role assertion and idTokenInfo flags and trigger preAccessToken trigger (#8046) 2024-05-31 10:10:18 +00:00
token.go fix(oidc): respect role assertion and idTokenInfo flags and trigger preAccessToken trigger (#8046) 2024-05-31 10:10:18 +00:00
userinfo_integration_test.go feat: api v2beta to api v2 (#8283) 2024-07-26 22:39:55 +02:00
userinfo_test.go fix(oidc): respect role assertion and idTokenInfo flags and trigger preAccessToken trigger (#8046) 2024-05-31 10:10:18 +00:00
userinfo.go fix: error handling to prevent panics (#8248) 2024-07-04 14:11:06 +00:00