Skip to content
Snippets Groups Projects
Select Git revision
  • d7656c8168cc24d407714f6e94e8b94b451706d9
  • master default
  • init_facts_module
3 results

nginx_facts

Blame
    • nimrod's avatar
      d7656c81
      - Run tests from Tox, use generated environments. · d7656c81
      nimrod authored
      - Run tests in TravisCI on multiple Ansible, Python versions and OSes.
      - Create Docker container with Ansible.
      - Split tests to seperate files.
      - Moved everything test related to tests/ .
      - Update pre-commit hooks.
      - Merge .flake8 to tox.ini.
      - Added shellcheck hook.
      - Fixed issues found by shellcheck.
      - Updated README (added usage, testing sections).
      d7656c81
      History
      - Run tests from Tox, use generated environments.
      nimrod authored
      - Run tests in TravisCI on multiple Ansible, Python versions and OSes.
      - Create Docker container with Ansible.
      - Split tests to seperate files.
      - Moved everything test related to tests/ .
      - Update pre-commit hooks.
      - Merge .flake8 to tox.ini.
      - Added shellcheck hook.
      - Fixed issues found by shellcheck.
      - Updated README (added usage, testing sections).
    app_oldap.py 1023 B
    from flask import Flask, g
    from flask_simpleldap import LDAP
    
    app = Flask(__name__)
    
    # Base
    app.config['LDAP_REALM_NAME'] = 'OpenLDAP Authentication'
    app.config['LDAP_HOST'] = 'openldap.example.org'
    app.config['LDAP_BASE_DN'] = 'dc=users,dc=openldap,dc=org'
    app.config['LDAP_USERNAME'] = 'cn=user,ou=servauth-users,dc=users,dc=openldap,dc=org'
    app.config['LDAP_PASSWORD'] = 'password'
    
    # OpenLDAP
    app.config['LDAP_OPENLDAP'] = True
    app.config['LDAP_OBJECTS_DN'] = 'dn'
    app.config['LDAP_USER_OBJECT_FILTER'] = '(&(objectclass=inetOrgPerson)(uid=%s))'
    
    # Groups
    app.config['LDAP_GROUP_MEMBERS_FIELD'] = "uniquemember"
    app.config['LDAP_GROUP_OBJECT_FILTER'] = "(&(objectclass=groupOfUniqueNames)(cn=%s))"
    app.config['LDAP_GROUP_MEMBER_FILTER'] = "(&(cn=*)(objectclass=groupOfUniqueNames)(uniquemember=%s))"
    app.config['LDAP_GROUP_MEMBER_FILTER_FIELD'] = "cn"
    
    ldap = LDAP(app)
    
    @app.route('/')
    @ldap.basic_auth_required
    def index():
        return 'Welcome, {0}!'.format(g.ldap_username)
    
    if __name__ == '__main__':
        app.run()