diff --git a/README.md b/README.md index 36e8ab6..dfb3902 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ TBA * py-flask >= 0.10 * py-flask-wtf >= 0.10 +* py-ldap >= 2.4.15 +* py-redis >= 2.10 ## Misc diff --git a/config.cfg.example b/config.cfg.example new file mode 100644 index 0000000..a8c361f --- /dev/null +++ b/config.cfg.example @@ -0,0 +1,5 @@ +DEBUG = True +SECRET_KEY = "CHANGE!ME" + +LDAP_URI = "ldaps://ldap.example.com" +LDAP_BASE = "ou=people,dc=example,dc=com" diff --git a/index.py b/index.py index f543b10..23d48a3 100755 --- a/index.py +++ b/index.py @@ -2,19 +2,36 @@ from flask import Flask, render_template, redirect, url_for, session from flask_wtf import Form +import ldap +from redis import Redis from wtforms.fields import PasswordField, SelectField, StringField, SubmitField from wtforms.validators import Required app = Flask(__name__) -app.config['SECRET_KEY'] = 'CHANGE!ME' +app.config.from_pyfile('index.cfg') app.jinja_env.trim_blocks = True app.jinja_env.lstrip_blocks = True +rdb = Redis(host='127.0.0.1', password='foobared') + + +class LoginForm(Form): + user = StringField('Username', validators=[Required()]) + pswd = PasswordField('Password', validators=[Required()]) + submit = SubmitField('Login') + @app.route('/') def index(): return render_template('index.html') +@app.route('/login', methods=['GET', 'POST']) +def login(): + form = LoginForm() + if form.validate_on_submit(): + # TODO implement login with LDAP + return redirect(url_for('index')) + return render_template('login.html', form=form) if __name__ == '__main__': - app.run(host='0.0.0.0', port=5000, debug=True) + app.run(host='0.0.0.0', port=5000) diff --git a/templates/_helpers.html b/templates/_helpers.html new file mode 100644 index 0000000..71a4f54 --- /dev/null +++ b/templates/_helpers.html @@ -0,0 +1,3 @@ +{% macro render_field(field) %} +