-
Notifications
You must be signed in to change notification settings - Fork 529
fix: cookies doc #2529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix: cookies doc #2529
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,24 +3,56 @@ id: cookies | |||||||||
| title: Configuring cookies | ||||||||||
| --- | ||||||||||
|
|
||||||||||
| By default, cookies sent by Ory Hydra's API are set without explicitly specifying a SameSite mode. If you wish for these cookies | ||||||||||
| to be set with a mode you can use the `serve.cookies.same_site_mode` setting. Possible values are `Strict`, `Lax` or `None`: | ||||||||||
| Ory Hydra uses HTTP cookies for login CSRF, consent CSRF, device-flow CSRF, and the user authentication session. This guide covers | ||||||||||
| how to tune their `SameSite` mode, domain, path, names, and development-mode flags. | ||||||||||
|
|
||||||||||
| ## SameSite mode | ||||||||||
|
|
||||||||||
| The `serve.cookies.same_site_mode` setting controls the | ||||||||||
| [`SameSite`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie#samesitesamesite-value) attribute. | ||||||||||
| Allowed values are `Strict`, `Lax`, or `None`. The default is `None`. | ||||||||||
|
|
||||||||||
| ```yaml | ||||||||||
| serve: | ||||||||||
| cookies: | ||||||||||
| same_site_mode: Strict | ||||||||||
| same_site_mode: Lax | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| If you wish to embed requests to hydra on a third party site (for example an iframe that periodically polls to check session | ||||||||||
| status) you will need to set the mode to `None`. Some | ||||||||||
| [browser versions](https://www.chromium.org/updates/same-site/incompatible-clients) reject cookies using the `Same-Site=None` | ||||||||||
| attribute. Hydra implements a [workaround](https://web.dev/samesite-cookie-recipes/#handling-incompatible-clients) that can be | ||||||||||
| enabled by setting `serve.cookies.same_site_legacy_workaround` to `true`. This workaround is disabled by default, and only takes | ||||||||||
| effect when `serve.cookies.same_site_mode` is set to `None`: | ||||||||||
| Pick the strictest value your deployment can tolerate: | ||||||||||
|
|
||||||||||
| - `Strict` — cookies are only sent on same-site requests. Safest, but breaks cross-site redirects back into Hydra (for example, | ||||||||||
| returning from an external login UI on a different eTLD+1). | ||||||||||
| - `Lax` — cookies are sent on top-level navigations. Good default when the login/consent UI and Hydra share a parent domain (see | ||||||||||
| [`serve.cookies.domain`](#cookie-domain) below). | ||||||||||
| - `None` — cookies are sent on all cross-site requests. Required when Hydra is reached cross-site, for example by | ||||||||||
| [front-channel logout](./logout) iframes rendered on a different eTLD+1 than Hydra. `SameSite=None` requires the `Secure` flag, | ||||||||||
| so it only works over HTTPS. If the issuer URL isn't HTTPS, Hydra falls back to `Lax` at runtime. | ||||||||||
|
|
||||||||||
| :::warning Third-party cookie deprecation | ||||||||||
|
|
||||||||||
| Modern browsers restrict or block third-party cookies regardless of `SameSite=None`: | ||||||||||
|
|
||||||||||
| - Safari's [Intelligent Tracking Prevention](https://webkit.org/tracking-prevention/) blocks third-party cookies by default. | ||||||||||
| - Firefox's | ||||||||||
| [Total Cookie Protection](https://blog.mozilla.org/en/products/firefox/firefox-rolls-out-total-cookie-protection-by-default-to-all-users-worldwide/) | ||||||||||
| partitions third-party cookies by top-level site. | ||||||||||
| - Chrome restricts third-party cookies via Tracking Protection and the Privacy Sandbox. | ||||||||||
|
|
||||||||||
| Host Hydra on the same eTLD+1 as your application and use `SameSite=Lax` whenever possible. For cross-domain logout, prefer | ||||||||||
| [back-channel logout](./logout) over [front-channel logout](./logout) iframes. Embedding the login, consent, or other | ||||||||||
|
Comment on lines
+41
to
+42
|
||||||||||
| Host Hydra on the same eTLD+1 as your application and use `SameSite=Lax` whenever possible. For cross-domain logout, prefer | |
| [back-channel logout](./logout) over [front-channel logout](./logout) iframes. Embedding the login, consent, or other | |
| Host Hydra on the same eTLD+1 as your application and use `SameSite=Lax` whenever possible. For cross-domain logout, see the | |
| [logout guide](./logout) and prefer back-channel logout over front-channel logout iframes. Embedding the login, consent, or other |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The text says the default
serve.cookies.same_site_modeisNone, but the immediately following YAML example sets it toLaxwithout explaining that this is a recommended override. To avoid readers thinkingLaxis the default, either adjust the example to showNoneor add a short note that the snippet is an example recommendation.