From e486b129357e5ebf2a8b095f146a4d3d677460b2 Mon Sep 17 00:00:00 2001 From: Matthias Weilinger Date: Wed, 22 May 2024 13:10:07 +0200 Subject: [PATCH] update imports to support Netbox v4.0 (#79) According to the netbox docs `extras.plugins` was renamed to `netbox.plugins`. Furthermore netbox no longer uses `django.contib.auth.models` to handle groups but `netbox.authentication`. These changes will make the plugin uncompatible with netbox versions before v4.0 --- README.md | 3 ++- django3_saml2_nbplugin/__init__.py | 2 +- django3_saml2_nbplugin/backends.py | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c46a7e1..477e71d 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ the User to the SSO system. Please refer to the example [nginx.conf](nginx.conf *NOTE: Netbox plugin for SSO, v2.0+, supports Netbox 2.8, 2.9, 2.10, 2.11, 3.0. +*NOTE: Netbox plugin for SSO, v3.0+, supports Netbox 4.0. + ## System Requirements You will need to install the [django3-auth-saml2](https://github.com/jeremyschulman/django3-auth-saml2) @@ -140,4 +142,3 @@ Add the following to your configuration.py: ```python BANNER_LOGIN = 'Login with SSO' ``` - diff --git a/django3_saml2_nbplugin/__init__.py b/django3_saml2_nbplugin/__init__.py index ccb1b66..f2ad464 100644 --- a/django3_saml2_nbplugin/__init__.py +++ b/django3_saml2_nbplugin/__init__.py @@ -8,7 +8,7 @@ this plugin is invoked the settings is already configured, and if you try settings.configure(SAML2_AUTH_CONFIG=user_config) an exception will be raised. """ -from extras.plugins import PluginConfig +from netbox.plugins import PluginConfig from django3_auth_saml2.config import SAML2_AUTH_CONFIG diff --git a/django3_saml2_nbplugin/backends.py b/django3_saml2_nbplugin/backends.py index e02a9c2..de0eed8 100644 --- a/django3_saml2_nbplugin/backends.py +++ b/django3_saml2_nbplugin/backends.py @@ -1,7 +1,8 @@ from typing import Optional -from django.contrib.auth.models import User, Group -from django.core.handlers.wsgi import WSGIRequest from django.conf import settings +from django.contrib.auth.models import User +from django.core.handlers.wsgi import WSGIRequest +from netbox.authentication import Group from saml2.response import AuthnResponse # Subclass from the Netbox provided RemoteUserBackend so that we get the