Conflicts:
	oidc_provider/lib/utils/common.py
	oidc_provider/lib/utils/token.py
This commit is contained in:
Ignacio 2016-02-25 10:10:07 -03:00
commit a4d5f89536
5 changed files with 16 additions and 2 deletions

1
.gitignore vendored
View file

@ -9,3 +9,4 @@ dist/
src/
.venv
.idea
docs/_build/

View file

@ -96,7 +96,16 @@ OIDC_IDTOKEN_PROCESSING_HOOK
============================
OPTIONAL. ``str``. A string with the location of your function hook.
here you can add extra dictionary values specific for your app into id_token.
Here you can add extra dictionary values specific for your app into id_token.
The function receives a ``id_token`` dictionary and ``user`` instance
and returns it with additional fields.
Default is::
def default_idtoken_processing_hook(id_token, user):
return id_token
OIDC_IDTOKEN_SUB_GENERATOR
==========================

View file

@ -55,8 +55,10 @@ def default_idtoken_processing_hook(id_token, user):
:param id_token: dictionary contains values that going to be serialized into `id_token`
:type id_token: dict
:param user: user for whom id_token is generated
:type user: User
:return: custom modified dictionary of values for `id_token`
:rtype dict
"""

View file

@ -108,9 +108,10 @@ def fake_sub_generator(user):
return user.email
def fake_idtoken_processing_hook(id_token):
def fake_idtoken_processing_hook(id_token, user):
"""
Fake function for inserting some keys into token. Testing OIDC_IDTOKEN_PROCESSING_HOOK.
"""
id_token['test_idtoken_processing_hook'] = FAKE_RANDOM_STRING
id_token['test_idtoken_processing_hook_user_email'] = user.email
return id_token

View file

@ -352,3 +352,4 @@ class TokenTestCase(TestCase):
id_token = JWT().unpack(response_dic['id_token'].encode('utf-8')).payload()
self.assertEqual(id_token.get('test_idtoken_processing_hook'), FAKE_RANDOM_STRING)
self.assertEqual(id_token.get('test_idtoken_processing_hook_user_email'), self.user.email)