mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-10-28 08:44:36 -04:00
fix: Check x-forwarded-proto header when determining auth cookie samesite attribute (#6383)
This commit is contained in:
@@ -85,9 +85,18 @@ def get_samesite(request: Request) -> Literal["lax", "none"]:
|
|||||||
`samesite="lax"` is the default, which works regardless of HTTP or HTTPS,
|
`samesite="lax"` is the default, which works regardless of HTTP or HTTPS,
|
||||||
but does not support hosting in iframes.
|
but does not support hosting in iframes.
|
||||||
"""
|
"""
|
||||||
if request.url.scheme == "https" and settings.PRODUCTION:
|
|
||||||
|
forwarded_proto = request.headers.get("x-forwarded-proto", "").lower()
|
||||||
|
is_https = request.url.scheme == "https" or forwarded_proto == "https"
|
||||||
|
|
||||||
|
if is_https and settings.PRODUCTION:
|
||||||
return "none"
|
return "none"
|
||||||
else:
|
else:
|
||||||
|
# TODO: remove this once we resolve pending iframe issues
|
||||||
|
if settings.PRODUCTION:
|
||||||
|
logger.debug("Setting samesite to 'lax' because connection is not HTTPS")
|
||||||
|
logger.debug(f"{request.url.scheme=} | {forwarded_proto=}")
|
||||||
|
|
||||||
return "lax"
|
return "lax"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user