Azure-Samples / Azure-Samples/ms-identity-python-samples-common

Intermittent 'Failed to match request state with session state' with Django adaptor

未關閉
#4 1 則留言 4 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
Python
星號
47
分支
42
PR 合併指標
30 天內沒有已合併 PR

描述

This issue is for a: (mark with an x)
- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)
Minimal steps to reproduce

Default Django setup as per Azure-Samples/ms-identity-python-django-tutorial

Any log messages given by the failure

Django error email report snippet:

•	/opt/master/venv/lib/python3.8/site-packages/ms_identity_web/__init__.py in _verify_state 
259.	
260.	            raise AuthSecurityError("Failed to match request state with session state")
261.	
Local Vars
Variable	Value
req_params	{'code': '0.AQ<redacted>AA',
 'session_state': 'aa8b2958-b1c4-4e71-a95c-a682c2180777',
 'state': 'c5af71b0-fc95-4d3c-896e-a5c8306d86f7'}
self	<ms_identity_web.IdentityWebPython object at 0x7fbda61c59a0>
session_state	None
state	'c5af71b0-fc95-4d3c-896e-a5c8306d86f7'

Expected/desired behavior

session_state should not be None and should match state param at https://github.com/Azure-Samples/ms-identity-python-samples-common/blob/main/ms_identity_web/__init__.py#L258

OS and Version?

Django 2.2 using gunicorn on Ubuntu 20.04 EC2

Versions

MSAL 1.12.0

Mention any other details that might be useful

Seems easier to repro using Firefox, but have seen using Edge/Chrome.

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 ms_identity_web/init.py 開始,特別檢查回報行附近的 _verify_state,並比較在使用 gunicorn 的 Django 2.2 設定中工作階段狀態的儲存與讀取方式。使用連結的 Django 教學課程重現這個間歇性故障,並注意 Firefox、Edge 和 Chrome。完成的標準是 callback 不再將 session_state 視為 None,且相關測試或重現確認狀態值相符。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
django, python, ubuntu
領域
authentication, backend
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
28/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。