-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.py
32 lines (27 loc) · 962 Bytes
/
server.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
import tornado.ioloop
import tornado.web
from CSHLDAP import CSHLDAP
class IbuttonHandler(tornado.web.RequestHandler):
def get(self):
# Do the actual work here
# Call out to ldap, return a json dict
# contents: entryUUID, username
# To move to production, change these initialization values
# to a user/pass which can search ibuttons
ldap = CSHLDAP('user', 'password')
# get the ibutton from the arguments
ibutton = self.get_argument('ibutton')
entry = ldap.search(ibutton=ibutton)[0]
response = {
'username': entry[1]['uid'],
# entryUUID temporarily disabled while I work out some permissions errors
#'entryUUID': entry[1]['entryUUID']
}
# return it
self.write(response)
if __name__ == "__main__":
application = tornado.web.Application([
(r"/", IbuttonHandler),
])
application.listen(6969)
tornado.ioloop.IOLoop.instance().start()