Commit d25a217c authored by Daniele Venzano's avatar Daniele Venzano

Fix Pylint errors

parent a1d0024a
......@@ -51,10 +51,6 @@ class BaseAuthenticator:
return user
elif user.auth_source == "pam" and pam_authenticate(username, password):
return user
elif user.auth_source == "oauth2":
egitlab = EurecomGitLabClient(client_id=get_conf().oauth_client_id, client_secret=get_conf().oauth_client_secret, redirect_uri=get_conf().oauth_redirect_uri)
auth_url = egitlab.authorize_url(scope=['openid', 'read_user'], response_type='code')
else:
return None
......
......@@ -2,8 +2,10 @@
class OAuth2Error(Exception):
"""OAuth error."""
pass
class ConfigurationError(OAuth2Error):
"""OAuth configuration error."""
pass
......@@ -7,7 +7,7 @@ import requests
from .errors import ConfigurationError
class OAuth2(object):
class OAuth2:
"""Main OAuth2 class."""
client_id = None
client_secret = None
......@@ -20,7 +20,7 @@ class OAuth2(object):
def __init__(self, client_id=None, client_secret=None, site=None,
redirect_uri=None, authorization_url=None,
token_url=None, revoke_url=None, scope_sep=None):
token_url=None, revoke_url=None, scope_sep=None): # pylint: disable=too-many-arguments
"""
Initializes the hook with OAuth2 parameters
"""
......
......@@ -164,11 +164,11 @@ class UserOAuthCallbackAPI(ZoeAPIRequestHandler):
egitlab = EurecomGitLabClient(client_id=zoe_lib.config.get_conf().oauth_client_id, client_secret=zoe_lib.config.get_conf().oauth_client_secret, redirect_uri=zoe_lib.config.get_conf().oauth_redirect_uri)
token = egitlab.get_token(code=code, grant_type="authorization_code")
r = requests.get(egitlab.userinfo_url, headers={'Authorization': 'Bearer {}'.format(token['access_token'])})
if r.status_code != 200:
resp = requests.get(egitlab.userinfo_url, headers={'Authorization': 'Bearer {}'.format(token['access_token'])})
if resp.status_code != 200:
self.redirect(self.reverse_url("login"))
return
data = r.json()
data = resp.json()
email = data['email']
username = data['nickname']
user = self.api_endpoint.user_by_name(username)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment