Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
main
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Simone Rossi
main
Commits
d25a217c
Commit
d25a217c
authored
Sep 17, 2018
by
Daniele Venzano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Pylint errors
parent
a1d0024a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
9 deletions
+7
-9
zoe_api/auth/base.py
zoe_api/auth/base.py
+0
-4
zoe_api/auth/requests_oauth2/errors.py
zoe_api/auth/requests_oauth2/errors.py
+2
-0
zoe_api/auth/requests_oauth2/oauth2.py
zoe_api/auth/requests_oauth2/oauth2.py
+2
-2
zoe_api/rest_api/user.py
zoe_api/rest_api/user.py
+3
-3
No files found.
zoe_api/auth/base.py
View file @
d25a217c
...
...
@@ -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
...
...
zoe_api/auth/requests_oauth2/errors.py
View file @
d25a217c
...
...
@@ -2,8 +2,10 @@
class
OAuth2Error
(
Exception
):
"""OAuth error."""
pass
class
ConfigurationError
(
OAuth2Error
):
"""OAuth configuration error."""
pass
zoe_api/auth/requests_oauth2/oauth2.py
View file @
d25a217c
...
...
@@ -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
"""
...
...
zoe_api/rest_api/user.py
View file @
d25a217c
...
...
@@ -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
:
r
esp
=
requests
.
get
(
egitlab
.
userinfo_url
,
headers
=
{
'Authorization'
:
'Bearer {}'
.
format
(
token
[
'access_token'
])})
if
r
esp
.
status_code
!=
200
:
self
.
redirect
(
self
.
reverse_url
(
"login"
))
return
data
=
r
.
json
()
data
=
r
esp
.
json
()
email
=
data
[
'email'
]
username
=
data
[
'nickname'
]
user
=
self
.
api_endpoint
.
user_by_name
(
username
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment