Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
461a987e
Commit
461a987e
authored
Jul 30, 2020
by
Manuel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added role to security token check
parent
cf0da34f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
token_service.py
...tage-discovery-microservice/app/services/token_service.py
+2
-0
security_util.py
src/modules/security/security_util.py
+7
-5
No files found.
src/data-hub/role-stage-discovery-microservice/app/services/token_service.py
View file @
461a987e
from
security
import
security_utils
as
security
def
verifyTokenRegular
(
token
,
required_scopes
):
# TODO call restGateway to verify the token
return
{}
...
...
src/modules/security/security_util.py
View file @
461a987e
...
...
@@ -11,13 +11,15 @@ class TokenStash:
to the user-microservice
'''
trusted_tokens
=
{}
roles
=
{}
@
staticmethod
def
add
(
token
:
str
,
username
:
str
):
def
add
(
token
:
str
,
username
:
str
,
role
:
str
):
'''
adds a verified token to the stash
'''
TokenStash
.
trusted_tokens
[
token
]
=
username
TokenStash
.
roles
[
token
]
=
role
@
staticmethod
def
is_token_cached
(
token
:
str
)
->
str
:
...
...
@@ -25,8 +27,8 @@ class TokenStash:
returns the associated username to a token, None otherwise
'''
if
token
in
TokenStash
.
trusted_tokens
:
return
TokenStash
.
trusted_tokens
[
token
]
if
token
in
TokenStash
.
trusted_tokens
and
token
in
TokenStash
.
roles
:
return
{
"sub"
:
TokenStash
.
trusted_tokens
[
token
],
"role"
:
TokenStash
.
roles
[
token
]}
return
None
...
...
@@ -62,5 +64,5 @@ def decodeToken(token: str) -> Dict:
raise
ValueError
(
f
"Validation of token failed (missing field in verification response)!"
)
TokenStash
.
add
(
token
,
data
[
"username"
])
return
{
"sub"
:
data
[
"username"
]}
TokenStash
.
add
(
token
,
data
[
"username"
]
,
data
[
"role"
]
)
return
{
"sub"
:
data
[
"username"
]
,
"role"
:
data
[
"role"
]
}
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