summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/endpoint.py
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-05-14 15:17:49 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-05-17 17:06:50 +0200
commit0c6ccca5fac44ab40671627fd3181e9b138672fa (patch)
tree0c0cc4aa53921feeddfd0d1c9111eee9a9c84c54 /opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/endpoint.py
parent17327a642738e0500f9a007b32a46bb4f426f881 (diff)
api: Migrate to Auth0 for API authorization
This change updates the OpenDC API to use Auth0 for API authorization. This removes the hard dependency on Google for logging into OpenDC and simplifies implementation as we do not have to store user information anymore, other than the user identifier.
Diffstat (limited to 'opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/endpoint.py')
-rw-r--r--opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/endpoint.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/endpoint.py b/opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/endpoint.py
index caac37ca..37cf1860 100644
--- a/opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/endpoint.py
+++ b/opendc-web/opendc-web-api/opendc/api/v2/projects/projectId/endpoint.py
@@ -16,7 +16,7 @@ def GET(request):
project = Project.from_id(request.params_path['projectId'])
project.check_exists()
- project.check_user_access(request.google_id, False)
+ project.check_user_access(request.current_user['sub'], False)
return Response(200, 'Successfully retrieved project', project.obj)
@@ -29,7 +29,7 @@ def PUT(request):
project = Project.from_id(request.params_path['projectId'])
project.check_exists()
- project.check_user_access(request.google_id, True)
+ project.check_user_access(request.current_user['sub'], True)
project.set_property('name', request.params_body['project']['name'])
project.set_property('datetime_last_edited', Database.datetime_to_string(datetime.now()))
@@ -46,7 +46,7 @@ def DELETE(request):
project = Project.from_id(request.params_path['projectId'])
project.check_exists()
- project.check_user_access(request.google_id, True)
+ project.check_user_access(request.current_user['sub'], True)
for topology_id in project.obj['topologyIds']:
topology = Topology.from_id(topology_id)
@@ -56,7 +56,7 @@ def DELETE(request):
portfolio = Portfolio.from_id(portfolio_id)
portfolio.delete()
- user = User.from_google_id(request.google_id)
+ user = User.from_google_id(request.current_user['sub'])
user.obj['authorizations'] = list(
filter(lambda x: x['projectId'] != project.get_id(), user.obj['authorizations']))
user.update()