irc dereference
parent
29cee8fb75
commit
aee18f11dd
20
auth.py
20
auth.py
|
@ -22,5 +22,25 @@ def login():
|
||||||
res,code = 'ERROR', 401
|
res,code = 'ERROR', 401
|
||||||
return make_response(res, code, { 'Content-Type': 'text/plain' })
|
return make_response(res, code, { 'Content-Type': 'text/plain' })
|
||||||
|
|
||||||
|
@app.route('/irc', methods=['GET'])
|
||||||
|
def irc_form():
|
||||||
|
return render_template('irc.html')
|
||||||
|
|
||||||
|
@app.route('/irc', methods=['POST'])
|
||||||
|
def irc_nick():
|
||||||
|
conn = ldap.initialize(app.config['LDAP_URL'])
|
||||||
|
conn.start_tls_s()
|
||||||
|
login,code = '', 401
|
||||||
|
try:
|
||||||
|
res = conn.search_s(app.config['IRC_BASEDN'], ldap.SCOPE_SUBTREE,
|
||||||
|
app.config['IRC_LDAP_FILTER'] % request.form['nick'])
|
||||||
|
if len(res) == 1:
|
||||||
|
login = res[0][1]['uid'][0]
|
||||||
|
code = 200
|
||||||
|
except ldap.LDAPError as e:
|
||||||
|
print e
|
||||||
|
code = 500
|
||||||
|
return make_response(login, code, { 'Content-Type': 'text/plain' })
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run('0.0.0.0', 8082, debug=True)
|
app.run('0.0.0.0', 8082, debug=True)
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
<form action="" method="POST">
|
||||||
|
<label for="nick">Freenode account<input type="text" name="nick"/></label>
|
||||||
|
<input type="submit" value="send"/>
|
||||||
|
</form>
|
Loading…
Reference in New Issue