mirror of
https://github.com/moepman/bk-dss
synced 2024-12-22 18:24:27 +01:00
Add password support
This commit is contained in:
parent
9669790224
commit
8667f788f1
@ -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
|
||||||
|
6
index.py
6
index.py
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user