From ba7b8e70a8929a75b12c16641b460484324b0889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oriol=20L=C3=B3pez-Doriga?= Date: Mon, 30 Oct 2023 09:23:31 +0100 Subject: [PATCH] adding permissions for every user and permissions from conf --- beacon/conf.py | 2 +- beacon/db/extract_filtering_terms.py | 30 ++++++++++++++++++++++++++++ beacon/utils/auth.py | 2 +- deploy/conf.py | 2 +- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/beacon/conf.py b/beacon/conf.py index 6bc9c6ea..0e8f3433 100644 --- a/beacon/conf.py +++ b/beacon/conf.py @@ -102,7 +102,7 @@ # # Permissions server configuration # -permissions_url = 'http://beacon-permissions' +permissions_url = 'http://beacon-permissions:5051/' #permissions_url = 'http://localhost:5051/' # diff --git a/beacon/db/extract_filtering_terms.py b/beacon/db/extract_filtering_terms.py index bd8138f9..05e1f7ba 100644 --- a/beacon/db/extract_filtering_terms.py +++ b/beacon/db/extract_filtering_terms.py @@ -20,14 +20,44 @@ import numpy as np from utils import get_filtering_documents +import sys +import os + + +current = os.path.dirname(os.path.realpath(__file__)) + + +parent = os.path.dirname(current) + + +sys.path.append(parent) + + +import conf + ONTOLOGY_REGEX = re.compile(r"([_A-Za-z0-9]+):([_A-Za-z0-9^\-]+)") +client = MongoClient( + #"mongodb://127.0.0.1:27017/" + "mongodb://{}:{}@{}:{}/{}?authSource={}".format( + conf.database_user, + conf.database_password, + conf.database_host, + conf.database_port, + conf.database_name, + conf.database_auth_source, + ) + ) + +''' +client = MongoClient( client = MongoClient( #"mongodb://127.0.0.1:27017/" "mongodb://root:example@mongo:27017/beacon?authSource=admin" ) +''' class MyProgressBar: def __init__(self): diff --git a/beacon/utils/auth.py b/beacon/utils/auth.py index 4a6d0c6e..b569748f 100644 --- a/beacon/utils/auth.py +++ b/beacon/utils/auth.py @@ -27,7 +27,7 @@ async def resolve_token(token, requested_datasets_ids): # * return _all_ the datasets the user has access to, in case the datasets list is empty async with ClientSession() as session: async with session.post( - 'http://beacon-permissions:5051/', + permissions_url, headers={'Authorization': 'Bearer ' + token, 'Accept': 'application/json'}, json={'datasets': requested_datasets_ids}, # will set the Content-Type to application/json diff --git a/deploy/conf.py b/deploy/conf.py index 22317a96..3ab4a36d 100644 --- a/deploy/conf.py +++ b/deploy/conf.py @@ -99,7 +99,7 @@ # # Permissions server configuration # -permissions_url = 'http://beacon-permissions' +permissions_url = 'http://beacon-permissions:5051/' # # IdP endpoints (OpenID Connect/Oauth2)