1
0
forked from moepman/bk-dss

Add password support

This commit is contained in:
Markus 2016-11-10 08:11:25 +01:00
parent 9669790224
commit 8667f788f1
2 changed files with 7 additions and 0 deletions

View File

@ -6,6 +6,7 @@ TBA
## Requirements ## Requirements
* passlib >= 1.6.0
* py-flask >= 0.10 * py-flask >= 0.10
* py-flask-wtf >= 0.10 * py-flask-wtf >= 0.10
* py-ldap >= 2.4.15 * py-ldap >= 2.4.15

View File

@ -4,6 +4,8 @@ from flask import Flask, render_template, redirect, url_for, session
from flask_wtf import Form from flask_wtf import Form
import ldap import ldap
import ldap.modlist import ldap.modlist
import os
from passlib.hash import ldap_salted_sha1
from redis import Redis from redis import Redis
import uuid import uuid
from wtforms.fields import IntegerField, PasswordField, SelectField, StringField, SubmitField from wtforms.fields import IntegerField, PasswordField, SelectField, StringField, SubmitField
@ -43,6 +45,9 @@ class LoginForm(Form):
submit = SubmitField('Login') submit = SubmitField('Login')
def makeSecret(password):
return ldap_salted_sha1.encrypt(password)
def isAdmin(): def isAdmin():
return isLoggedin() and rdb.hget(session['uuid'], 'user') in app.config.get('ADMINS', []) return isLoggedin() and rdb.hget(session['uuid'], 'user') in app.config.get('ADMINS', [])
@ -85,6 +90,7 @@ def create():
'uid' : form.uid.data, 'uid' : form.uid.data,
'gn' : form.gn.data, 'gn' : form.gn.data,
'sn' : form.sn.data, 'sn' : form.sn.data,
'pass' : makeSecret(form.pwd1.data)
} }
# add user # add user