Skip to content
Snippets Groups Projects
Commit dfadbe61 authored by Timothy Allen's avatar Timothy Allen
Browse files

Add an example of using .basic_auth_required()

parent f970cf64
Branches
Tags
No related merge requests found
from flask import Flask, g, request, session, redirect, url_for
from flask.ext.simpleldap import LDAP
app = Flask(__name__)
app.secret_key = 'dev key'
app.debug = True
app.config['LDAP_HOST'] = 'ldap.example.org'
app.config['LDAP_BASE_DN'] = 'OU=users,dc=example,dc=org'
app.config['LDAP_USERNAME'] = 'CN=user,OU=Users,DC=example,DC=org'
app.config['LDAP_PASSWORD'] = 'password'
ldap = LDAP(app)
@app.route('/')
@ldap.basic_auth_required
def index():
return "Welcome, {0}!".format(g.ldap_username)
if __name__ == '__main__':
app.run()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment