Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新增帳號組權限時,保存後遇到CSRF 禁止 #2812

Open
dearsiang opened this issue Sep 18, 2024 · 5 comments
Open

新增帳號組權限時,保存後遇到CSRF 禁止 #2812

dearsiang opened this issue Sep 18, 2024 · 5 comments

Comments

@dearsiang
Copy link

重现步骤

CSRF-1
CSRF-2
CSRF-3
Hi 大大

這邊將Archery 服務器放在AWS EC2上,並掛在AWS ALB , 將ALB 做CNAME 解析成二級域名

但在新增帳號組的權限時,保存後遇到CSRF 禁止,在網路上找過方法,登入到archery 容器路徑底下/opt/archery/archery/setting.py ,註解掉以下參數,重新啟動後,發現還是一樣出現CSRF 禁止

django.middleware.csrf.CsrfViewMiddleware

Archery 版本:v1.11.3
OS: Ubuntu 24.04 LTS

预期外的结果

CSRF-2

日志文本

[2024-09-18 09:58:30 +0800] [15] [INFO] Using worker: sync
[2024-09-18 09:58:30 +0800] [16] [INFO] Booting worker with pid: 16
[2024-09-18 09:58:30 +0800] [17] [INFO] Booting worker with pid: 17
[2024-09-18 09:58:31 +0800] [18] [INFO] Booting worker with pid: 18
[2024-09-18 09:58:31 +0800] [19] [INFO] Booting worker with pid: 19
2024-09-18 09:58:31,342 - environ.environ - INFO - /opt/archery/.env not found - if you're not configuring your environment separately, check this.
2024-09-18 09:58:31,360 - environ.environ - INFO - /opt/archery/.env not found - if you're not configuring your environment separately, check this.
2024-09-18 09:58:31,494 - environ.environ - INFO - /opt/archery/.env not found - if you're not configuring your environment separately, check this.
2024-09-18 09:58:31,660 - environ.environ - INFO - /opt/archery/.env not found - if you're not configuring your environment separately, check this.
2024-09-18 11:34:43,001 - django.security.csrf - WARNING - Forbidden (Origin checking failed - https://archery-v2.ha-fintech.com does not match any trusted origins.): /admin/auth/group/13/change/

版本

v1.11.3

部署方式

Docker

是否还有其他可以辅助定位问题的信息?比如数据库版本等

MySQL: 8.0.39
Browsers: Chrome

@dearsiang
Copy link
Author

請問大大,有解決辦法嗎?

@dearsiang
Copy link
Author

還是只能坐等版本更新?

@LeoQuote
Copy link
Collaborator

有条件的话开一下debug,看一下详情,csrf更多的还是django和代理的问题,你需要排查一整条链路上的代理,看最后给到django app 的请求是怎么样的,这样来看哪里出了问题。

@dearsiang
Copy link
Author

Hi LeoQuote 大大 , 謝謝回覆

這裡開啟Debug ,再去archery容器底下的/opt/archery/logs/archerys.log 觀察,有出現一些錯誤訊息,不知道是不是跟csrf有關?上面django.contrib.messages.middleware.MessageMiddleware , 這邊看setting 也只有註解掉跟csrf有關的參數,在請大大指導是否還有其他方向能解決,謝謝。

Snipaste_2024-09-24_15-57-28

Snipaste_2024-09-24_15-55-34

Snipaste_2024-09-24_15-06-33

@LeoQuote
Copy link
Collaborator

这个无关, 建议还是多看一下CSRF 的相关文档, 这个更多的还是 django 问题而不是 archery 问题, 因为我也没有环境去复现, 所以我暂时没法帮到你

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants