Rename setting.

This commit is contained in:
juanifioren 2016-02-12 14:51:43 -03:00
parent 73b1cb1efb
commit 782befd6ec
5 changed files with 12 additions and 13 deletions

View file

@ -49,7 +49,7 @@ def default_after_userlogin_hook(request, user, client):
""" """
return None 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. 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 :rtype dict
""" """
return id_token return id_token

View file

@ -44,7 +44,7 @@ def create_id_token(user, aud, nonce):
if nonce: if nonce:
dic['nonce'] = str(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 return dic

View file

@ -98,12 +98,12 @@ class DefaultSettings(object):
return 'oidc_provider.lib.utils.common.DefaultUserInfo' return 'oidc_provider.lib.utils.common.DefaultUserInfo'
@property @property
def OIDC_ID_TOKEN_PROCESSING_HOOK(self): def OIDC_IDTOKEN_PROCESSING_HOOK(self):
""" """
OPTIONAL. A string with the location of your hook. OPTIONAL. A string with the location of your hook.
Used to add extra dictionary values specific for your app into id_token. 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() default_settings = DefaultSettings()

View file

@ -108,9 +108,9 @@ def fake_sub_generator(user):
return user.email 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 id_token['test_idtoken_processing_hook'] = FAKE_RANDOM_STRING
return id_token return id_token

View file

@ -336,10 +336,10 @@ class TokenTestCase(TestCase):
self.assertEqual(id_token.get('sub'), self.user.email) 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') @override_settings(OIDC_IDTOKEN_PROCESSING_HOOK='oidc_provider.tests.app.utils.fake_idtoken_processing_hook')
def test_additional_id_token_processing_hook(self): 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() code = self._create_code()
@ -350,4 +350,4 @@ class TokenTestCase(TestCase):
response_dic = json.loads(response.content.decode('utf-8')) response_dic = json.loads(response.content.decode('utf-8'))
id_token = JWT().unpack(response_dic['id_token'].encode('utf-8')).payload() 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)