|
|
|
@@ -24,7 +24,10 @@ import java.util.Map;
|
|
|
|
* <li><b>§5.8.3 sending.</b> A cookie whose {@code same-site-flag} is {@code Strict} or
|
|
|
|
* <li><b>§5.8.3 sending.</b> A cookie whose {@code same-site-flag} is {@code Strict} or
|
|
|
|
* {@code Lax} is not attached to a cross-site request; {@code Lax} makes an exception for
|
|
|
|
* {@code Lax} is not attached to a cross-site request; {@code Lax} makes an exception for
|
|
|
|
* top-level safe-method navigations, which a {@code fetch()} from a SPA is not. A cookie with
|
|
|
|
* top-level safe-method navigations, which a {@code fetch()} from a SPA is not. A cookie with
|
|
|
|
* no {@code SameSite} attribute is treated as {@code Lax}.</li>
|
|
|
|
* no {@code SameSite} attribute is treated as {@code Lax} — by Chromium-based browsers.
|
|
|
|
|
|
|
|
* Firefox has not enabled Lax-by-default on its release channel, so it still treats an absent
|
|
|
|
|
|
|
|
* attribute as unrestricted. This jar models the Chromium behaviour, because that is the one
|
|
|
|
|
|
|
|
* a deployment has to survive.</li>
|
|
|
|
* </ul>
|
|
|
|
* </ul>
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* <p>Feeding the real {@code Set-Cookie} headers the application emits through this jar is what
|
|
|
|
* <p>Feeding the real {@code Set-Cookie} headers the application emits through this jar is what
|
|
|
|
@@ -119,7 +122,9 @@ public final class SpecCookieJar {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static boolean willSend(StoredCookie cookie, Context context, boolean safeMethod) {
|
|
|
|
private static boolean willSend(StoredCookie cookie, Context context, boolean safeMethod) {
|
|
|
|
// No SameSite attribute means Lax, which is where the modern default bites.
|
|
|
|
// No SameSite attribute means Lax in Chromium-based browsers, which is where the modern
|
|
|
|
|
|
|
|
// default bites. Firefox's release channel still treats an absent attribute as
|
|
|
|
|
|
|
|
// unrestricted; modelling the stricter of the two is the useful choice.
|
|
|
|
String effective = (cookie.sameSite() == null) ? "Lax" : cookie.sameSite();
|
|
|
|
String effective = (cookie.sameSite() == null) ? "Lax" : cookie.sameSite();
|
|
|
|
return switch (context) {
|
|
|
|
return switch (context) {
|
|
|
|
case SAME_SITE -> true;
|
|
|
|
case SAME_SITE -> true;
|
|
|
|
|