How to add samesite none option in django settings file
NickName:Hariprasath Vengatachalam Ask DateTime:2020-08-25T15:26:12

How to add samesite none option in django settings file

I used Django 2.0.2 version. I tried to process google authentication in Django project. I got the token but I will pass URL and token. it return 404 error. I need to add samesite='none' in Django settings project. Where to add I don't know and I tried to add many ways but still it's throwing 404 error. How to fix it.

Settings.py

MIDDLEWARE = [
    'django_cookies_samesite.middleware.CookiesSameSite',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

So, I added samesite.middleware.CookiesSameSite middleware. but still I facing this warning A cookie associated with a cross-site resource at http://stats.XXXX.com/ was set without the SameSite attribute. It has been blocked, as Chrome now only delivers cookies with cross-site requests if they are set with SameSite=None and Secure. You can review cookies in developer tools under Application>Storage>Cookies and see more details How to fix it

Copyright Notice:Content Author:「Hariprasath Vengatachalam」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/63573949/how-to-add-samesite-none-option-in-django-settings-file

Answers
art_hq 2020-11-20T19:16:46

Follow this instructions, and set\nDCS_SESSION_COOKIE_SAMESITE = 'None' \n\nat settings.py right after MIDDLEWARE list\nAlso you need establish ssl connection to your dev server or use some outdated browser which allows using SameSite cookie policy with None attribute and without attribute secure",


More about “How to add samesite none option in django settings file” related questions

How to add samesite none option in django settings file

I used Django 2.0.2 version. I tried to process google authentication in Django project. I got the token but I will pass URL and token. it return 404 error. I need to add samesite='none' in Django

Show Detail

Setting a cookie with samesite none on Django 2.2

I am trying to set a specific cookie to have samesite='None' for a Django project on version 2.2.x. I continue to get the below error. raise ValueError('samesite must be "lax" or "st...

Show Detail

Where to add `SameSite=None`?

I got the following code in happening on my site, and I tried my best cant grasp this, so I have a couple questions, please read. category-search-Forum:1 A cookie associated with a cross-site resou...

Show Detail

CSRF_COOKIE_SAMESITE equivalent for django 1.6.5

I am trying to launch my application which was written using django 1.6.5 version, in a salesforce webtab iframe. I was getting a "CSRF cookie not set" error while trying to login. I unde...

Show Detail

samesite none without secure browser

I'm developing with React and Django. The original plan was to send api requests from the front to the Django server to manage sessions and read data, but it seems that cookies cannot be stored in ...

Show Detail

Recaptcha Samesite Cookie Error with Django 4.0.4

I have included Recaptcha v3 in my Django project but am faced with this error: "Indicate whether to send a cookie in a cross-site request by specifying its SameSite attribute" I have t...

Show Detail

Internet Explorer/Edge (not chromium) add additional SameSite=Lax when SameSite=None Secure

I have .NET MVC application loaded in iframe in Microsoft Dynamics page. Initially the user will open the home page. The home controller redirects to the login page: return RedirectToAction("Index...

Show Detail

Test SameSite and Secure cookies in Django Test client response

I have a Django 3.1.7 API. Until now I was adding SameSite and Secure cookies in the responses through a custom middleware before Django 3.1, depending on the user agent, with automated tests. Now ...

Show Detail

ASP.NET 4.7.2 SameSite=None Cookie with WSFederationAuthenticationModule?

In our ASP.NET 4.7.2 web applications, we use WSFederationAuthenticationModule configured in the Web.config like so: <system.webServer> <modules> <add name="

Show Detail

Understanding Django CSRF_COOKIE_SAMESITE and CSRF_TRUSTED_ORIGINS

Obviously I have a problem to understand the impact of Django (2.2.4) settings regarding CSRF parameters in a cross-domain environment. As I have already noticed I have to set SESSION_COOKIE_SAME...

Show Detail