From 782befd6ecf9a207dfe2591c12934df6a9092bc6 Mon Sep 17 00:00:00 2001 From: juanifioren Date: Fri, 12 Feb 2016 14:51:43 -0300 Subject: [PATCH] Rename setting. --- oidc_provider/lib/utils/common.py | 3 +-- oidc_provider/lib/utils/token.py | 2 +- oidc_provider/settings.py | 4 ++-- oidc_provider/tests/app/utils.py | 8 ++++---- oidc_provider/tests/test_token_endpoint.py | 8 ++++---- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/oidc_provider/lib/utils/common.py b/oidc_provider/lib/utils/common.py index 3743684..c97c7e8 100644 --- a/oidc_provider/lib/utils/common.py +++ b/oidc_provider/lib/utils/common.py @@ -49,7 +49,7 @@ def default_after_userlogin_hook(request, user, client): """ return None -def additional_id_token_processing_hook(id_token): +def default_idtoken_processing_hook(id_token): """ Hook to perform some additional actions ti `id_token` dictionary just before serialization. @@ -59,4 +59,3 @@ def additional_id_token_processing_hook(id_token): :rtype dict """ return id_token - diff --git a/oidc_provider/lib/utils/token.py b/oidc_provider/lib/utils/token.py index 05eeaa6..67bfb91 100644 --- a/oidc_provider/lib/utils/token.py +++ b/oidc_provider/lib/utils/token.py @@ -44,7 +44,7 @@ def create_id_token(user, aud, nonce): if nonce: dic['nonce'] = str(nonce) - dic = settings.get('OIDC_ID_TOKEN_PROCESSING_HOOK', import_str=True)(dic) + dic = settings.get('OIDC_IDTOKEN_PROCESSING_HOOK', import_str=True)(dic) return dic diff --git a/oidc_provider/settings.py b/oidc_provider/settings.py index 0bae84b..d732d63 100644 --- a/oidc_provider/settings.py +++ b/oidc_provider/settings.py @@ -98,12 +98,12 @@ class DefaultSettings(object): return 'oidc_provider.lib.utils.common.DefaultUserInfo' @property - def OIDC_ID_TOKEN_PROCESSING_HOOK(self): + def OIDC_IDTOKEN_PROCESSING_HOOK(self): """ OPTIONAL. A string with the location of your hook. Used to add extra dictionary values specific for your app into id_token. """ - return 'oidc_provider.lib.utils.common.additional_id_token_processing_hook' + return 'oidc_provider.lib.utils.common.default_idtoken_processing_hook' default_settings = DefaultSettings() diff --git a/oidc_provider/tests/app/utils.py b/oidc_provider/tests/app/utils.py index 0b78eba..a644298 100644 --- a/oidc_provider/tests/app/utils.py +++ b/oidc_provider/tests/app/utils.py @@ -108,9 +108,9 @@ def fake_sub_generator(user): return user.email -def fake_id_token_processing_hook(id_token): +def fake_idtoken_processing_hook(id_token): """ - Fake function for inserting some keys into token. Testing OIDC_ID_TOKEN_PROCESSING_HOOK + Fake function for inserting some keys into token. Testing OIDC_IDTOKEN_PROCESSING_HOOK. """ - id_token['test_id_token_processing_hook'] = FAKE_RANDOM_STRING - return id_token \ No newline at end of file + id_token['test_idtoken_processing_hook'] = FAKE_RANDOM_STRING + return id_token diff --git a/oidc_provider/tests/test_token_endpoint.py b/oidc_provider/tests/test_token_endpoint.py index 8a5047d..0cbc7c3 100644 --- a/oidc_provider/tests/test_token_endpoint.py +++ b/oidc_provider/tests/test_token_endpoint.py @@ -336,10 +336,10 @@ class TokenTestCase(TestCase): self.assertEqual(id_token.get('sub'), self.user.email) - @override_settings(OIDC_ID_TOKEN_PROCESSING_HOOK='oidc_provider.tests.app.utils.fake_id_token_processing_hook') - def test_additional_id_token_processing_hook(self): + @override_settings(OIDC_IDTOKEN_PROCESSING_HOOK='oidc_provider.tests.app.utils.fake_idtoken_processing_hook') + def test_additional_idtoken_processing_hook(self): """ - Test custom function for setting OIDC_ID_TOKEN_PROCESSING_HOOK. + Test custom function for setting OIDC_IDTOKEN_PROCESSING_HOOK. """ code = self._create_code() @@ -350,4 +350,4 @@ class TokenTestCase(TestCase): response_dic = json.loads(response.content.decode('utf-8')) id_token = JWT().unpack(response_dic['id_token'].encode('utf-8')).payload() - self.assertEqual(id_token.get('test_id_token_processing_hook'), FAKE_RANDOM_STRING) + self.assertEqual(id_token.get('test_idtoken_processing_hook'), FAKE_RANDOM_STRING)