Skip to content

Commit 4d2d1ad

Browse files
Adding Support For CIBA with RAR (#679)
### Changes - Added support for Rich Authorization Request in CIBA. ### References - [Open ID](https://openid.net/specs/openid-client-initiated-backchannel-authentication-core-1_0.html) - [User Authentication with CIBA](https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-initiated-backchannel-authentication-flow/user-authentication-with-ciba) - [Configure Client-Initiated Backchannel Authentication](https://auth0.com/docs/get-started/applications/configure-client-initiated-backchannel-authentication#integrate-guardian-sdk-into-your-application) ### Testing - [x] This change adds test coverage - [x] This change has been tested on the latest version of the platform/language or why not ### Contributor Checklist - [x] I agree to adhere to the [Auth0 General Contribution Guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md). - [x] I agree to uphold the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md). --------- Co-authored-by: Kunal Dawar <[email protected]>
1 parent 425ed63 commit 4d2d1ad

File tree

6 files changed

+89
-24
lines changed

6 files changed

+89
-24
lines changed

.snyk

+4
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@ ignore:
99
SNYK-PYTHON-REQUESTS-40470:
1010
- '*':
1111
reason: 'patched in latest python versions: https://bugs.python.org/issue27568'
12+
"snyk:lic:pip:certifi:MPL-2.0":
13+
- '*':
14+
reason: "Accepting certifi’s MPL-2.0 license for now"
15+
expires: "2030-12-31T23:59:59Z"
1216
patch: {}

auth0/authentication/back_channel_login.py

+1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ def back_channel_login(
3434
"scope": scope,
3535
**kwargs,
3636
},
37+
headers={"Content-Type": "application/x-www-form-urlencoded"},
3738
)

auth0/test/authentication/test_back_channel_login.py

+60
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
import unittest
33
from unittest import mock
4+
import json
45

56
import requests
67
from ...exceptions import Auth0Error, RateLimitError
@@ -74,5 +75,64 @@ def test_should_require_scope(self, mock_post):
7475
# Assert the error message is correct
7576
self.assertIn("missing 1 required positional argument: \'scope\'", str(context.exception))
7677

78+
@mock.patch("auth0.rest.RestClient.post")
79+
def test_with_authorization_details(self, mock_post):
80+
g = BackChannelLogin("my.domain.com", "cid", client_secret="clsec")
81+
g.back_channel_login(
82+
binding_message="This is a binding message.",
83+
login_hint={"format": "iss_sub", "iss": "https://my.domain.auth0.com/", "sub": "auth0|USER_ID"},
84+
scope="openid",
85+
authorization_details=[
86+
{
87+
"type":"payment_initiation","locations":["https://example.com/payments"],
88+
"instructedAmount":
89+
{
90+
"currency":"EUR","amount":"123.50"
91+
},
92+
"creditorName":"Merchant A",
93+
"creditorAccount":
94+
{
95+
"bic":"ABCIDEFFXXX",
96+
"iban":"DE021001001093071118603"
97+
},
98+
"remittanceInformationUnstructured":"Ref Number Merchant"
99+
}
100+
],
101+
)
102+
103+
args, kwargs = mock_post.call_args
104+
105+
expected_data = {
106+
"client_id": "cid",
107+
"client_secret": "clsec",
108+
"binding_message": "This is a binding message.",
109+
"login_hint": {"format": "iss_sub", "iss": "https://my.domain.auth0.com/", "sub": "auth0|USER_ID" },
110+
"scope": "openid",
111+
"authorization_details": [
112+
{
113+
"type":"payment_initiation","locations":["https://example.com/payments"],
114+
"instructedAmount":
115+
{
116+
"currency":"EUR","amount":"123.50"
117+
},
118+
"creditorName":"Merchant A",
119+
"creditorAccount":
120+
{
121+
"bic":"ABCIDEFFXXX",
122+
"iban":"DE021001001093071118603"
123+
},
124+
"remittanceInformationUnstructured":"Ref Number Merchant"
125+
}],
126+
}
127+
128+
actual_data = kwargs["data"]
129+
130+
self.assertEqual(args[0], "https://my.domain.com/bc-authorize")
131+
132+
self.assertEqual(
133+
json.dumps(actual_data, sort_keys=True),
134+
json.dumps(expected_data, sort_keys=True)
135+
)
136+
77137

78138

auth0/test/authentication/test_pushed_authorization_requests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_par_custom_params(self, mock_post):
4848
)
4949

5050
@mock.patch("auth0.rest.RestClient.post")
51-
def test_rar(self, mock_post):
51+
def test_with_authorization_details(self, mock_post):
5252
a = PushedAuthorizationRequests("my.domain.com", "cid", client_secret="sh!")
5353
a.pushed_authorization_request(
5454
response_type="code",

poetry.lock

+17-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

requirements.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ argcomplete==3.5.3 ; python_version >= "3.7" and python_version < "4.0"
55
async-timeout==4.0.3 ; python_version >= "3.7" and python_version < "4.0"
66
asynctest==0.13.0 ; python_version >= "3.7" and python_version < "3.8"
77
attrs==23.1.0 ; python_version >= "3.7" and python_version < "4.0"
8-
certifi==2023.11.17 ; python_version >= "3.7" and python_version < "4.0"
8+
certifi==2025.1.31 ; python_version >= "3.7" and python_version < "4.0"
99
cffi==1.17.1 ; python_version >= "3.7" and python_version < "4.0"
1010
charset-normalizer==3.2.0 ; python_version >= "3.7" and python_version < "4.0"
1111
click==8.1.7 ; python_version >= "3.7" and python_version < "4.0"
1212
colorama==0.4.6 ; python_version >= "3.7" and python_version < "4.0" and sys_platform == "win32" or python_version >= "3.7" and python_version < "4.0" and platform_system == "Windows"
1313
coverage[toml]==7.2.7 ; python_version >= "3.7" and python_version < "4.0"
14-
cryptography==43.0.1 ; python_version >= "3.7" and python_version < "4.0"
14+
cryptography==44.0.1 ; python_version >= "3.7" and python_version < "4.0"
1515
exceptiongroup==1.1.3 ; python_version >= "3.7" and python_version < "3.11"
1616
frozenlist==1.5.0 ; python_version >= "3.7" and python_version < "4.0"
1717
idna==3.10 ; python_version >= "3.7" and python_version < "4.0"
@@ -24,18 +24,18 @@ pipx==1.2.0 ; python_version >= "3.7" and python_version < "4.0"
2424
pluggy==1.2.0 ; python_version >= "3.7" and python_version < "4.0"
2525
pycparser==2.21 ; python_version >= "3.7" and python_version < "4.0"
2626
pyjwt==2.8.0 ; python_version >= "3.7" and python_version < "4.0"
27-
pyopenssl==23.3.0 ; python_version >= "3.7" and python_version < "4.0"
27+
pyopenssl==25.0.0 ; python_version >= "3.7" and python_version < "4.0"
2828
pytest-aiohttp==1.0.4 ; python_version >= "3.7" and python_version < "4.0"
2929
pytest-asyncio==0.23.8 ; python_version >= "3.7" and python_version < "4.0"
3030
pytest-cov==4.1.0 ; python_version >= "3.7" and python_version < "4.0"
3131
pytest==7.4.0 ; python_version >= "3.7" and python_version < "4.0"
3232
pyyaml==6.0.2 ; python_version >= "3.7" and python_version < "4.0"
33-
requests==2.31.0 ; python_version >= "3.7" and python_version < "4.0"
33+
requests==2.32.3 ; python_version >= "3.7" and python_version < "4.0"
3434
responses==0.23.3 ; python_version >= "3.7" and python_version < "4.0"
3535
tomli==2.0.1 ; python_version >= "3.7" and python_full_version <= "3.11.0a6"
3636
types-pyyaml==6.0.12.11 ; python_version >= "3.7" and python_version < "4.0"
3737
typing-extensions==4.7.1 ; python_version >= "3.7" and python_version < "3.8"
38-
urllib3==2.0.7 ; python_version >= "3.7" and python_version < "4.0"
38+
urllib3==2.2.2 ; python_version >= "3.7" and python_version < "4.0"
3939
userpath==1.9.0 ; python_version >= "3.7" and python_version < "4.0"
4040
yarl==1.9.2 ; python_version >= "3.7" and python_version < "4.0"
41-
zipp==3.15.0 ; python_version >= "3.7" and python_version < "3.8"
41+
zipp==3.19.1 ; python_version >= "3.7" and python_version < "3.8"

0 commit comments

Comments
 (0)