Skip to main content

Flask extension that provides an easy way to protect certain views of an application with LDAP and HTTP basic access authentication.

Project description

Flask-BasicAuth-LDAP

Flask-BasicAuth-LDAP is a Flask extension that provides an easy way to protect certain views of an application with LDAP_ and HTTP basic access authentication_

.. _LDAP: https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol .. _basic access authentication: https://en.wikipedia.org/wiki/Basic_access_authentication

Install

::

pip install flask-basicauth-ldap

Quickstart

::

from flask import Flask, jsonify
from flask_basicauth_ldap import LDAPBasicAuth

app = Flask(__name__)
auth = LDAPBasicAuth(app)

app.config['LDAP_HOST'] = 'ldap://test_host'
app.config['LDAP_PORT'] = 'test_port'
app.config['LDAP_DOMAIN'] = 'test_domain'


@app.route('/secret', methods=['GET'])
@auth.required
def secret_view():
   return jsonify({'status': 'secret'})

If you want to change a response on the unauthorized access, just use unauthorizedhandler to register function that should return Response object

::

@auth.unauthorizedhandler def custom_unathorized_view(): return jsonify({'message': 'Athorize first'}), 401

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for Flask-BasicAuth-LDAP, version 0.0.0a1.dev2
Filename, size File type Python version Upload date Hashes
Filename, size Flask_BasicAuth_LDAP-0.0.0a1.dev2-py3-none-any.whl (3.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size Flask-BasicAuth-LDAP-0.0.0a1.dev2.tar.gz (3.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page