summaryrefslogtreecommitdiff
path: root/login.py
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2016-12-17 15:50:27 +0100
committerYves Fischer <yvesf-git@xapek.org>2016-12-17 16:00:19 +0100
commit8ceac0236c555979a9172c69c1a9e895d7487d6f (patch)
tree390740422d514ac62bc572d61c64e7375f2d7a27 /login.py
parentf355162fde31a4c79b7e665b43cef2de3ba05cb5 (diff)
downloadauth-xmppmessage-8ceac0236c555979a9172c69c1a9e895d7487d6f.tar.gz
auth-xmppmessage-8ceac0236c555979a9172c69c1a9e895d7487d6f.zip
replace all with subdirectory rust/
Diffstat (limited to 'login.py')
-rwxr-xr-xlogin.py38
1 files changed, 0 insertions, 38 deletions
diff --git a/login.py b/login.py
deleted file mode 100755
index 24f62a1..0000000
--- a/login.py
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/usr/bin/env python3.4
-import os
-import sys
-import functions
-
-
-def run(config):
- conf_users = config['users'].split(',')
- conf_secret = config['secret']
- conf_validsec = int(config['validsec'])
- conf_jid = config['jid']
- conf_jid_pw = config['jid_pw']
-
- # reading the credential supplied in a pipe from apache
- username = sys.stdin.readline().strip()
- password = sys.stdin.readline().strip()
-
- if password == "" and username in conf_users:
- # avoid spamming by allowing only one message sent at a time
- lockfile = os.path.basename(__file__)
- with functions.file_lock("/tmp/lock." + lockfile):
- message = functions.token_message(username, conf_secret, conf_validsec,
- os.getenv("URI"), os.getenv("HTTP_HOST"))
- if os.getenv("SKIP_XMPP"): # used for testing
- print(message)
- else:
- functions.send_message(conf_jid, conf_jid_pw, username, message)
- elif username in conf_users:
- if functions.verify_token(username, password, conf_secret, conf_validsec):
- return os.EX_OK
-
- return os.EX_NOPERM # fail by default
-
-
-if __name__ == "__main__":
- config = dict(map(lambda kv: kv.split("="),
- os.getenv("CONTEXT").split(";")))
- sys.exit(run(config))