question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SESSION_COOKIE_SAMESITE not woking

See original GitHub issue

I wanted to embed dashboard to iframe, but got cross-site issue. But I don’t want to use PUBLIC_ROLE_LIKE_GAMMA = True and let everyone who knows the link to access my dashbaord. The solution I found was to set SESSION_COOKIE_SAMESITE = None. The feature have existed after flask 1.0 #2607 changed log

But no matter what I set, the samesite attribute has never shown up.

I can assure that flask and werkzung both are right version. #1549 and use the right config file.

Expected Behavior

Set-Cookie: session=<session>; Expires=Mon, 23-Nov-2020 11:58:00 GMT; Path=/; secure; samesite=<whatever I set>

Actual Behavior

Set-Cookie: session=<session>; Expires=Mon, 23-Nov-2020 11:58:00 GMT; Path=/; secure

Example

  1. Try to set samesite=strict and without secure.

config.py

SESSION_COOKIE_SAMESITE = 'Strict'
SESSION_COOKIE_HTTPONLY = False
SESSION_COOKIE_SECURE = False

result image

  1. Try to set samesite=lax and with secure.

config.py

SESSION_COOKIE_SAMESITE = 'Lax'
SESSION_COOKIE_HTTPONLY = False
SESSION_COOKIE_SECURE = True

result image

Environment

  • Python version: 3.6
  • Flask version: 1.1.2
  • Werkzeug version: 1.0.1
  • Superset version: 0.999.0dev

Checklist

Make sure to follow these steps before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • I have reproduced the issue with at least the latest released version of superset.
  • I have checked the issue tracker for the same issue and I haven’t found one similar.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
keehl1213commented, Nov 30, 2020

I’ve solved this problem. The issue was cause by flask-session. #116 But the pull request haven’t merged yet. So I used the workaround from this issue #124

1reaction
etr2460commented, Nov 25, 2020

As displayed in the config comments (https://github.com/apache/incubator-superset/blob/master/superset/config.py#L918), you need to pass in "None" and not None to set the samesite attribute to “None”. This is an unfortunate naming collision between Python and web standards…

Note I believe you also must set SESSION_COOKIE_HTTPONLY to True to set any of the samesite options as otherwise a malicious site could grab your cookie through JS and impersonate the user

Read more comments on GitHub >

github_iconTop Results From Across the Web

Session cookie set `SameSite=None; Secure;` does not work
I put the word secure inside the cookie and it worked properly, but because the word secure must be used next to samesite...
Read more >
SameSite cookies - HTTP - MDN Web Docs
Cookie "myCookie" rejected because it has the "SameSite=None" attribute but is missing the "secure" attribute. This Set-Cookie was blocked ...
Read more >
Cookies SameSite mode 'None' not working - ComponentSpace
The ASP.NET session cookie must include aSameSite value of None and should be marked as secure. To achieve this: 1. Update the web...
Read more >
Get Ready for New SameSite=None; Secure Cookie Settings
Only cookies with the SameSite=None ; Secure setting will be available for external access, provided they are being accessed from secure connections.
Read more >
SameSite cookies explained - web.dev
Introducing the SameSite attribute on a cookie provides three different ways to control this behaviour. You can choose to not specify the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found