-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐳 Fix proxy-setup with docker-compose
We need to rewrite the Host header when we make API calls to localhost:8001 and localhost:8002 from the test suite, since the URLs need to be resolvable from container-to-container. However, the previous setup broke the local docker-compose setup for login to the admin because the cookie domain is set to the internal service names, so logging in was no longer possible due to a missing csrftoken cookie (as we log in on localhost, not the internal service names). Only overwriting the Host header in /api/ subpaths is a pragmatic approach that should solve this, since CSRF cookies are not used in the API. Furthermore, the browser sends an Oigin header of localhost:800x, but this is different from the Host seen by Django due to the proxy_pass directive, which also results in CSRF issues. The solution is to enable X-Forwarded-Host header and calculate it in nginx, so that it matches. For this match to happen, we also need to add the port number and keep the mapped docker-compose port and nginx server block ports in sync, since different ports lead to different origins.
- Loading branch information
1 parent
a6586c6
commit d13ae74
Showing
3 changed files
with
22 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,8 +28,9 @@ | |
}, | ||
{ | ||
"model": "token.tokenauth", | ||
"pk": "7657474c3d75f56ae0abd0d1bf7994b09964dca9", | ||
"pk": 1, | ||
"fields": { | ||
"token": "7657474c3d75f56ae0abd0d1bf7994b09964dca9", | ||
"contact_person": "Admin", | ||
"email": "[email protected]", | ||
"organization": "", | ||
|
@@ -43,7 +44,7 @@ | |
"model": "token.permission", | ||
"pk": 1, | ||
"fields": { | ||
"token_auth": "7657474c3d75f56ae0abd0d1bf7994b09964dca9", | ||
"token_auth": 1, | ||
"object_type": 1, | ||
"mode": "read_and_write", | ||
"use_fields": false, | ||
|
@@ -54,7 +55,7 @@ | |
"model": "token.permission", | ||
"pk": 2, | ||
"fields": { | ||
"token_auth": "7657474c3d75f56ae0abd0d1bf7994b09964dca9", | ||
"token_auth": 1, | ||
"object_type": 2, | ||
"mode": "read_and_write", | ||
"use_fields": false, | ||
|
@@ -65,7 +66,7 @@ | |
"model": "token.permission", | ||
"pk": 3, | ||
"fields": { | ||
"token_auth": "7657474c3d75f56ae0abd0d1bf7994b09964dca9", | ||
"token_auth": 1, | ||
"object_type": 3, | ||
"mode": "read_and_write", | ||
"use_fields": false, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters