Просмотр исходного кода

Closes #5033: Support backward compatibility for REMOTE_AUTH_BACKEND

Jeremy Stretch 5 лет назад
Родитель
Сommit
728088f5fa
2 измененных файлов с 10 добавлено и 1 удалено
  1. 3 1
      docs/release-notes/version-2.9.md
  2. 7 0
      netbox/netbox/settings.py

+ 3 - 1
docs/release-notes/version-2.9.md

@@ -7,6 +7,7 @@
 * [#4540](https://github.com/netbox-community/netbox/issues/4540) - Add IP address status type for SLAAC
 * [#4814](https://github.com/netbox-community/netbox/issues/4814) - Allow nested LAG interfaces
 * [#4991](https://github.com/netbox-community/netbox/issues/4991) - Add Python and NetBox versions to error page
+* [#5033](https://github.com/netbox-community/netbox/issues/5033) - Support backward compatibility for `REMOTE_AUTH_BACKEND` configuration parameter
 
 ---
 
@@ -66,7 +67,8 @@ Two new REST API endpoints have been added to facilitate the retrieval and manip
 
 ### Configuration Changes
 
-* If in use, LDAP authentication must be enabled by setting `REMOTE_AUTH_BACKEND` to `'netbox.authentication.LDAPBackend'`. (LDAP configuration parameters in `ldap_config.py` remain unchanged.)
+* If using NetBox's built-in remote authentication backend, update `REMOTE_AUTH_BACKEND` to `'netbox.authentication.RemoteUserBackend'`, as the authentication class has moved.
+* If using LDAP authentication, set `REMOTE_AUTH_BACKEND` to `'netbox.authentication.LDAPBackend'`. (LDAP configuration parameters in `ldap_config.py` remain unchanged.)
 * `REMOTE_AUTH_DEFAULT_PERMISSIONS` now takes a dictionary rather than a list. This is a mapping of permission names to a dictionary of constraining attributes, or `None`. For example, `['dcim.add_site', 'dcim.change_site']` would become `{'dcim.add_site': None, 'dcim.change_site': None}`.
 
 ### REST API Changes

+ 7 - 0
netbox/netbox/settings.py

@@ -142,6 +142,13 @@ if type(REMOTE_AUTH_DEFAULT_PERMISSIONS) is not dict:
         )
     except TypeError:
         raise ImproperlyConfigured("REMOTE_AUTH_DEFAULT_PERMISSIONS must be a dictionary.")
+# Backward compatibility for REMOTE_AUTH_BACKEND
+if REMOTE_AUTH_BACKEND == 'utilities.auth_backends.RemoteUserBackend':
+    warnings.warn(
+        "RemoteUserBackend has moved! Please update your configuration to:\n"
+        "    REMOTE_AUTH_BACKEND='netbox.authentication.RemoteUserBackend'"
+    )
+    REMOTE_AUTH_BACKEND = 'netbox.authentication.RemoteUserBackend'
 
 
 #