This repository has been archived by the owner on Mar 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 495
/
http-auth-be.py
executable file
·68 lines (47 loc) · 1.71 KB
/
http-auth-be.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Jan-Piet Mens <[email protected]>'
__copyright__ = 'Copyright 2014 Jan-Piet Mens'
import sys
import bottle
from bottle import response, request
app = application = bottle.Bottle()
@app.route('/auth', method='POST')
def auth():
response.content_type = 'text/plain'
response.status = 403
# data = bottle.request.body.read() # username=jane%40mens.de&password=jolie&topic=&acc=-1
username = request.forms.get('username')
password = request.forms.get('password')
topic = request.forms.get('topic')
acc = request.forms.get('acc')
if username == '[email protected]' and password == 'jolie':
response.status = 200
return None
@app.route('/superuser', method='POST')
def superuser():
response.content_type = 'text/plain'
response.status = 403
data = bottle.request.body.read() # username=jane%40mens.de&password=&topic=&acc=-1
username = request.forms.get('username')
if username == 'special':
response.status = 200
return None
@app.route('/acl', method='POST')
def acl():
response.content_type = 'text/plain'
response.status = 403
data = bottle.request.body.read() # username=jane%40mens.de&password=&topic=t%2F1&acc=2&clientid=JANESUB
username = request.forms.get('username')
topic = request.forms.get('topic')
clientid = request.forms.get('clientid')
acc = request.forms.get('acc') # 1 == SUB, 2 == PUB
if username == '[email protected]' and topic == 't/1':
response.status = 200
return None
if __name__ == '__main__':
bottle.debug(True)
bottle.run(app,
# server='python_server',
host= "127.0.0.1",
port= 8100)