Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed introspection #378

Merged
merged 4 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion beacon/api_version.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
api_version: v2.0-19c610e
api_version: v2.0-8917c2a
26 changes: 5 additions & 21 deletions beacon/db/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@

def cross_query(query: dict, scope: str, collection: str, request_parameters: dict):
if scope == 'genomicVariation' and collection == 'g_variants' or scope == collection[0:-1]:
LOG.debug(query)
LOG.debug(request_parameters)
subquery={}
subquery["$or"]=[]
if request_parameters != {}:
biosample_ids = client.beacon.genomicVariations.find(request_parameters, {"caseLevelData.biosampleId": 1, "_id": 0})
final_id='id'
final_id='caseLevelData.biosampleId'
original_id="biosampleId"
def_list=[]
for iditem in biosample_ids:
Expand All @@ -36,30 +34,16 @@ def cross_query(query: dict, scope: str, collection: str, request_parameters: di
new_id={}
new_id[final_id] = id_item[original_id]
try:
#LOG.debug(new_id)
subquery['$or'].append(new_id)
except Exception:
except Exception:# pragma: no cover
def_list.append(new_id)

LOG.debug(subquery)
mongo_collection=client.beacon.biosamples
original_id="individualId"
join_ids2=list(join_query(mongo_collection, subquery, original_id))
def_list=[]
final_id="id"
for id_item in join_ids2:
new_id={}
new_id[final_id] = id_item.pop(original_id)
def_list.append(new_id)
subquery={}
subquery['$or']=def_list
subquery={}
subquery['$or']=def_list
try:
LOG.debug(query)
query["$and"] = []
query["$and"].append(subquery)
except Exception:
LOG.debug(query)
LOG.debug(query)
pass
else:
def_list=[]
if scope == 'individual' and collection == 'g_variants':
Expand Down
6 changes: 5 additions & 1 deletion permissions/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ async def get_user_info(access_token):
LOG.error(user_info)
user = None

'''
async with ClientSession() as session:
async with session.post(idp_introspection,
auth=BasicAuth(idp_client_id, password=idp_client_secret),
Expand All @@ -117,6 +118,7 @@ async def get_user_info(access_token):
LOG.error('Invalid token')
user = 'public'
return user, list_visa_datasets
'''

async with ClientSession(trust_env=True) as session:
headers = { 'Accept': 'application/json', 'Authorization': 'Bearer ' + access_token }
Expand All @@ -125,6 +127,7 @@ async def get_user_info(access_token):
LOG.error('Response %s', resp)
if resp.status == 200:
user = await resp.json()
LOG.error(user)
try:
visa_datasets = user['ga4gh_passport_v1']
if visa_datasets is not None:
Expand Down Expand Up @@ -165,6 +168,7 @@ async def decorated(request):
# We make a round-trip to the userinfo. We might not have a JWT token.
try:
user, list_visa_datasets = await get_user_info(access_token)
LOG.error(user)
except Exception:
user = 'public'
LOG.info('The user is: %r', user)
Expand All @@ -174,7 +178,7 @@ async def decorated(request):
username = 'public'
else:
username = user.get('preferred_username')
LOG.debug('username: %s', username)
LOG.error('username: %s', username)

return await func(request, username, list_visa_datasets)
return decorated
Loading