Skip to content

Commit 66429f1

Browse files
Adding Support For RAR and JAR Requests (#659)
Adding Support For RAR and JAR Requests
1 parent 6ef05d4 commit 66429f1

File tree

3 files changed

+70
-11
lines changed

3 files changed

+70
-11
lines changed

.github/workflows/publish.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ permissions:
1212

1313
jobs:
1414
rl-scanner:
15-
uses: ./.github/workflows/rl-scanner
16-
with:
17-
python-version: 3.10
18-
artifact-name: "auth0-python.tgz"
19-
secrets:
20-
RLSECURE_LICENSE: ${{ secrets.RLSECURE_LICENSE }}
21-
RLSECURE_SITE_KEY: ${{ secrets.RLSECURE_SITE_KEY }}
22-
SIGNAL_HANDLER_TOKEN: ${{ secrets.SIGNAL_HANDLER_TOKEN }}
23-
PRODSEC_TOOLS_USER: ${{ secrets.PRODSEC_TOOLS_USER }}
24-
PRODSEC_TOOLS_TOKEN: ${{ secrets.PRODSEC_TOOLS_TOKEN }}
25-
PRODSEC_TOOLS_ARN: ${{ secrets.PRODSEC_TOOLS_ARN }}
15+
uses: ./.github/workflows/rl-scanner.yml
16+
with:
17+
python-version: 3.10
18+
artifact-name: "auth0-python.tgz"
19+
secrets:
20+
RLSECURE_LICENSE: ${{ secrets.RLSECURE_LICENSE }}
21+
RLSECURE_SITE_KEY: ${{ secrets.RLSECURE_SITE_KEY }}
22+
SIGNAL_HANDLER_TOKEN: ${{ secrets.SIGNAL_HANDLER_TOKEN }}
23+
PRODSEC_TOOLS_USER: ${{ secrets.PRODSEC_TOOLS_USER }}
24+
PRODSEC_TOOLS_TOKEN: ${{ secrets.PRODSEC_TOOLS_TOKEN }}
25+
PRODSEC_TOOLS_ARN: ${{ secrets.PRODSEC_TOOLS_ARN }}
2626
publish-pypi:
2727
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/'))
2828
name: "PyPI"

auth0/authentication/pushed_authorization_requests.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ def pushed_authorization_request(
1616
redirect_uri (str): The URL to which Auth0 will redirect the browser after authorization has been granted
1717
by the user.
1818
**kwargs: Other fields to send along with the PAR.
19+
For RAR requests, authorization_details parameter should be added in a proper format. See:https://datatracker.ietf.org/doc/html/rfc9396
20+
For JAR requests, requests parameter should be send with the JWT as the value. See: https://datatracker.ietf.org/doc/html/rfc9126#name-the-request-request-paramet
1921
2022
See: https://www.rfc-editor.org/rfc/rfc9126.html
2123
"""

auth0/test/authentication/test_pushed_authorization_requests.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import unittest
2+
import json
23
from unittest import mock
34

45
from ...authentication.pushed_authorization_requests import PushedAuthorizationRequests
@@ -45,3 +46,59 @@ def test_par_custom_params(self, mock_post):
4546
"foo": "bar",
4647
},
4748
)
49+
50+
@mock.patch("auth0.rest.RestClient.post")
51+
def test_rar(self, mock_post):
52+
a = PushedAuthorizationRequests("my.domain.com", "cid", client_secret="sh!")
53+
a.pushed_authorization_request(
54+
response_type="code",
55+
redirect_uri="https://example.com/callback",
56+
authorization_details=[{"type": "money_transfer", "instructedAmount": {"amount": 2500, "currency": "USD"}}],
57+
)
58+
59+
args, kwargs = mock_post.call_args
60+
61+
expected_data = {
62+
"client_id": "cid",
63+
"client_secret": "sh!",
64+
"response_type": "code",
65+
"redirect_uri": "https://example.com/callback",
66+
"authorization_details": [{"type": "money_transfer", "instructedAmount": {"amount": 2500, "currency": "USD"}}],
67+
}
68+
69+
actual_data = kwargs["data"]
70+
71+
self.assertEqual(args[0], "https://my.domain.com/oauth/par")
72+
73+
self.assertEqual(
74+
json.dumps(actual_data, sort_keys=True),
75+
json.dumps(expected_data, sort_keys=True)
76+
)
77+
78+
@mock.patch("auth0.rest.RestClient.post")
79+
def test_jar(self, mock_post):
80+
a = PushedAuthorizationRequests("my.domain.com", "cid", client_secret="sh!")
81+
a.pushed_authorization_request(
82+
response_type="code",
83+
redirect_uri="https://example.com/callback",
84+
request="my-jwt-request",
85+
)
86+
87+
args, kwargs = mock_post.call_args
88+
89+
expected_data = {
90+
"client_id": "cid",
91+
"client_secret": "sh!",
92+
"response_type": "code",
93+
"redirect_uri": "https://example.com/callback",
94+
"request": 'my-jwt-request',
95+
}
96+
97+
actual_data = kwargs["data"]
98+
99+
self.assertEqual(args[0], "https://my.domain.com/oauth/par")
100+
101+
self.assertEqual(
102+
json.dumps(actual_data, sort_keys=True),
103+
json.dumps(expected_data, sort_keys=True)
104+
)

0 commit comments

Comments
 (0)