這是很容易與瓶的工作,因爲它是輕量級的,基於插件的Python的Web框架
事情你需要爲LDAP配置
你需要安裝瓶,LDAP插件
pip install Flask-LDAP
,這裏是一個基本的例子,讓你開始:
from flask import Flask
from flask.ext.ldap import LDAP, login_required
app = Flask(__name__)
app.debug = True
app.config['LDAP_HOST'] = 'ldap.example.com'
app.config['LDAP_DOMAIN'] = 'example.com'
app.config['LDAP_SEARCH_BASE'] = 'OU=Domain Users,DC=example,DC=com'
ldap = LDAP(app)
app.secret_key = "welfhwdlhwdlfhwelfhwlehfwlehfelwehflwefwlehflwefhlwefhlewjfhwelfjhweflhweflhwel"
app.add_url_rule('/login', 'login', ldap.login, methods=['GET', 'POST'])
@app.route('/')
@ldap.login_required
def index():
pass
# @app.route('/login', methods=['GET', 'POST'])
# def login():
# pass
if __name__ == '__main__':
app.run(debug=True, host="0.0.0.0")
更多細節可以發現here