diff --git a/auth.py b/auth.py index e42ac51..0bc1b39 100644 --- a/auth.py +++ b/auth.py @@ -22,5 +22,25 @@ def login(): res,code = 'ERROR', 401 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__': app.run('0.0.0.0', 8082, debug=True) diff --git a/templates/irc.html b/templates/irc.html new file mode 100644 index 0000000..1fc2f13 --- /dev/null +++ b/templates/irc.html @@ -0,0 +1,4 @@ +
+ + +