Skip to content

Commit b5154aa

Browse files
committed
Remove use_mrrt flag and have mrrt used by default
1 parent 19977f8 commit b5154aa

File tree

3 files changed

+8
-88
lines changed

3 files changed

+8
-88
lines changed

examples/ConnectedAccounts.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ This is particularly useful for applications that require access to different re
1212

1313
The SDK must be configured with an audience (an API Identifier) - this will be the resource server that uses the tokens from the Token Vault.
1414

15-
The SDK must also be configured to use refresh tokens and MRRT (Multiple Resource Refresh Tokens) since we will use the refresh token grant to get Access Tokens for the My Account API in addition to the API we are calling.
15+
The Auth0 client Application must be configured to use refresh tokens and MRRT (Multiple Resource Refresh Tokens) since we will use the refresh token grant to get Access Tokens for the My Account API in addition to the API we are calling.
1616

1717
```python
1818
server_client = ServerClient(
1919
domain="YOUR_AUTH0_DOMAIN",
2020
client_id="YOUR_CLIENT_ID",
2121
client_secret="YOUR_CLIENT_SECRET",
2222
secret="YOUR_SECRET",
23-
use_mrrt=True,
2423
authorization_params={
2524
"redirect_uri":"YOUR_CALLBACK_URL",
2625
}

src/auth0_server_python/auth_server/server_client.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
AccessTokenForConnectionError,
3232
AccessTokenForConnectionErrorCode,
3333
ApiError,
34-
Auth0Error,
3534
BackchannelLogoutError,
3635
MissingRequiredArgumentError,
3736
MissingTransactionError,
@@ -68,7 +67,6 @@ def __init__(
6867
state_identifier: str = "_a0_session",
6968
authorization_params: Optional[dict[str, Any]] = None,
7069
pushed_authorization_requests: bool = False,
71-
use_mrrt: bool = False,
7270
):
7371
"""
7472
Initialize the Auth0 server client.
@@ -85,7 +83,6 @@ def __init__(
8583
state_identifier: Identifier for state data
8684
authorization_params: Default parameters for authorization requests
8785
pushed_authorization_requests: Whether to use PAR for authorization requests
88-
use_mrrt: Whether to allow use of Multi-Resource Refresh Tokens
8986
"""
9087
if not secret:
9188
raise MissingRequiredArgumentError("secret")
@@ -97,7 +94,6 @@ def __init__(
9794
self._redirect_uri = redirect_uri
9895
self._default_authorization_params = authorization_params or {}
9996
self._pushed_authorization_requests = pushed_authorization_requests # store the flag
100-
self._use_mrrt = use_mrrt
10197

10298
# Initialize stores
10399
self._transaction_store = transaction_store
@@ -617,14 +613,6 @@ async def get_access_token(
617613
token_set = ts
618614
break
619615

620-
# After loop: if no matching token found and MRRT disabled, check if we need to error
621-
if not token_set and not self._use_mrrt and state_data_dict.get("token_sets"):
622-
# We have tokens but none match, and we can't use RT to get a new one
623-
raise AccessTokenError(
624-
AccessTokenErrorCode.INCORRECT_AUDIENCE,
625-
"The access token for the requested audience is not available and Multi-Resource Refresh Tokens are disabled."
626-
)
627-
628616
# If token is valid, return it
629617
if token_set and token_set.get("expires_at", 0) > time.time():
630618
return token_set["access_token"]
@@ -1316,9 +1304,6 @@ async def start_connect_account(
13161304
Returns:
13171305
The a connect URL containing a ticket to redirect the user to.
13181306
"""
1319-
if not self._use_mrrt:
1320-
raise Auth0Error("Multi-Resource Refresh Tokens (MRRT) is required to use Connected Accounts functionality.")
1321-
13221307
# Use the default redirect_uri if none is specified
13231308
redirect_uri = options.redirect_uri or self._redirect_uri
13241309
# Ensure we have a redirect_uri
@@ -1387,9 +1372,6 @@ async def complete_connect_account(
13871372
Returns:
13881373
A response from the connect account flow.
13891374
"""
1390-
if not self._use_mrrt:
1391-
raise Auth0Error("Multi-Resource Refresh Tokens (MRRT) is required to use Connected Accounts functionality.")
1392-
13931375
# Parse the URL to get query parameters
13941376
parsed_url = urlparse(url)
13951377
query_params = parse_qs(parsed_url.query)

src/auth0_server_python/tests/test_server_client.py

Lines changed: 7 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from auth0_server_python.error import (
1919
AccessTokenForConnectionError,
2020
ApiError,
21-
Auth0Error,
2221
BackchannelLogoutError,
2322
MissingRequiredArgumentError,
2423
MissingTransactionError,
@@ -1274,8 +1273,7 @@ async def test_start_connect_account_calls_connect_and_builds_url(mocker):
12741273
client_secret="<client_secret>",
12751274
state_store=mock_state_store,
12761275
transaction_store=mock_transaction_store,
1277-
secret="some-secret",
1278-
use_mrrt=True
1276+
secret="some-secret"
12791277
)
12801278

12811279
mocker.patch.object(client, "get_access_token", AsyncMock(return_value="<access_token>"))
@@ -1339,8 +1337,7 @@ async def test_start_connect_account_default_redirect_uri(mocker):
13391337
state_store=mock_state_store,
13401338
transaction_store=mock_transaction_store,
13411339
secret="some-secret",
1342-
redirect_uri="/default_redirect_uri",
1343-
use_mrrt=True
1340+
redirect_uri="/default_redirect_uri"
13441341
)
13451342

13461343
mocker.patch.object(client, "get_access_token", AsyncMock(return_value="<access_token>"))
@@ -1402,8 +1399,7 @@ async def test_start_connect_account_no_redirect_uri(mocker):
14021399
client_secret="<client_secret>",
14031400
state_store=mock_state_store,
14041401
transaction_store=mock_transaction_store,
1405-
secret="some-secret",
1406-
use_mrrt=True
1402+
secret="some-secret"
14071403
)
14081404

14091405
# Act
@@ -1417,33 +1413,6 @@ async def test_start_connect_account_no_redirect_uri(mocker):
14171413
# Assert
14181414
assert "redirect_uri" in str(exc.value)
14191415

1420-
@pytest.mark.asyncio
1421-
async def test_start_connect_account_mrrt_disabled(mocker):
1422-
# Setup
1423-
mock_transaction_store = AsyncMock()
1424-
mock_state_store = AsyncMock()
1425-
1426-
client = ServerClient(
1427-
domain="auth0.local",
1428-
client_id="<client_id>",
1429-
client_secret="<client_secret>",
1430-
state_store=mock_state_store,
1431-
transaction_store=mock_transaction_store,
1432-
secret="some-secret",
1433-
use_mrrt=False
1434-
)
1435-
1436-
# Act
1437-
with pytest.raises(Auth0Error) as exc:
1438-
await client.start_connect_account(
1439-
options=ConnectAccountOptions(
1440-
connection="<connection>"
1441-
)
1442-
)
1443-
1444-
# Assert
1445-
assert "MRRT" in str(exc.value)
1446-
14471416
@pytest.mark.asyncio
14481417
async def test_complete_connect_account_calls_complete(mocker):
14491418
# Setup
@@ -1457,8 +1426,7 @@ async def test_complete_connect_account_calls_complete(mocker):
14571426
state_store=mock_state_store,
14581427
transaction_store=mock_transaction_store,
14591428
secret="some-secret",
1460-
redirect_uri="/test_redirect_uri",
1461-
use_mrrt=True
1429+
redirect_uri="/test_redirect_uri"
14621430
)
14631431

14641432
mocker.patch.object(client, "get_access_token", AsyncMock(return_value="<access_token>"))
@@ -1501,8 +1469,7 @@ async def test_complete_connect_account_no_connect_code(mocker):
15011469
state_store=mock_state_store,
15021470
transaction_store=mock_transaction_store,
15031471
secret="some-secret",
1504-
redirect_uri="/test_redirect_uri",
1505-
use_mrrt=True
1472+
redirect_uri="/test_redirect_uri"
15061473
)
15071474

15081475
mock_my_account_client = AsyncMock(MyAccountClient)
@@ -1533,8 +1500,7 @@ async def test_complete_connect_account_no_state(mocker):
15331500
state_store=mock_state_store,
15341501
transaction_store=mock_transaction_store,
15351502
secret="some-secret",
1536-
redirect_uri="/test_redirect_uri",
1537-
use_mrrt=True
1503+
redirect_uri="/test_redirect_uri"
15381504
)
15391505

15401506
mock_my_account_client = AsyncMock(MyAccountClient)
@@ -1565,8 +1531,7 @@ async def test_complete_connect_account_no_transactions(mocker):
15651531
state_store=mock_state_store,
15661532
transaction_store=mock_transaction_store,
15671533
secret="some-secret",
1568-
redirect_uri="/test_redirect_uri",
1569-
use_mrrt=True
1534+
redirect_uri="/test_redirect_uri"
15701535
)
15711536

15721537
mock_my_account_client = AsyncMock(MyAccountClient)
@@ -1583,29 +1548,3 @@ async def test_complete_connect_account_no_transactions(mocker):
15831548
# Assert
15841549
assert "transaction" in str(exc.value)
15851550
mock_my_account_client.complete_connect_account.assert_not_awaited()
1586-
1587-
@pytest.mark.asyncio
1588-
async def test_complete_connect_account_mrrt_disabled(mocker):
1589-
# Setup
1590-
mock_transaction_store = AsyncMock()
1591-
mock_state_store = AsyncMock()
1592-
1593-
client = ServerClient(
1594-
domain="auth0.local",
1595-
client_id="<client_id>",
1596-
client_secret="<client_secret>",
1597-
state_store=mock_state_store,
1598-
transaction_store=mock_transaction_store,
1599-
secret="some-secret",
1600-
redirect_uri="/test_redirect_uri",
1601-
use_mrrt=False
1602-
)
1603-
1604-
# Act
1605-
with pytest.raises(Auth0Error) as exc:
1606-
await client.complete_connect_account(
1607-
url="/test_redirect_uri?connect_code=<connect_code>&state=<state>"
1608-
)
1609-
1610-
# Assert
1611-
assert "MRRT" in str(exc.value)

0 commit comments

Comments
 (0)