LDAP configuration errors even when REMOTE_AUTH_ENABLED = False #8364

Closed
opened 2025-12-29 20:35:49 +01:00 by adam · 2 comments
Owner

Originally created by @candlerb on GitHub (Jul 25, 2023).

NetBox version

v3.5.6

Python version

3.8

Steps to Reproduce

Set the following in configuration.py

REMOTE_AUTH_ENABLED = False
REMOTE_AUTH_BACKEND = 'netbox.authentication.LDAPBackend'

and leave ldap_config.py missing, or create an empty file.

Expected Behavior

Since REMOTE_AUTH_ENABLED is False, no attempt should be made to load ldap config

Observed Behavior

ldap config errors are shown. (Reported in discussion #13138)

I suspect the cause is here:

        if 'netbox.authentication.LDAPBackend' in settings.REMOTE_AUTH_BACKEND:

which probably should start if settings.REMOTE_AUTH_ENABLED and ...

Originally created by @candlerb on GitHub (Jul 25, 2023). ### NetBox version v3.5.6 ### Python version 3.8 ### Steps to Reproduce Set the following in configuration.py ``` REMOTE_AUTH_ENABLED = False REMOTE_AUTH_BACKEND = 'netbox.authentication.LDAPBackend' ``` and leave ldap_config.py missing, or create an empty file. ### Expected Behavior Since REMOTE_AUTH_ENABLED is False, no attempt should be made to load ldap config ### Observed Behavior ldap config errors are shown. (Reported in discussion #13138) I suspect the cause is [here](https://github.com/netbox-community/netbox/blob/v3.5.6/netbox/netbox/api/authentication.py#L63): ``` if 'netbox.authentication.LDAPBackend' in settings.REMOTE_AUTH_BACKEND: ``` which probably should start `if settings.REMOTE_AUTH_ENABLED and ...`
adam closed this issue 2025-12-29 20:35:49 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 11, 2023):

The documentation for the REMOTE_AUTH_ENABLED configuration parameter reads:

NetBox can be configured to support remote user authentication by inferring user authentication from an HTTP header set by the HTTP reverse proxy (e.g. nginx or Apache). Set this to True to enable this functionality. (Local authentication will still take effect as a fallback.) (REMOTE_AUTH_DEFAULT_GROUPS will not function if REMOTE_AUTH_ENABLED is disabled)

It is referenced in code only by RemoteUserMiddleware and has no impact on the use of LDAP authentication. I don't believe it makes sense to evaluate this parameter when initializing the LDAP authentication backend. To do so we would need to redefine its purpose and update the documentation accordingly.

The workaround is to simply not enable the LDAP authentication backend if no configuration has been defined for it.

@jeremystretch commented on GitHub (Aug 11, 2023): The documentation for the [`REMOTE_AUTH_ENABLED`](https://docs.netbox.dev/en/stable/configuration/remote-authentication/#remote_auth_enabled) configuration parameter reads: > NetBox can be configured to support remote user authentication by inferring user authentication from an HTTP header set by the HTTP reverse proxy (e.g. nginx or Apache). Set this to True to enable this functionality. (Local authentication will still take effect as a fallback.) (`REMOTE_AUTH_DEFAULT_GROUPS` will not function if `REMOTE_AUTH_ENABLED` is disabled) It is referenced in code only by `RemoteUserMiddleware` and has no impact on the use of LDAP authentication. I don't believe it makes sense to evaluate this parameter when initializing the LDAP authentication backend. To do so we would need to redefine its purpose and update the documentation accordingly. The workaround is to simply not enable the LDAP authentication backend if no configuration has been defined for it.
Author
Owner

@jeremystretch commented on GitHub (Sep 26, 2023):

I'm going to close this out as there's been no further discussion.

@jeremystretch commented on GitHub (Sep 26, 2023): I'm going to close this out as there's been no further discussion.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8364