Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2714a3a

Browse files
authored
Merge branch 'master' into master
2 parents feff120 + 9e355df commit 2714a3a

File tree

6 files changed

+54
-3
lines changed

6 files changed

+54
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changes
22
=======
33

4+
3.21.0
5+
------------------
6+
7+
**Added**
8+
- Add pagination to device credentials [\#300](https://github.com/auth0/auth0-python/pull/300) ([fionnulak](https://github.com/fionnulak))
9+
410
3.20.0
511
------------------
612

auth0/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '3.20.0'
1+
__version__ = '3.21.0'

auth0/v3/authentication/token_verifier.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ def verify(self, token, nonce=None, max_age=None, organization=None):
229229
organization (str, optional): The expected organization ID (org_id) claim value. This should be specified
230230
when logging in to an organization.
231231
232+
Returns:
233+
the decoded payload from the token
234+
232235
Raises:
233236
TokenValidationError: when the token cannot be decoded, the token signing algorithm is not the expected one,
234237
the token signature is invalid or the token has a claim missing or with unexpected value.
@@ -244,6 +247,8 @@ def verify(self, token, nonce=None, max_age=None, organization=None):
244247
# Verify claims
245248
self._verify_payload(payload, nonce, max_age, organization)
246249

250+
return payload
251+
247252
def _verify_payload(self, payload, nonce=None, max_age=None, organization=None):
248253
try:
249254
# on Python 2.7, 'str' keys as parsed as 'unicode'

auth0/v3/management/users.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,17 @@ def delete_multifactor(self, id, provider):
298298
url = self._url('{}/multifactor/{}'.format(id, provider))
299299
return self.client.delete(url)
300300

301+
def delete_authenticators(self, id):
302+
"""Delete a user's MFA enrollments.
303+
304+
Args:
305+
id (str): The user's id.
306+
307+
See: https://auth0.com/docs/api/management/v2#!/Users/delete_authenticators
308+
"""
309+
url = self._url('{}/authenticators'.format(id))
310+
return self.client.delete(url)
311+
301312
def unlink_user_account(self, id, provider, user_id):
302313
"""Unlink a user account
303314

auth0/v3/test/authentication/test_token_verifier.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ def test_passes_when_org_present_and_matches(self):
390390
audience=expectations['audience']
391391
)
392392
tv._clock = MOCKED_CLOCK
393-
tv.verify(token, organization='org_123')
393+
tv.verify(token, organization='org_123')
394394

395395
def test_fails_when_org_specified_but_not_present(self):
396396
token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhdXRoMHxzZGs0NThma3MiLCJhdWQiOiJ0b2tlbnMtdGVzdC0xMjMiLCJpc3MiOiJodHRwczovL3Rva2Vucy10ZXN0LmF1dGgwLmNvbS8iLCJleHAiOjE1ODc3NjUzNjEsImlhdCI6MTU4NzU5MjU2MX0.wotJnUdD5IfdZMewF_-BnHc0pI56uwzwr5qaSXvSu9w"
@@ -402,4 +402,22 @@ def test_fails_when_org_specified_but_not_(self):
402402

403403
def test_fails_when_org_specified_but_does_not_match(self):
404404
token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhdXRoMHxzZGs0NThma3MiLCJhdWQiOiJ0b2tlbnMtdGVzdC0xMjMiLCJvcmdfaWQiOiJvcmdfMTIzIiwiaXNzIjoiaHR0cHM6Ly90b2tlbnMtdGVzdC5hdXRoMC5jb20vIiwiZXhwIjoxNTg3NzY1MzYxLCJpYXQiOjE1ODc1OTI1NjF9.hjSPgJpg0Dn2z0giCdGqVLD5Kmqy_yMYlSkgwKD7ahQ"
405-
self.assert_fails_with_error(token, 'Organization (org_id) claim mismatch in the ID token; expected "org_abc", found "org_123"', signature_verifier=SymmetricSignatureVerifier(HMAC_SHARED_SECRET), organization='org_abc')
405+
self.assert_fails_with_error(token, 'Organization (org_id) claim mismatch in the ID token; expected "org_abc", found "org_123"', signature_verifier=SymmetricSignatureVerifier(HMAC_SHARED_SECRET), organization='org_abc')
406+
407+
def test_verify_returns_payload(self):
408+
token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhdXRoMHxzZGs0NThma3MiLCJhdWQiOiJ0b2tlbnMtdGVzdC0xMjMiLCJvcmdfaWQiOiJvcmdfMTIzIiwiaXNzIjoiaHR0cHM6Ly90b2tlbnMtdGVzdC5hdXRoMC5jb20vIiwiZXhwIjoxNTg3NzY1MzYxLCJpYXQiOjE1ODc1OTI1NjF9.hjSPgJpg0Dn2z0giCdGqVLD5Kmqy_yMYlSkgwKD7ahQ"
409+
sv = SymmetricSignatureVerifier(HMAC_SHARED_SECRET)
410+
tv = TokenVerifier(
411+
signature_verifier=sv,
412+
issuer=expectations['issuer'],
413+
audience=expectations['audience']
414+
)
415+
tv._clock = MOCKED_CLOCK
416+
response = tv.verify(token)
417+
self.assertIn('sub', response);
418+
self.assertIn('aud', response);
419+
self.assertIn('org_id', response);
420+
self.assertIn('iss', response);
421+
self.assertIn('exp', response);
422+
self.assertIn('iat', response);
423+
self.assertEqual('org_123', response['org_id'])

auth0/v3/test/management/test_users.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,17 @@ def test_delete_multifactor(self, mock_rc):
260260
'https://domain/api/v2/users/an-id/multifactor/provider'
261261
)
262262

263+
@mock.patch('auth0.v3.management.users.RestClient')
264+
def test_delete_authenticators(self, mock_rc):
265+
mock_instance = mock_rc.return_value
266+
267+
u = Users(domain='domain', token='jwttoken')
268+
u.delete_authenticators('an-id')
269+
270+
mock_instance.delete.assert_called_with(
271+
'https://domain/api/v2/users/an-id/authenticators'
272+
)
273+
263274
@mock.patch('auth0.v3.management.users.RestClient')
264275
def test_unlink_user_account(self, mock_rc):
265276
mock_instance = mock_rc.return_value

0 commit comments

Comments
 (0)