Skip to content

Commit

Permalink
Merge pull request #311 from CanDIG/daisieh/no-service-token
Browse files Browse the repository at this point in the history
Don't pass in OPA_SECRET anymore
  • Loading branch information
daisieh authored May 28, 2024
2 parents 3423c92 + 14d9270 commit bf50265
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
1 change: 0 additions & 1 deletion config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ DBPath = sqlite:///./data/files.db
PGPath = postgresql+psycopg2://<POSTGRES_USERNAME>:PASSWORD@HOST:5432/genomic

[authz]
CANDIG_OPA_SECRET = <CANDIG_OPA_SECRET>
CANDIG_OPA_URL = <OPA_URL>
CANDIG_VAULT_URL = <VAULT_URL>
2 changes: 0 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

set -Euo pipefail

export OPA_SECRET=$(cat /run/secrets/opa-service-token)
export VAULT_URL=$VAULT_URL
export AGGREGATE_COUNT_THRESHOLD=$AGGREGATE_COUNT_THRESHOLD

if [[ -f "initial_setup" ]]; then
sed -i s@\<CANDIG_OPA_SECRET\>@$OPA_SECRET@ config.ini
sed -i s@\<OPA_URL\>@$OPA_URL@ config.ini
sed -i s@\<VAULT_URL\>@$VAULT_URL@ config.ini
sed -i s@\<AGGREGATE_COUNT_THRESHOLD\>@$AGGREGATE_COUNT_THRESHOLD@ config.ini
Expand Down
6 changes: 3 additions & 3 deletions htsget_server/authz.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_authorized_cohorts(request):
if is_testing(request):
return []
try:
return authx.auth.get_opa_datasets(request, admin_secret=AUTHZ['CANDIG_OPA_SECRET'])
return authx.auth.get_opa_datasets(request)
except Exception as e:
print(f"Couldn't authorize cohorts: {type(e)} {str(e)}")
app.logger.warning(f"Couldn't authorize cohorts: {type(e)} {str(e)}")
Expand All @@ -47,7 +47,7 @@ def get_authorized_cohorts(request):
def is_cohort_authorized(request, cohort_id):
if is_testing(request):
return True
return authx.auth.is_action_allowed_for_program(authx.auth.get_auth_token(request), method=request.method, path=request.path, program=cohort_id, admin_secret=AUTHZ['CANDIG_OPA_SECRET'])
return authx.auth.is_action_allowed_for_program(authx.auth.get_auth_token(request), method=request.method, path=request.path, program=cohort_id)


def is_site_admin(request):
Expand All @@ -58,7 +58,7 @@ def is_site_admin(request):
return True
if "Authorization" in request.headers:
try:
return authx.auth.is_site_admin(request, admin_secret=AUTHZ['CANDIG_OPA_SECRET'])
return authx.auth.is_site_admin(request)
except Exception as e:
print(f"Couldn't authorize site_admin: {type(e)} {str(e)}")
app.logger.warning(f"Couldn't authorize site_admin: {type(e)} {str(e)}")
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pysam==0.22.0
sqlalchemy==1.4.44
connexion==2.14.1
MarkupSafe==2.1.1
candigv2-authx@git+https://github.com/CanDIG/[email protected].1
candigv2-authx@git+https://github.com/CanDIG/[email protected].2
pytest==7.2.0
uwsgi==2.0.23
connexion[swagger-ui]
Expand Down

0 comments on commit bf50265

Please sign in to comment.