inventree / InvenTree

Open Source Inventory Management System
https://docs.inventree.org
MIT License
4.34k stars 786 forks source link

CSRF token #8439

Closed Sube22 closed 2 weeks ago

Sube22 commented 2 weeks ago

Deployment Method

Describe the problem*

Hi! My problem is that I can't log in and try as I might, I can't solve it. I can't log in with the old UI, but I can with the new one. With the old one I get an "Authentication failure" in the log and "Forbidden (CSRF cookie not set.): /accounts/login/", but with the new platform I can log in.! `# Site URL - update this to match your host

I run this behind traefik and I also use cloudflare proxy. InvenTree version: 0.16.7

INVENTREE_SITE_URL="http://localhost"

INVENTREE_SITE_URL="http://stock.domain.tld"

COMPOSE_PROJECT_NAME=inventree

INVENTREE_WEB_PORT=1020 INVENTREE_TAG=0.16.7

INVENTREE_ALLOWED_HOSTS=localhost

INVENTREE_ALLOWED_HOSTS=stock.domain.tld

INVENTREE_ALLOWED_HOSTS=*

INVENTREE_TRUSTED_ORIGINS=['http://localhost:1020', 'http://localhost']

INVENTREE_TRUSTED_ORIGINS='https://stock.domain.tld,https://domain.tld,http://localhost,http://localhost:1020,http://192.168.80.5,http://192.168.80.5:8000,http://inventree-server:8000'

INVENTREE_TRUSTED_ORIGINS="https://stock.domain.tld"

INVENTREE_CORS_ORIGIN_ALLOW_ALL=True

INVENTREE_USE_X_FORWARDED_HOST=True

INVENTREE_USE_X_FORWARDED_PORT=True

INVENTREE_CORS_ORIGIN_WHITELIST=https://stock.domain.tld`

Image

PS: In TRUSTED_ORIGINS => I added everything I tried

Steps to Reproduce

Setup Inventree in docker and after setup, unable to login

Relevant log output

Forbidden (CSRF cookie not set.): /accounts/login/

SchrodingersGat commented 2 weeks ago

In the 0.16.7 release notes there is a breaking change which is likely related to this.

You should change the value of INVENTREE_COOKIE_SAMESITE - as per the changelog in the linked release. This should address the issue for you, I think.

Sube22 commented 2 weeks ago

Okay, you've solved in ~two seconds a problem that I've been struggling with for two days. Thank you very much @SchrodingersGat

SchrodingersGat commented 2 weeks ago

@Sube22 happy to help :) And make sure to read the release notes when you update ;)