Skip to content
Snippets Groups Projects
Select Git revision
  • 687fbb53ed3d9a5eba759b87e70ab19c614543c4
  • master default
  • ldapi-support
  • v1.3.3
  • v1.4.0
  • v1.3.2
  • v1.3.0
  • v1.1.2
  • v1.1.1
  • v1.1.0
  • v1.0.1
  • v1.0.0
  • v0.4.0
  • v0.2.0
  • v0.3.0
  • v0.1.1
  • v0.1.0
17 results

flask-simpleldap

Flask-SimpleLDAP

Flask-SimpleLDAP provides LDAP authentication for Flask.

Quickstart

First, install Flask-SimpleLDAP:

    $ pip install flask-simpleldap

Flask-SimpleLDAP depends, and will install for you, recent versions of Flask (0.9 or later) and python-ldap. Flask-SimpleLDAP is compatible with and tested on Python 2.6 and 2.7.

Next, add a LDAP instance to your code and at least the three required configuration options:

from flask import Flask
from flask.ext.simpleldap import LDAP

app = Flask(__name__)
ldap = LDAP(app)

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'

@app.route('/ldap')
@ldap.login_required
def ldap_protected():
    return 'Success!'

Check the examples folder for a more complex example using LDAP groups.

Resources