summaryrefslogtreecommitdiff
path: root/login.py
diff options
context:
space:
mode:
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))