diff options
author | cbdev <cb@cbcdn.com> | 2022-07-04 19:21:34 +0200 |
---|---|---|
committer | cbdev <cb@cbcdn.com> | 2022-07-04 19:21:34 +0200 |
commit | 507f0d060da30a8f65bec8b2ac1f08837d536b4c (patch) | |
tree | b2c5a1f9cc5080fb7f2586e2371fce443e43fbaa /backend/ExternalAuth.py | |
parent | 4369d6a7f024f9ebf3c5f41a8fe17bfc65d0a820 (diff) | |
download | cargohold-507f0d060da30a8f65bec8b2ac1f08837d536b4c.tar.gz cargohold-507f0d060da30a8f65bec8b2ac1f08837d536b4c.tar.bz2 cargohold-507f0d060da30a8f65bec8b2ac1f08837d536b4c.zip |
Implement authentication modules for admin panel
Diffstat (limited to 'backend/ExternalAuth.py')
-rw-r--r-- | backend/ExternalAuth.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/backend/ExternalAuth.py b/backend/ExternalAuth.py new file mode 100644 index 0000000..e6837ec --- /dev/null +++ b/backend/ExternalAuth.py @@ -0,0 +1,22 @@ +import config +import utils + +# This authentication provider assumes that the actual authentication is done in +# an upstream component such as the serving httpd. +# The authorized user is expected to be passed in the uwsgi environment variable REMOTE_USER. + +def login(env, post): + user = get(env) + if not User: + return utils.redirect(config.homepage) + + utils.ensure_user(user["user"]) + return utils.redirect("/admin") + +def get(env): + if env.get('REMOTE_USER', ''): + return {"user": env.get('REMOTE_USER', ''), "expire": None} + return None + +def logout(): + return False |