Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Kontr 2.0
Portal API Backend
Commits
c21ae8f1
Verified
Commit
c21ae8f1
authored
May 19, 2018
by
Peter Stanko
Browse files
Updated Demo
parent
e343dea3
Pipeline
#12628
failed with stage
in 1 minute and 58 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
docs/Demo.adoc
View file @
c21ae8f1
...
...
@@ -53,7 +53,7 @@ To run the backend there are some steps required:
- Set the flask app env variable:
[source, bash]
----
export FLASK_APP='app
.py
'
export FLASK_APP='app
:app
'
----
- Run the migrations
...
...
@@ -64,7 +64,16 @@ flask db upgrade
----
- Initialize the data (users)
[source, bash]
----
flask
init_data admin
flask
data init
----
- Set admin user password
[source, bash]
----
flask users set-password admin
----
portal/rest/auth/gitlab.py
View file @
c21ae8f1
...
...
@@ -15,7 +15,7 @@ log = logging.getLogger(__name__)
def
extract_user_info
(
me
:
dict
)
->
dict
:
log
.
debug
(
f
"[GITLAB] Received info:
{
me
}
"
)
return
dict
(
uco
=
None
,
# TODO: Need from gitlab or prompt the user
uco
=
None
,
name
=
me
[
'name'
],
username
=
me
[
'username'
],
email
=
me
[
'email'
]
...
...
portal/rest/users/users.py
View file @
c21ae8f1
...
...
@@ -156,7 +156,7 @@ class UserRoleList(Resource):
def
get
(
self
,
uid
):
client
=
portal
.
service
.
auth
.
find_client
()
user
=
portal
.
service
.
general
.
find_user
(
uid
)
# authorization
TODO: insufficient?
# authorization
if
not
(
permissions
.
check_component
(
component
=
client
)
or
permissions
.
check_sysadmin
(
client
)
or
client
==
user
):
...
...
@@ -220,7 +220,7 @@ class UserEffectivePermissions(Resource):
def
get
(
self
,
uid
):
client
=
portal
.
service
.
auth
.
find_client
()
user
=
portal
.
service
.
general
.
find_user
(
uid
)
# authorization
TODO - check
# authorization
if
not
(
permissions
.
check_component
(
component
=
client
)
or
permissions
.
check_sysadmin
(
user
)
or
client
==
user
):
...
...
portal/service/auth.py
View file @
c21ae8f1
...
...
@@ -59,6 +59,7 @@ def validate_gitlab_token(token: str, username: str, throws: bool = True):
Returns(Bool):
"""
client
=
gitlab_factory
.
instance
(
oauth_token
=
token
)
client
.
auth
()
user
=
client
.
user
if
user
.
username
!=
username
:
if
throws
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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