Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Commit 52c51af

Browse files
committed
fix permissions delivery
1 parent 85e885f commit 52c51af

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

beacon_api/permissions/ga4gh.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,17 @@
9595

9696
async def check_ga4gh_token(decoded_data, token, bona_fide_status, dataset_permissions):
9797
"""Check the token for GA4GH claims."""
98+
LOG.debug('Checking GA4GH claims from scope.')
99+
98100
if 'scope' in decoded_data:
99101
ga4gh_scopes = ['openid', 'ga4gh_passport_v1']
100102
token_scopes = decoded_data.get('scope').split(' ')
101-
LOG.info(f'GA4H Required scopes: {ga4gh_scopes}')
102-
LOG.info(f'Token scopes: {token_scopes}')
103-
LOG.info(f'Bona fide before: {bona_fide_status}')
104-
LOG.info(f'Permissions before: {dataset_permissions}')
103+
105104
if all(scope in token_scopes for scope in ga4gh_scopes):
106105
dataset_permissions, bona_fide_status = await get_ga4gh_permissions(token)
107106

107+
return dataset_permissions, bona_fide_status
108+
108109

109110
async def decode_passport(encoded_passport):
110111
"""Return decoded header and payload from encoded passport JWT.

beacon_api/utils/validate.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,19 +183,13 @@ async def token_middleware(request, handler):
183183
# for now the permissions just reflects that the data can be decoded from token
184184
# the bona fide status is checked against ELIXIR AAI by default or the URL from config
185185
# the bona_fide_status is specific to ELIXIR Tokens
186-
dataset_permissions, bona_fide_status = [], ''
187-
188186
# Retrieve GA4GH Passports from /userinfo and process them into dataset permissions and bona fide status
189-
bona_fide_status = False
190-
dataset_permissions = set()
191-
await check_ga4gh_token(decoded_data, token, bona_fide_status, dataset_permissions)
192-
193-
LOG.info(f'Bona fide after: {bona_fide_status}')
194-
LOG.info(f'Permissions after: {dataset_permissions}')
195-
controlled_datasets = set()
187+
dataset_permissions, bona_fide_status = set(), False
188+
dataset_permissions, bona_fide_status = await check_ga4gh_token(decoded_data, token, bona_fide_status, dataset_permissions)
196189
# currently we offer module for parsing GA4GH permissions, but multiple claims and providers can be utilised
197190
# by updating the set, meaning replicating the line below with the permissions function and its associated claim
198191
# For GA4GH DURI permissions (ELIXIR Permissions API 2.0)
192+
controlled_datasets = set()
199193
controlled_datasets.update(dataset_permissions)
200194
all_controlled = list(controlled_datasets) if bool(controlled_datasets) else None
201195
request["token"] = {"bona_fide_status": bona_fide_status,

0 commit comments

Comments
 (0)