Skip to content
Snippets Groups Projects
Commit e01063e3 authored by kaiyou's avatar kaiyou
Browse files

Use a hack to access the client object from the OIDC Code Mixin

parent 96621ca0
No related branches found
No related tags found
No related merge requests found
...@@ -103,14 +103,17 @@ class OpenIDMixin(object): ...@@ -103,14 +103,17 @@ class OpenIDMixin(object):
def exists_nonce(self, nonce, request): def exists_nonce(self, nonce, request):
return bool(utils.redis.get("nonce:{}".format(nonce))) return bool(utils.redis.get("nonce:{}".format(nonce)))
def get_client(self):
# TODO: this is a terribly ugly hack meant only as a temporary measure
# waiting for authlib to merge our PRs allowing a more generic way of
# always having the current client in the context.
return inspect.currentframe().f_back.f_back.f_back.f_locals["self"].client
def get_jwt_config(self, grant=None): def get_jwt_config(self, grant=None):
# In the case of AuthorizationCode, the current object is not the grant return self.get_client().get_jwt_config()
# but a grant extension, so the client is retrieved through the grant argument
client = self.request.client if grant is None else grant.client
return client.get_jwt_config()
def generate_user_info(self, user, scope): def generate_user_info(self, user, scope):
return Client.generate_user_info(user, scope) return self.get_client().generate_user_info(user, scope)
class Client(sqla_oauth2.OAuth2ClientMixin): class Client(sqla_oauth2.OAuth2ClientMixin):
...@@ -157,8 +160,7 @@ class Client(sqla_oauth2.OAuth2ClientMixin): ...@@ -157,8 +160,7 @@ class Client(sqla_oauth2.OAuth2ClientMixin):
'exp': 3600, 'exp': 3600,
} }
@classmethod def generate_user_info(self, user, scope):
def generate_user_info(cls, user, scope):
""" User info generation function used by the oidc code mixin and the userinfo endpoint """ User info generation function used by the oidc code mixin and the userinfo endpoint
""" """
return oidc.UserInfo( return oidc.UserInfo(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment