pushed_authorization_request sends list authorization_details as a Python repr
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Bắt đầu với PushedAuthorizationRequests.pushed_authorization_request() và bài kiểm thử hiện có test_with_authorization_details được đề cập trong issue. So sánh cách RestClient._request() mã hóa các giá trị danh sách với bản sửa lỗi BackChannelLogin.back_channel_login() trong #695. Công việc hoàn tất khi phần thân biểu mẫu chứa authorization_details dưới dạng một mảng JSON có dấu ngoặc kép khi truyền vào một danh sách.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 578
- Fork
- 190
- Merge trung bình
- 9 giờ 39 phút
- Pull request đã merge (30 ngày)
- 7
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của auth0/auth0-python
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
auth0/auth0-python#852 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
auth0/auth0-python#856 · 4 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
auth0/auth0-python#798 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
auth0/auth0-python#789 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của auth0/auth0-python
Issue tương tự
-
changelog investigate
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
ramnes/notion-sdk-py#423 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 89/100
duckdb/duckdb-web#7514 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
jbacalso24/mimry#525 ·
Maintainer thường phản hồi trong vòng 1 ngày