8000 Adding Support For RAR and JAR Requests by kishore7snehil · Pull Request #659 · auth0/auth0-python · GitHub
[go: up one dir, main page]

Skip to content

Adding Support For RAR and JAR Requests #659

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

Merged
merged 3 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ permissions:

jobs:
rl-scanner:
uses: ./.github/workflows/rl-scanner
with:
python-version: 3.10
artifact-name: "auth0-python.tgz"
secrets:
RLSECURE_LICENSE: ${{ secrets.RLSECURE_LICENSE }}
RLSECURE_SITE_KEY: ${{ secrets.RLSECURE_SITE_KEY }}
SIGNAL_HANDLER_TOKEN: ${{ secrets.SIGNAL_HANDLER_TOKEN }}
PRODSEC_TOOLS_USER: ${{ secrets.PRODSEC_TOOLS_USER }}
PRODSEC_TOOLS_TOKEN: ${{ secrets.PRODSEC_TOOLS_TOKEN }}
PRODSEC_TOOLS_ARN: ${{ secrets.PRODSEC_TOOLS_ARN }}
uses: ./.github/workflows/rl-scanner.yml
with:
python-version: 3.10
artifact-name: "auth0-python.tgz"
secrets:
RLSECURE_LICENSE: ${{ secrets.RLSECURE_LICENSE }}
RLSECURE_SITE_KEY: ${{ secrets.RLSECURE_SITE_KEY }}
SIGNAL_HANDLER_TOKEN: ${{ secrets.SIGNAL_HANDLER_TOKEN }}
PRODSEC_TOOLS_USER: ${{ secrets.PRODSEC_TOOLS_USER }}
PRODSEC_TOOLS_TOKEN: ${{ secrets.PRODSEC_TOOLS_TOKEN }}
PRODSEC_TOOLS_ARN: ${{ secrets.PRODSEC_TOOLS_ARN }}
publish-pypi:
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/'))
name: "PyPI"
Expand Down
2 changes: 2 additions & 0 deletions auth0/authentication/pushed_authorization_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def pushed_authorization_request(
redirect_uri (str): The URL to which Auth0 will redirect the browser after authorization has been granted
by the user.
**kwargs: Other fields to send along with the PAR.
For RAR requests, authorization_details parameter should be added in a proper format. See:https://datatracker.ietf.org/doc/html/rfc9396
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

See: https://www.rfc-editor.org/rfc/rfc9126.html
"""
Expand Down
57 changes: 57 additions & 0 deletions auth0/test/authentication/test_pushed_authorization_requests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
import json
from unittest import mock

from ...authentication.pushed_authorization_requests import PushedAuthorizationRequests
Expand Down Expand Up @@ -45,3 +46,59 @@ def test_par_custom_params(self, mock_post):
"foo": "bar",
},
)

@mock.patch("auth0.rest.RestClient.post")
def test_rar(self, mock_post):
a = PushedAuthorizationRequests("my.domain.com", "cid", client_secret="sh!")
a.pushed_authorization_request(
response_type="code",
redirect_uri="https://example.com/callback",
authorization_details=[{"type": "money_transfer", "instructedAmount": {"amount": 2500, "currency": "USD"}}],
)

args, kwargs = mock_post.call_args

expected_data = {
"client_id": "cid",
"client_secret": "sh!",
"response_type": "code",
"redirect_uri": "https://example.com/callback",
"authorization_details": [{"type": "money_transfer", "instructedAmount": {"amount": 2500, "currency": "USD"}}],
}

actual_data = kwargs["data"]

self.assertEqual(args[0], "https://my.domain.com/oauth/par")

self.assertEqual(
json.dumps(actual_data, sort_keys=True),
json.dumps(expected_data, sort_keys=True)
)

@mock.patch("auth0.rest.RestClient.post")
def test_jar(self, mock_post):
a = PushedAuthorizationRequests("my.domain.com", "cid", client_secret="sh!")
a.pushed_authorization_request(
response_type="code",
redirect_uri="https://example.com/callback",
request="my-jwt-request",
)

args, kwargs = mock_post.call_args

expected_data = {
"client_id": "cid",
"client_secret": "sh!",
"response_type": "code",
"redirect_uri": "https://example.com/callback",
"request": 'my-jwt-request',
}

actual_data = kwargs["data"]

self.assertEqual(args[0], "https://my.domain.com/oauth/par")

self.assertEqual(
json.dumps(actual_data, sort_keys=True),
json.dumps(expected_data, sort_keys=True)
)
0