Merge pull request #85 from nmohoric/set-log-level

Changed logging from error to debug.
This commit is contained in:
Juan Ignacio Fiorentino 2016-03-17 18:57:39 -03:00
commit af3a0c0581
3 changed files with 16 additions and 16 deletions

View file

@ -60,15 +60,15 @@ class AuthorizeEndpoint(object):
try: try:
self.client = Client.objects.get(client_id=self.params.client_id) self.client = Client.objects.get(client_id=self.params.client_id)
except Client.DoesNotExist: except Client.DoesNotExist:
logger.error('[Authorize] Invalid client identifier: %s', self.params.client_id) logger.debug('[Authorize] Invalid client identifier: %s', self.params.client_id)
raise ClientIdError() raise ClientIdError()
if self.is_authentication and not self.params.redirect_uri: if self.is_authentication and not self.params.redirect_uri:
logger.error('[Authorize] Missing redirect uri.') logger.debug('[Authorize] Missing redirect uri.')
raise RedirectUriError() raise RedirectUriError()
if not self.grant_type: if not self.grant_type:
logger.error('[Authorize] Invalid response type: %s', self.params.response_type) logger.debug('[Authorize] Invalid response type: %s', self.params.response_type)
raise AuthorizeError(self.params.redirect_uri, 'unsupported_response_type', raise AuthorizeError(self.params.redirect_uri, 'unsupported_response_type',
self.grant_type) self.grant_type)
@ -83,7 +83,7 @@ class AuthorizeEndpoint(object):
clean_redirect_uri = urlsplit(self.params.redirect_uri) clean_redirect_uri = urlsplit(self.params.redirect_uri)
clean_redirect_uri = urlunsplit(clean_redirect_uri._replace(query='')) clean_redirect_uri = urlunsplit(clean_redirect_uri._replace(query=''))
if not (clean_redirect_uri in self.client.redirect_uris): if not (clean_redirect_uri in self.client.redirect_uris):
logger.error('[Authorize] Invalid redirect uri: %s', self.params.redirect_uri) logger.debug('[Authorize] Invalid redirect uri: %s', self.params.redirect_uri)
raise RedirectUriError() raise RedirectUriError()
@ -138,7 +138,7 @@ class AuthorizeEndpoint(object):
query_fragment['state'] = self.params.state if self.params.state else '' query_fragment['state'] = self.params.state if self.params.state else ''
except Exception as error: except Exception as error:
logger.error('[Authorize] Error when trying to create response uri: %s', error) logger.debug('[Authorize] Error when trying to create response uri: %s', error)
raise AuthorizeError( raise AuthorizeError(
self.params.redirect_uri, self.params.redirect_uri,
'server_error', 'server_error',

View file

@ -65,34 +65,34 @@ class TokenEndpoint(object):
try: try:
self.client = Client.objects.get(client_id=self.params.client_id) self.client = Client.objects.get(client_id=self.params.client_id)
except Client.DoesNotExist: except Client.DoesNotExist:
logger.error('[Token] Client does not exist: %s', self.params.client_id) logger.debug('[Token] Client does not exist: %s', self.params.client_id)
raise TokenError('invalid_client') raise TokenError('invalid_client')
if not (self.client.client_secret == self.params.client_secret): if not (self.client.client_secret == self.params.client_secret):
logger.error('[Token] Invalid client secret: client %s do not have secret %s', logger.debug('[Token] Invalid client secret: client %s do not have secret %s',
self.client.client_id, self.client.client_secret) self.client.client_id, self.client.client_secret)
raise TokenError('invalid_client') raise TokenError('invalid_client')
if self.params.grant_type == 'authorization_code': if self.params.grant_type == 'authorization_code':
if not (self.params.redirect_uri in self.client.redirect_uris): if not (self.params.redirect_uri in self.client.redirect_uris):
logger.error('[Token] Invalid redirect uri: %s', self.params.redirect_uri) logger.debug('[Token] Invalid redirect uri: %s', self.params.redirect_uri)
raise TokenError('invalid_client') raise TokenError('invalid_client')
try: try:
self.code = Code.objects.get(code=self.params.code) self.code = Code.objects.get(code=self.params.code)
except Code.DoesNotExist: except Code.DoesNotExist:
logger.error('[Token] Code does not exist: %s', self.params.code) logger.debug('[Token] Code does not exist: %s', self.params.code)
raise TokenError('invalid_grant') raise TokenError('invalid_grant')
if not (self.code.client == self.client) \ if not (self.code.client == self.client) \
or self.code.has_expired(): or self.code.has_expired():
logger.error('[Token] Invalid code: invalid client or code has expired', logger.debug('[Token] Invalid code: invalid client or code has expired',
self.params.redirect_uri) self.params.redirect_uri)
raise TokenError('invalid_grant') raise TokenError('invalid_grant')
elif self.params.grant_type == 'refresh_token': elif self.params.grant_type == 'refresh_token':
if not self.params.refresh_token: if not self.params.refresh_token:
logger.error('[Token] Missing refresh token') logger.debug('[Token] Missing refresh token')
raise TokenError('invalid_grant') raise TokenError('invalid_grant')
try: try:
@ -100,11 +100,11 @@ class TokenEndpoint(object):
client=self.client) client=self.client)
except Token.DoesNotExist: except Token.DoesNotExist:
logger.error('[Token] Refresh token does not exist: %s', self.params.refresh_token) logger.debug('[Token] Refresh token does not exist: %s', self.params.refresh_token)
raise TokenError('invalid_grant') raise TokenError('invalid_grant')
else: else:
logger.error('[Token] Invalid grant type: %s', self.params.grant_type) logger.debug('[Token] Invalid grant type: %s', self.params.grant_type)
raise TokenError('unsupported_grant_type') raise TokenError('unsupported_grant_type')
def create_response_dic(self): def create_response_dic(self):

View file

@ -42,15 +42,15 @@ def protected_resource_view(scopes=[]):
try: try:
kwargs['token'] = Token.objects.get(access_token=access_token) kwargs['token'] = Token.objects.get(access_token=access_token)
except Token.DoesNotExist: except Token.DoesNotExist:
logger.error('[UserInfo] Token does not exist: %s', access_token) logger.debug('[UserInfo] Token does not exist: %s', access_token)
raise BearerTokenError('invalid_token') raise BearerTokenError('invalid_token')
if kwargs['token'].has_expired(): if kwargs['token'].has_expired():
logger.error('[UserInfo] Token has expired: %s', access_token) logger.debug('[UserInfo] Token has expired: %s', access_token)
raise BearerTokenError('invalid_token') raise BearerTokenError('invalid_token')
if not set(scopes).issubset(set(kwargs['token'].scope)): if not set(scopes).issubset(set(kwargs['token'].scope)):
logger.error('[UserInfo] Missing openid scope.') logger.debug('[UserInfo] Missing openid scope.')
raise BearerTokenError('insufficient_scope') raise BearerTokenError('insufficient_scope')
except (BearerTokenError) as error: except (BearerTokenError) as error:
response = HttpResponse(status=error.status) response = HttpResponse(status=error.status)