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
72f8b967
Commit
72f8b967
authored
Aug 04, 2020
by
manuel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes in token_service.py
parent
73c9bb09
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
7 deletions
+24
-7
token_service.py
...tage-discovery-microservice/app/services/token_service.py
+14
-1
network_constants.py
src/modules/network_constants.py
+4
-4
security_util.py
src/modules/security/security_util.py
+6
-2
No files found.
src/data-hub/role-stage-discovery-microservice/app/services/token_service.py
View file @
72f8b967
from
security
import
security_util
import
logging
def
verifyTokenRegular
(
token
,
required_scopes
):
return
security_util
.
decodeToken
(
token
)
print
(
"gonna verify token: "
+
token
)
LOGGER
=
logging
.
getLogger
(
__name__
)
try
:
token_info
=
security_util
.
decodeToken
(
token
)
print
(
"TOKEN INFO: "
+
str
(
token_info
))
LOGGER
.
info
(
"TOKEN INFO: "
+
str
(
token_info
))
return
token_info
except
Exception
as
e
:
print
(
"ERROR DURING TOKEN VALIDATION: "
+
str
(
e
))
LOGGER
.
error
(
"ERROR DURING TOKEN VALIDATION: "
+
str
(
e
))
return
None
def
verifyTokenAdmin
(
token
,
required_scopes
):
# TODO call restGateway to verify the token
...
...
src/modules/network_constants.py
View file @
72f8b967
...
...
@@ -18,9 +18,9 @@ SEMANTIC_LINKING_DB_PORT = 27017
## Role Stage Discovery
ROLESTAGE_DISCOVERY_HOSTNAME
=
'role-stage-discovery'
ROLESTAGE_DISCOVERY_REST_PORT
=
80
ROLESTAGE_DISCOVERY_DB_HOSTNAME
=
f
'
{ROLESTAGE_DISCOVERY_HOSTNAME}-db
'
ROLESTAGE_DISCOVERY_DB_PORT
=
27017
ROLESTAGE_DISCOVERY_REST_PORT
=
30103
ROLESTAGE_DISCOVERY_DB_HOSTNAME
=
f
'
articonf1.itec.aau.at
'
ROLESTAGE_DISCOVERY_DB_PORT
=
30104
## Rest Gateway
# REST_GATEWAY_HOSTNAME = 'rest-gateway'
...
...
@@ -28,4 +28,4 @@ ROLESTAGE_DISCOVERY_DB_PORT = 27017
REST_GATEWAY_HOSTNAME
=
'articonf1.itec.aau.at'
REST_GATEWAY_REST_PORT
=
30401
REST_GATEWAY_DB_HOSTNAME
=
'articonf1.itec.aau.at'
REST_GATEWAY_DB_PORT
=
30402
\ No newline at end of file
REST_GATEWAY_DB_PORT
=
30402
src/modules/security/security_util.py
View file @
72f8b967
...
...
@@ -51,8 +51,12 @@ def decodeToken(token: str) -> Dict:
raise
ValueError
(
'Invalid JWT token (must be a Bearer string)'
)
token
=
token
[
7
:]
response
=
requests
.
get
(
f
'https://{REST_GATEWAY_HOSTNAME}/api/tokens/{token}'
)
response
=
requests
.
post
(
f
'https://{network_constants.REST_GATEWAY_HOSTNAME}:{network_constants.REST_GATEWAY_REST_PORT}/api/tokens/{token}'
,
verify
=
False
,
headers
=
{
'User-Agent'
:
'Chrome'
,
'Accept'
:
'application/json'
,
'Content-Type'
:
'application/json'
},
proxies
=
{
"http"
:
"http://proxy.uni-klu.ac.at:3128/"
,
"https"
:
"http://proxy.uni-klu.ac.at:3128/"
}
)
if
response
.
status_code
!=
200
:
raise
ValueError
(
...
...
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