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
2078b53e
Commit
2078b53e
authored
Aug 05, 2020
by
Manuel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved token_service into modules/
parent
1b00f4c9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
24 deletions
+18
-24
token_service.py
...tage-discovery-microservice/app/services/token_service.py
+0
-21
security.yml
src/modules/security/security.yml
+2
-2
security_util.py
src/modules/security/security_util.py
+16
-1
No files found.
src/data-hub/role-stage-discovery-microservice/app/services/token_service.py
deleted
100644 → 0
View file @
1b00f4c9
# global import
from
security
import
security_util
from
typing
import
List
import
logging
def
_verify
(
token
:
str
,
roles
:
List
[
str
]
=
[]):
try
:
token_info
=
security_util
.
decodeToken
(
token
,
roles
=
roles
)
return
token_info
except
Exception
as
e
:
LOGGER
=
logging
.
getLogger
(
__name__
)
LOGGER
.
error
(
"ERROR DURING TOKEN VALIDATION: "
+
str
(
e
))
return
None
def
verifyTokenRegular
(
token
,
required_scopes
):
return
_verify
(
token
)
def
verifyTokenAdmin
(
token
,
required_scopes
):
return
_verify
(
token
,
roles
=
[
"a"
])
src/modules/security/security.yml
View file @
2078b53e
...
@@ -3,9 +3,9 @@ securityDefinitions:
...
@@ -3,9 +3,9 @@ securityDefinitions:
type
:
apiKey
type
:
apiKey
name
:
Authorization
name
:
Authorization
in
:
header
in
:
header
x-apikeyInfoFunc
:
"
se
rvices.token_service
.verifyTokenRegular"
x-apikeyInfoFunc
:
"
se
curity_util
.verifyTokenRegular"
JwtAdmin
:
JwtAdmin
:
type
:
apiKey
type
:
apiKey
name
:
Authorization
name
:
Authorization
in
:
header
in
:
header
x-apikeyInfoFunc
:
"
se
rvices.token_service
.verifyTokenAdmin"
x-apikeyInfoFunc
:
"
se
curity_util
.verifyTokenAdmin"
src/modules/security/security_util.py
View file @
2078b53e
...
@@ -76,3 +76,18 @@ def decodeToken(token: str, roles:List[str]=[]) -> Dict:
...
@@ -76,3 +76,18 @@ def decodeToken(token: str, roles:List[str]=[]) -> Dict:
TokenStash
.
add
(
token
,
data
[
"username"
],
data
[
"role"
])
TokenStash
.
add
(
token
,
data
[
"username"
],
data
[
"role"
])
return
{
"sub"
:
data
[
"username"
],
"role"
:
data
[
"role"
]}
return
{
"sub"
:
data
[
"username"
],
"role"
:
data
[
"role"
]}
def
_verify
(
token
:
str
,
roles
:
List
[
str
]
=
[]):
try
:
token_info
=
decodeToken
(
token
,
roles
=
roles
)
return
token_info
except
Exception
as
e
:
print
(
"ERROR DURING TOKEN VALIDATION: "
+
str
(
e
))
return
None
def
verifyTokenRegular
(
token
,
required_scopes
):
return
_verify
(
token
)
def
verifyTokenAdmin
(
token
,
required_scopes
):
return
_verify
(
token
,
roles
=
[
"a"
])
\ No newline at end of file
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