Refactoring create_id_token function.

This commit is contained in:
Ignacio Fiorentino 2016-09-09 13:10:12 -03:00
parent 5836774f6b
commit 8a63c83514
7 changed files with 41 additions and 15 deletions

View file

@ -17,7 +17,7 @@ from oidc_provider.models import (
from oidc_provider import settings
def create_id_token(user, aud, nonce, at_hash=None, request=None):
def create_id_token(user, aud, nonce, at_hash=None, request=None, scope=[]):
"""
Creates the id_token dictionary.
See: http://openid.net/specs/openid-connect-core-1_0.html#IDToken
@ -50,7 +50,7 @@ def create_id_token(user, aud, nonce, at_hash=None, request=None):
if at_hash:
dic['at_hash'] = at_hash
if getattr(user, 'email', None):
if ('email' in scope) and getattr(user, 'email', None):
dic['email'] = user.email
processing_hook = settings.get('OIDC_IDTOKEN_PROCESSING_HOOK')