Skip to content

Commit 0329ae4

Browse files
Adding Support For CIBA with RAR
1 parent a455156 commit 0329ae4

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

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",

0 commit comments

Comments
 (0)