Fix conditional for code expiration.
This commit is contained in:
parent
989b110bf0
commit
9b321fef9a
1 changed files with 2 additions and 6 deletions
|
@ -13,13 +13,11 @@ from oidc_provider import settings
|
||||||
class TokenEndpoint(object):
|
class TokenEndpoint(object):
|
||||||
|
|
||||||
def __init__(self, request):
|
def __init__(self, request):
|
||||||
|
|
||||||
self.request = request
|
self.request = request
|
||||||
self.params = Params()
|
self.params = Params()
|
||||||
self._extract_params()
|
self._extract_params()
|
||||||
|
|
||||||
def _extract_params(self):
|
def _extract_params(self):
|
||||||
|
|
||||||
query_dict = self.request.POST
|
query_dict = self.request.POST
|
||||||
|
|
||||||
self.params.client_id = query_dict.get('client_id', '')
|
self.params.client_id = query_dict.get('client_id', '')
|
||||||
|
@ -31,7 +29,6 @@ class TokenEndpoint(object):
|
||||||
self.params.state = query_dict.get('state', '')
|
self.params.state = query_dict.get('state', '')
|
||||||
|
|
||||||
def validate_params(self):
|
def validate_params(self):
|
||||||
|
|
||||||
if not (self.params.grant_type == 'authorization_code'):
|
if not (self.params.grant_type == 'authorization_code'):
|
||||||
raise TokenError('unsupported_grant_type')
|
raise TokenError('unsupported_grant_type')
|
||||||
|
|
||||||
|
@ -46,8 +43,8 @@ class TokenEndpoint(object):
|
||||||
|
|
||||||
self.code = Code.objects.get(code=self.params.code)
|
self.code = Code.objects.get(code=self.params.code)
|
||||||
|
|
||||||
if not (self.code.client == self.client) and \
|
if not (self.code.client == self.client) \
|
||||||
not self.code.has_expired():
|
or self.code.has_expired():
|
||||||
raise TokenError('invalid_grant')
|
raise TokenError('invalid_grant')
|
||||||
|
|
||||||
except Client.DoesNotExist:
|
except Client.DoesNotExist:
|
||||||
|
@ -57,7 +54,6 @@ class TokenEndpoint(object):
|
||||||
raise TokenError('invalid_grant')
|
raise TokenError('invalid_grant')
|
||||||
|
|
||||||
def create_response_dic(self):
|
def create_response_dic(self):
|
||||||
|
|
||||||
sub = settings.get('OIDC_IDTOKEN_SUB_GENERATOR')(
|
sub = settings.get('OIDC_IDTOKEN_SUB_GENERATOR')(
|
||||||
user=self.code.user)
|
user=self.code.user)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue