Add setup to extra scope claims.

This commit is contained in:
juanifioren 2015-03-06 12:54:27 -03:00
parent 2a7cf82cd4
commit e3b5af5490
2 changed files with 9 additions and 7 deletions

7
doc.md
View file

@ -99,12 +99,11 @@ from oidc_provider.lib.claims import AbstractScopeClaims
class MyAppScopeClaims(AbstractScopeClaims):
def __init__(self, user, scopes):
# Don't forget this.
super(StandardScopeClaims, self).__init__(user, scopes)
def setup(self):
# Here you can load models that will be used
# in more than one scope for example.
# print self.user
# print self.scopes
try:
self.some_model = SomeModel.objects.get(user=self.user)
except UserInfo.DoesNotExist:

View file

@ -8,6 +8,11 @@ class AbstractScopeClaims(object):
self.user = user
self.scopes = scopes
self.setup()
def setup(self):
pass
def create_response_dic(self):
"""
Generate the dic that will be jsonify. Checking scopes given vs
@ -61,9 +66,7 @@ class StandardScopeClaims(AbstractScopeClaims):
See: http://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
"""
def __init__(self, user, scopes):
super(StandardScopeClaims, self).__init__(user, scopes)
def setup(self):
try:
self.userinfo = UserInfo.objects.get(user=self.user)
except UserInfo.DoesNotExist: