Skip to content

Commit

Permalink
Update members.py (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsatoriu authored Aug 14, 2024
1 parent 94daabb commit 1cda9b2
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions api/endpoints/members.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,20 +525,28 @@ def get(self, endpoint_uri):
maap_user = get_authorized_user()

if maap_user is None:
return Response('Unauthorized', status=401)
return Response('Unauthorized', status=status.HTTP_401_UNAUTHORIZED)
else:
json_response = get_edc_credentials(endpoint_uri=endpoint_uri, user_id=maap_user.id)
edc_response = get_edc_credentials(endpoint_uri=endpoint_uri, user_id=maap_user.id)

try:
edc_response_json = json.loads(edc_response)
response = jsonify(
accessKeyId=edc_response_json['accessKeyId'],
secretAccessKey=edc_response_json['secretAccessKey'],
sessionToken=edc_response_json['sessionToken'],
expiration=edc_response_json['expiration']
)

response = jsonify(
accessKeyId=json_response['accessKeyId'],
secretAccessKey=json_response['secretAccessKey'],
sessionToken=json_response['sessionToken'],
expiration=json_response['expiration']
)
response.headers.add('Access-Control-Allow-Origin', '*')

response.headers.add('Access-Control-Allow-Origin', '*')
return response

return response
except ValueError as ex:
response_body = dict()
response_body["code"] = status.HTTP_500_INTERNAL_SERVER_ERROR
response_body["message"] = edc_response.decode("utf-8")
return response_body, status.HTTP_500_INTERNAL_SERVER_ERROR


@ns.route('/self/awsAccess/workspaceBucket')
Expand Down Expand Up @@ -669,7 +677,7 @@ def get_edc_credentials(endpoint_uri, user_id):
else:
edl_response = edl_federated_request(url=endpoint)

return json.loads(edl_response.content)
return edl_response.content


@ns.route('/pre-approved')
Expand Down

0 comments on commit 1cda9b2

Please sign in to comment.