Skip to main content

LDAP Auth Configuration

The ldap-auth plugin verifies HTTP Basic credentials with an LDAP directory and maps the authenticated directory user to an API consumer. Configuration covers credential fields and route and service fields.

Parameters​

See plugin common configurations for configuration options available to all plugins.

Credentials​

The following attributes configure LDAP Auth on a consumer.

  • user_dn

    string

    required


    Distinguished name of the LDAP entry represented by the consumer, such as uid=johndoe,ou=users,dc=example,dc=org. It must match the DN used for the successful directory bind.

    API7 Gateway 3.10.6 and APISIX 3.18.0 introduced RFC 4514 escaping when constructing the bind DN. If the user name contains structural characters, configure user_dn with the matching escaped DN. API7 Gateway 3.9 does not escape these characters.

    Supports an environment variable reference with the $env:// prefix or a secret-manager reference with the $secret:// prefix. See environment variables in plugins and secrets.

Routes or Services​

The following attributes configure LDAP Auth on routes or services.

  • base_dn

    string

    required


    Base distinguished name appended to the user name when the plugin constructs the bind DN, such as ou=users,dc=example,dc=org.

  • ldap_uri

    string

    required


    LDAP directory address as host or host:port. The default port is 389 when omitted.

  • use_tls

    boolean

    default: false


    If true, connect to the directory over LDAPS. This field does not enable StartTLS.

  • tls_verify

    boolean

    default: false


    If true, verify the directory certificate when use_tls is enabled. Configure the gateway trust bundle so that it trusts the issuing CA and use a directory host name covered by the certificate.

  • uid

    string

    default: cn


    LDAP attribute placed before the client-supplied user name when constructing the bind DN. For example, uid produces uid=johndoe,<base_dn>.

  • hide_credentials

    boolean

    default: false


    If true, remove the Authorization header after authentication so the directory password is not forwarded upstream.

    Introduced in API7 Gateway 3.10.6 and APISIX 3.18.0. API7 Gateway 3.9 does not support this field and forwards the header upstream.

  • realm

    string

    default: ldap

    valid value:

    between 1 and 128 printable ASCII characters, excluding double quotes and backslashes

    Realm included in the WWW-Authenticate challenge returned with an authentication failure.