ldap first pass

This commit is contained in:
Matthew Scragg 2015-10-14 17:36:22 -05:00
parent 3c2f4a0445
commit 2eaf09dc78
13 changed files with 148 additions and 25 deletions

View file

@ -0,0 +1,31 @@
from flask import current_app, render_template
from flask.ext.login import login_user
from realms import ldap
from flask_ldap_login import LDAPLoginForm
from ..models import BaseUser
import bcrypt
users = {}
@ldap.save_user
def save_user(username, userdata):
users[username] = User(username, userdata)
return users[username]
class User(BaseUser):
type = 'ldap'
def __init__(self, username, data):
self.id = username
self.username = username
self.data = data
@staticmethod
def login_form():
form = LDAPLoginForm()
return render_template('auth/ldap/login.html', form=form)
@staticmethod
def auth(*args):
login_user(args[0].user, remember=True)
return True