Commit 03730d57 authored by Jonathan Schaeffer's avatar Jonathan Schaeffer

Merge branch 'fix-2' into 'master'

Fix 2

Closes #2

See merge request resif/ws-eidaauth!1
parents d6bc8627 c52a1d79
image: python:3.7-alpine
# test:
# script:
# - apk add --no-cache postgresql-libs gnupg
# - apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev
# - pip install -r requirements.txt
# - pip install pytest-cov
# - pip install --editable .
# - pytest --cov=eidawsauth
deploy test:
stage: deploy
tags:
- deploy-eidawsauth
script:
- rsync -a --exclude .git* $CI_PROJECT_DIR /srv/deploy/
- sudo docker restart eidawsauth-dev
......@@ -202,6 +202,14 @@ def auth():
return Response('Token is expired. Please generate a new one at https://geofon.gfz-potsdam.de/eas/', status=415)
logging.info("Token is valid")
# Compute a random login and password
login = ''.join(random.choices(string.ascii_uppercase + string.digits, k=14))
password = ''.join(random.choices(string.ascii_uppercase + string.digits, k=14))
# Register login
register_login(login, password)
# Store in PRIVILEGEDB
# Check membership and get FDSN references
fdsn_memberships = []
for em in tokendict['memberof'].split(';'):
......@@ -209,22 +217,11 @@ def auth():
if em in application.config['EPOS_FDSN_MAP']:
logging.debug(" ... is in epos fdsn map")
fdsn_memberships.append(application.config['EPOS_FDSN_MAP'][em])
# If fdsn_memberships is empty, there is no point to continue.
if len(fdsn_memberships) == 0 :
logging.info("User has no access to any data hosted here.")
return Response("This token does not grant access to any data hosted at RESIF. You are member of %s. Please contact the PI of the data you are looking for to grant you access."%tokendict['memberof'], status=200)
# Compute a random login and password
login = ''.join(random.choices(string.ascii_uppercase + string.digits, k=14))
password = ''.join(random.choices(string.ascii_uppercase + string.digits, k=14))
if len(fdsn_memberships) > 0:
logging.debug("FDSN memberships: %s"%(fdsn_memberships))
register_privileges(login, fdsn_memberships)
# Register login
register_login(login, password)
# Store in PRIVILEGEDB
logging.debug("FDSN memberships: %s"%(fdsn_memberships))
register_privileges(login, fdsn_memberships)
# Return
return "%s:%s"%(login, password)
if __name__ == "__main__":
......
__version__='0.3.3'
__version__='0.4.0'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment