Skip to main content

devpi-ldap: LDAP authentication for devpi-server

Latest Version

For use with devpi-server >= 2.1.0.

Installation

devpi-ldap needs to be installed alongside devpi-server.

You can install it with:

pip install devpi-ldap

For devpi-server there is no configuration needed to activate the plugin, as it will automatically discover the plugin through calling hooks using the setuptools entry points mechanism. However, you need to pass a path with a YAML config file to devpi-server, via the --ldap-config command-line option.

Details about LDAP configuration below.

Configuration

A script named devpi-ldap can be used to test your LDAP configuration.

To configure LDAP, create a yaml file with a dictionary containing another dictionary under the devpi-ldap key with the following options:

url

The url of the LDAP server. Using ldaps:// enables SSL. No certificate validation is performed at the moment.

tls

Parameters to the ldap3.Tls object for Transport Layer Security, used with LDAPS connections.

server_pool

A list of LDAP pool servers. Either server_pool or url are mandatory, but they are mutually exclusive. A list entry itself is a dictionary containing a mandatory url item and optionally a tls item.

user_template

The template to generate the distinguished name for the user. If the structure is fixed, this is faster than specifying a user_search, but devpi-server can’t know whether a user exists or not.

user_search

If you can’t or don’t want to use user_template, then these are the search settings for the users distinguished name. You can use username in the search filter. See specifics below.

group_search

The search settings for the group objects of the user. You can use username and userdn (the distinguished name) in the search filter. See specifics below.

referrals

Whether to follow referrals. This needs to be set to false in many cases when using LDAP via Active Directory on Windows. The default is true.

reject_as_unknown

Report all failed authentication attempts as unknown instead of reject. This is useful e.g. if using the provided credentials to bind to ldap, in which case we cannot distinguish authentication failures from unknown users. unknown is required to let other auth hooks attempt to authenticate the user.

timeout

The timeout for connections to the LDAP server. Defaults to 10 seconds.

The user_search and group_search settings are dictionaries with the following options:

base

The base location from which to search.

filter

The search filter. To use replacements, put them in curly braces. Example: (&(objectClass=group)(member={userdn}))

scope

The scope for the search. Valid values are base-object, single-level and whole-subtree. The default is whole-subtree.

attribute_name

The name of the attribute which contains the user DN which will be used to check the user’s password. devpi-ldap will extract this attribute from the search results and attempt to bind to the LDAP server using this DN and the password supplied by the user. If this bind succeeds, access is granted.

userdn

The distinguished name of the user which should be used for the search operation. For user_search, if you don’t have anonymous user search or for group_search if the users can’t search their own groups, then you need to set this to a user which has the necessary rights.

password

The password for the user in userdn.

The YAML file should then look similar to this:

---
devpi-ldap:
  url: ldap://example.com
  user_template: CN={username},CN=Partition1,DC=Example,DC=COM
  group_search:
    base: CN=Partition1,DC=Example,DC=COM
    filter: (&(objectClass=group)(member={userdn}))
    attribute_name: CN

An example with user search and Active Directory might look like this:

---
devpi-ldap:
  url: ldap://example.com
  user_search:
    base: CN=Partition1,DC=Example,DC=COM
    filter: (&(objectClass=user)(sAMAccountName={username}))
    attribute_name: distinguishedName
  group_search:
    base: CN=Partition1,DC=Example,DC=COM
    filter: (&(objectClass=group)(member={userdn}))
    attribute_name: CN

With a server pool it might look like this:

---
devpi-ldap:
  server_pool:
    - url: ldap://server1.example.com:389
    - url: ldap://server2.example.com:3268
    - url: ldaps://server3.example.com:636
      tls:
        validate: 2 # ssl.CERT_REQUIRED
        ca_certs_file: /etc/ssl/certs/ca-certificates.crt
    - url: ldaps://server4.example.com:3269
      tls:
        validate: 2 # ssl.CERT_REQUIRED
        ca_certs_file: /etc/ssl/certs/ca-certificates.crt
  user_search:
    base: CN=Partition1,DC=Example,DC=COM
    filter: (&(objectClass=user)(sAMAccountName={username}))
    attribute_name: distinguishedName
  group_search:
    base: CN=Partition1,DC=Example,DC=COM
    filter: (&(objectClass=group)(member={userdn}))
    attribute_name: CN

Changelog

Changelog

2.2.0 - 2026-05-08

  • Drop support for Python < 3.9.

  • Add support for Python up to 3.13.

  • Require at least ldap3 2.0.9

  • Require at least devpi-server 6.0.0.

  • Support loading configuration from --configfile option of devpi-server.

2.1.1 - 2023-08-07

  • Use escape_filter_chars before calling LDAP search method. [mr-scrawley (Micha Schmierer), fschulze]

2.1.0 - 2021-12-04

  • Fix issue #50: new server_pool setting.

2.0.0 - 2021-05-16

  • Add timeout option for LDAP connections. Defaults to 10 seconds.

  • Use safe_load to read YAML config.

  • The reject_as_unknown option is now true by default.

  • Drop support for Python < 3.6, support for Python 3.x will end with their respective EOLs.

  • Fix deprecation warning with devpi-server 6.0.0.

  • Fix pluggy deprecation warning.

  • Require at least devpi-server 5.0.0.

1.2.2 - 2018-05-28

  • More ldap3 2.x fixes. [fschulze]

1.2.1 - 2018-05-25

  • Fix compatibility with ldap3 2.x. [fschulze, abrasive (James Laird-Wah)]

  • Stopped testing with Python 2.6, but no changes made which break compatibility.

1.2.0 - 2016-03-25

  • Add support for TLS parameters in the config. [jaraco (Jason R. Coombs)]

  • Allow invocation via python -m devpi-ldap and fix cli for Python 3. [jaraco]

  • Add exit codes to testing script when authentication fails. [jaraco]

1.1.1 - 2016-01-28

  • set minimum version of ldap3 library, which adds hiding of password in debug logging. [cannatag (Giovanni Cannata), rodcloutier (Rodrigue Cloutier), fschulze]

  • change dependency for the ldap library, which was renamed. [kumy]

  • fix issue #5: dn and distinguishedName may appear as a top level response attribute instead of the attributes list. [kainz (Bryon Roché)]

  • fix issue #24: Ignore additional search result data. [bonzani (Patrizio Bonzani), fschulze]

1.1.0 - 2014-11-10

  • add reject_as_unknown option [davidszotten (David Szotten)]

1.0.1 - 2014-10-10

  • fix the plugin hook [fschulze]

1.0.0 - 2014-09-22

  • initial release

Metadata

Release files for devpi-ldap 2.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for devpi-ldap 2.2.0
File Size Uploaded
devpi_ldap-2.2.0.tar.gz 15.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for devpi-ldap 2.2.0
File Interpreter ABI Platform
devpi_ldap-2.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.9 kB

Release files / devpi_ldap-2.2.0.tar.gz

Download URL devpi_ldap-2.2.0.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5a183bfe4cf3c060fc9eb272c54b7c33672886abb92528ce3c74eef6b45a4a6c
BLAKE2b-256 checksum
How to use checksums
9601a5694f1171abeb188623fadc920bc9f92366f8f5e7b0832d34162d68833d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via devpi-server/6.19.1 (py3.11.11; darwin)

Release files / devpi_ldap-2.2.0-py3-none-any.whl

Download URL devpi_ldap-2.2.0-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f407c8184b753545b2069135013192a06e221114c050b17ea6850d67f1324e7
BLAKE2b-256 checksum
How to use checksums
05a175cefc166f730b7b58bfcacf49ee6b5e429dcc5110fcb029adf0a61f409e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via devpi-server/6.19.1 (py3.11.11; darwin)

Release history Release notifications | RSS feed

This release

2.2.0 This release

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

1 release file

1.0.2.dev1

1.0.1

1 release file

1.0.1.dev1

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page