pushed_authorization_request sends list authorization_details as a Python repr
維護者通常 1 天內回覆
評估
研究方向
從PushedAuthorizationRequests.pushed_authorization_request()以及 issue 中提到的現有測試test_with_authorization_details開始。比較RestClient._request()對列表值的編碼方式與 #695 中BackChannelLogin.back_channel_login()的修正。傳入列表時,如果表單本文將authorization_details包含為帶雙引號的 JSON 陣列,就表示完成。
由索引模型根據 Issue 內容生成。
描述
Checklist
- I have looked into the README and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
Description
PushedAuthorizationRequests.pushed_authorization_request() posts a form-encoded body (Content-Type: application/x-www-form-urlencoded). RestClient._request() converts the payload with urllib.parse.urlencode(), which turns a list value into its Python repr.
When you pass authorization_details as a list, which the existing test test_with_authorization_details does, the request body contains:
authorization_details=%5B%7B%27type%27%3A+%27money_transfer%27%2C+...
That decodes to [{'type': 'money_transfer', ...}], with single quotes, which is not JSON. RFC 9396 requires authorization_details to be a JSON array, so RAR through PAR does not work with a list.
BackChannelLogin.back_channel_login() had the same problem and was fixed in #695 by calling json.dumps() on list values.
Reproduction
from unittest import mock
from urllib.parse import parse_qs
from auth0.authentication.pushed_authorization_requests import PushedAuthorizationRequests
with mock.patch("requests.request") as req:
req.return_value.status_code = 201
req.return_value.text = '{"request_uri": "urn:x", "expires_in": 30}'
PushedAuthorizationRequests("my.domain.com", "cid", client_secret="s").pushed_authorization_request(
response_type="code",
redirect_uri="https://example.com/cb",
authorization_details=[{"type": "money_transfer"}],
)
print(parse_qs(req.call_args.kwargs["data"])["authorization_details"])
# ["[{'type': 'money_transfer'}]"]
Expected: ['[{"type": "money_transfer"}]'].
Additional context
Workaround: pass authorization_details=json.dumps([...]).
auth0-python version
6.8.0 (main at 9aae3e5)
Python version
3.12
- 主要語言
- Python
- 星號
- 578
- 分支
- 190
- 平均合併
- 9 小時 39 分鐘
- 30 天內合併 PR
- 7
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
auth0/auth0-python 的其他 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 68/100
auth0/auth0-python#852 ·
維護者通常 1 天內回覆
-
bug
難度 3/5 1-2 天 新手友好度 68/100
auth0/auth0-python#856 · 4 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
bug
難度 4/5 3-5 天 新手友好度 52/100
auth0/auth0-python#798 · 1 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
bug
難度 3/5 1-2 天 新手友好度 45/100
auth0/auth0-python#789 · 1 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
查看 auth0/auth0-python 的全部 Issue
相似的 Issue
-
`image_generation`: `max_retries` is ignored for OpenAI-compatible providers (always 2 retries)可能已有人在做 @ericz7900 今天認領。 未關閉llm translation
難度 2/5 1-3 小時 新手友好度 77/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
rheeloaded/paperpull#117 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 65/100
agenda-tech-brasil/agenda-tech-brasil#1619 · 1 則留言 ·
-
process
難度 1/5 1-3 小時 新手友好度 76/100
pyrite-wiki/pyrite#1036 ·
維護者通常 1 天內回覆