Software /
code /
prosody-modules
Comparison
mod_auth_external_insecure/examples/python/prosody-auth-example.py @ 3884:f84ede3e9e3b
mod_auth_external->mod_auth_external_insecure: Unmaintained and almost certainly insecure, discourage its use
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 06 Feb 2020 21:03:17 +0000 |
parent | 1194:mod_auth_external/examples/python/prosody-auth-example.py@f5eadba27120 |
comparison
equal
deleted
inserted
replaced
3883:571249f69577 | 3884:f84ede3e9e3b |
---|---|
1 #!/usr/bin/env python2 | |
2 | |
3 import sys | |
4 | |
5 def auth(username, password): | |
6 if username == "someone": | |
7 return "1" | |
8 return "0" | |
9 | |
10 def respond(ret): | |
11 sys.stdout.write(ret+"\n") | |
12 sys.stdout.flush() | |
13 | |
14 methods = { | |
15 "auth": { "function": auth, "parameters": 2 } | |
16 } | |
17 | |
18 while 1: | |
19 line = sys.stdin.readline().rstrip("\n") | |
20 method, sep, data = line.partition(":") | |
21 if method in methods: | |
22 method_info = methods[method] | |
23 split_data = data.split(":", method_info["parameters"]) | |
24 if len(split_data) == method_info["parameters"]: | |
25 respond(method_info["function"](*split_data)) | |
26 else: | |
27 respond("error: incorrect number of parameters to method '%s'"%method) | |
28 else: | |
29 respond("error: method '%s' not implemented"%method) |