setup.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #!/usr/bin/env python
  2. from __future__ import unicode_literals
  3. from setuptools import setup
  4. import django_auth_ldap
  5. long_description = """\
  6. This is a Django authentication backend that authenticates against an LDAP
  7. service. Configuration can be as simple as a single distinguished name template,
  8. but there are many rich configuration options for working with users, groups,
  9. and permissions.
  10. This version is supported on Python 2.7 and 3.4+; and Django 1.8 and 1.10+.
  11. Under Python 2, it requires `python-ldap
  12. <https://pypi.python.org/pypi/python-ldap>`_ >= 2.0; under Python 3, it uses
  13. `pyldap <https://pypi.python.org/pypi/pyldap>`_.
  14. * Repository: https://bitbucket.org/illocution/django-auth-ldap
  15. * Documentation: https://django-auth-ldap.readthedocs.io/
  16. * Mailing list: https://groups.google.com/group/django-auth-ldap
  17. Following is an example configuration, just to whet your appetite::
  18. import ldap
  19. from django_auth_ldap.config import LDAPSearch, GroupOfNamesType
  20. # Baseline configuration.
  21. AUTH_LDAP_SERVER_URI = "ldap://ldap.example.com"
  22. AUTH_LDAP_BIND_DN = "cn=django-agent,dc=example,dc=com"
  23. AUTH_LDAP_BIND_PASSWORD = "phlebotinum"
  24. AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=users,dc=example,dc=com",
  25. ldap.SCOPE_SUBTREE, "(uid=%(user)s)")
  26. # or perhaps:
  27. # AUTH_LDAP_USER_DN_TEMPLATE = "uid=%(user)s,ou=users,dc=example,dc=com"
  28. # Set up the basic group parameters.
  29. AUTH_LDAP_GROUP_SEARCH = LDAPSearch("ou=django,ou=groups,dc=example,dc=com",
  30. ldap.SCOPE_SUBTREE, "(objectClass=groupOfNames)"
  31. )
  32. AUTH_LDAP_GROUP_TYPE = GroupOfNamesType()
  33. # Simple group restrictions
  34. AUTH_LDAP_REQUIRE_GROUP = "cn=enabled,ou=django,ou=groups,dc=example,dc=com"
  35. AUTH_LDAP_DENY_GROUP = "cn=disabled,ou=django,ou=groups,dc=example,dc=com"
  36. # Populate the Django user from the LDAP directory.
  37. AUTH_LDAP_USER_ATTR_MAP = {
  38. "first_name": "givenName",
  39. "last_name": "sn",
  40. "email": "mail"
  41. }
  42. AUTH_LDAP_USER_FLAGS_BY_GROUP = {
  43. "is_active": "cn=active,ou=django,ou=groups,dc=example,dc=com",
  44. "is_staff": "cn=staff,ou=django,ou=groups,dc=example,dc=com",
  45. "is_superuser": "cn=superuser,ou=django,ou=groups,dc=example,dc=com"
  46. }
  47. # Use LDAP group membership to calculate group permissions.
  48. AUTH_LDAP_FIND_GROUP_PERMS = True
  49. # Cache group memberships for an hour to minimize LDAP traffic
  50. AUTH_LDAP_CACHE_GROUPS = True
  51. AUTH_LDAP_GROUP_CACHE_TIMEOUT = 3600
  52. # Keep ModelBackend around for per-user permissions and maybe a local
  53. # superuser.
  54. AUTHENTICATION_BACKENDS = (
  55. 'django_auth_ldap.backend.LDAPBackend',
  56. 'django.contrib.auth.backends.ModelBackend',
  57. )
  58. """
  59. setup(
  60. name="django-auth-ldap",
  61. version=django_auth_ldap.version_string,
  62. description="Django LDAP authentication backend",
  63. long_description=long_description,
  64. url="https://bitbucket.org/illocution/django-auth-ldap",
  65. author="Peter Sagerson",
  66. author_email="psagers@ignorare.net",
  67. license="BSD",
  68. packages=["django_auth_ldap"],
  69. classifiers=[
  70. 'Development Status :: 5 - Production/Stable',
  71. "Environment :: Web Environment",
  72. "Programming Language :: Python",
  73. "Programming Language :: Python :: 2",
  74. "Programming Language :: Python :: 2.7",
  75. "Programming Language :: Python :: 3",
  76. "Programming Language :: Python :: 3.4",
  77. "Programming Language :: Python :: 3.5",
  78. "Programming Language :: Python :: 3.6",
  79. "Framework :: Django",
  80. "Framework :: Django :: 1.8",
  81. "Framework :: Django :: 1.10",
  82. "Framework :: Django :: 1.11",
  83. "Framework :: Django :: 2.0",
  84. "Intended Audience :: Developers",
  85. "Intended Audience :: System Administrators",
  86. "License :: OSI Approved :: BSD License",
  87. "Topic :: Internet :: WWW/HTTP",
  88. "Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP",
  89. "Topic :: Software Development :: Libraries :: Python Modules",
  90. ],
  91. keywords=["django", "ldap", "authentication", "auth"],
  92. install_requires=[
  93. 'django >= 1.8',
  94. 'pyldap; python_version >= "3.0"',
  95. 'python-ldap >= 2.0; python_version < "3.0"',
  96. ],
  97. setup_requires=[
  98. "setuptools >= 0.6c11",
  99. ],
  100. tests_require=[
  101. "mockldap >= 0.2.7",
  102. ]
  103. )