Error after adding Okta / SAML configs (edited)

454 views
Skip to first unread message

Vinita Shah

unread,
Mar 17, 2021, 7:39:40 PM3/17/21
to NetBox

Error

A module import error occurred during this request. Common causes include the following:
 Missing required packages - This installation of NetBox might be missing one or more required Python packages. These packages are listed in requirements.txt and local_requirements.txt, and are normally installed as part of the installation or upgrade process. To verify installed packages, run pip freeze from the console and compare the output to the list of required packages.
 WSGI service not restarted after upgrade - If this installation has recently been upgraded, check that the WSGI service (e.g. gunicorn or uWSGI) has been restarted. This ensures that the new code is running.The complete exception is provided below:
<class 'ModuleNotFoundError'>No module named 'utilities.auth_backends'Python version: 3.6.9
NetBox version: 2.10.5

·         I have matched the requirements in pip freeze with requirements and local requirements.txt.

·         There is no module named not sure what to check here.

·         No module named 'utilities.auth_backends'

requirements.txt

Django==3.1.3
django-cacheops==5.1
django-cors-headers==3.5.0
django-debug-toolbar==3.1.1
django-filter==2.4.0
django-mptt==0.11.0
django-pglocks==1.0.4
django-prometheus==2.1.0
django-rq==2.4.0
django-tables2==2.3.3
django-taggit==1.3.0
django-timezone-field==4.0
djangorestframework==3.12.2
drf-yasg[validation]==1.20.0
gunicorn==20.0.4
Jinja2==2.11.2
redis==3.5.3
Markdown==3.3.3
netaddr==0.8.0
Pillow==8.0.1
psycopg2-binary==2.8.6
pycryptodome==3.9.9
PyYAML==5.3.1
redis==3.5.3
svgwrite==1.4

local_requirements.com 

netbox-plugin-auth-saml2
#django3_auth_saml2

Configuration.py

REMOTE_AUTH_ENABLED = True
REMOTE_AUTH_HEADER = 'HTTP_REMOTE_USER'
REMOTE_AUTH_BACKEND = 'netbox.custom_auth_backend.SAML2AttrUserBackend'
REMOTE_AUTH_AUTO_CREATE_USER = True
REMOTE_AUTH_DEFAULT_GROUPS = []
REMOTE_AUTH_DEFAULT_PERMISSIONS = []PLUGINS = ['django3_saml2_nbplugin'] #, 'netbox-plugin-auth-saml2']PLUGINS_CONFIG = {
   'django3_saml2_nbplugin': {     # Use the Netbox default remote backend
     'AUTHENTICATION_BACKEND': REMOTE_AUTH_BACKEND,     'ASSERTION_URL': 'https://xxxnetbox.com',     'ENTITY_ID': 'https://xxxnetbox.com/',     'METADATA_LOCAL_FILE_PATH': "/opt/netbox/netbox/netbox/okta_saml.xml",  }
}

 

Message has been deleted
Message has been deleted

Brian Candler

unread,
Mar 18, 2021, 6:38:58 AM3/18/21
to NetBox
I wrote two replies, but they were both deleted.  My guess is that anything which quotes the original message, is getting auto-deleted.  I am going to try again without quoting the original.

Brian Candler

unread,
Mar 18, 2021, 6:44:44 AM3/18/21
to NetBox
This is my final attempt to post an answer.

1. You didn't show the exception backtrace
2. You didn't say what third-party add-ons you were using with Netbox.

Googling for "django3_saml2_nbplugin" I am guessing you might be using this: https://github.com/jeremyschulman/netbox-plugin-auth-saml2

I note that your REMOTE_AUTH_BACKEND does not match what the author suggests at https://github.com/jeremyschulman/netbox-plugin-auth-saml2#netbox-configuration
However, the way REMOTE_AUTH_BACKEND is used has also changed from netbox 2.9.0 onwards.  You have to change "utilities.auth_backends.RemoteUserBackend" to "netbox.authentication.RemoteUserBackend"

Vinita Shah

unread,
Mar 18, 2021, 11:31:09 AM3/18/21
to Brian Candler, NetBox

Thanks Brian.

 

Error is. This is the only info I have

    1. A module import error occurred during this request. Common causes include the following:
    2.  Missing required packages - This installation of NetBox might be missing one or more required Python packages. These packages are listed in requirements.txt and local_requirements.txt, and are normally installed as part of the installation or upgrade process. To verify installed packages, run pip freeze from the console and compare the output to the list of required packages.
    3.  WSGI service not restarted after upgrade - If this installation has recently been upgraded, check that the WSGI service (e.g. gunicorn or uWSGI) has been restarted. This ensures that the new code is running.
    1. The complete exception is provided below:

      6)  <class 'ModuleNotFoundError'>

      7)  No module named 'utilities.auth_backends'

      8)   

      9)  Python version: 3.6.9

      10)NetBox version: 2.10.5

       

       

      My services are up

       

       netbox.service - NetBox WSGI Service

         Loaded: loaded (/etc/systemd/system/netbox.service; enabled; vendor preset: enabled)

         Active: active (running) since Thu 2021-03-18 00:40:34 UTC; 18min ago

           Docs: https://netbox.readthedocs.io/en/stable/

       Main PID: 28356 (gunicorn)

          Tasks: 21 (limit: 2348)

         CGroup: /system.slice/netbox.service

                 ─28356 /opt/netbox/venv/bin/python3 /opt/netbox/venv/bin/gunicorn --pid /var/tmp/netbox.pid --pythonpath /opt/netbox/netbox --config /opt/

                 ─28385 /opt/netbox/venv/bin/python3 /opt/netbox/venv/bin/gunicorn --pid /var/tmp/netbox.pid --pythonpath /opt/netbox/netbox --config /opt/

                 ─28386 /opt/netbox/venv/bin/python3 /opt/netbox/venv/bin/gunicorn --pid /var/tmp/netbox.pid --pythonpath /opt/netbox/netbox --config /opt/

                 ─28388 /opt/netbox/venv/bin/python3 /opt/netbox/venv/bin/gunicorn --pid /var/tmp/netbox.pid --pythonpath /opt/netbox/netbox --config /opt/

                 ─28390 /opt/netbox/venv/bin/python3 /opt/netbox/venv/bin/gunicorn --pid /var/tmp/netbox.pid --pythonpath /opt/netbox/netbox --config /opt/

                 └─28391 /opt/netbox/venv/bin/python3 /opt/netbox/venv/bin/gunicorn --pid /var/tmp/netbox.pid --pythonpath /opt/netbox/netbox --config /opt/

       

      Mar 18 00:40:34 ip-x systemd[1]: Stopped NetBox WSGI Service.

      Mar 18 00:40:34 ip-x systemd[1]: Started NetBox WSGI Service.

      Mar 18 00:40:35 ip-x gunicorn[28356]: [2021-03-18 00:40:35 +0000] [28356] [INFO] Starting gunicorn 20.0.4

      Mar 18 00:40:35 ip-x gunicorn[28356]: [2021-03-18 00:40:35 +0000] [28356] [INFO] Listening at: http://127.0.0.1:8001 (28356)

      Mar 18 00:40:35 ip-x gunicorn[28356]: [2021-03-18 00:40:35 +0000] [28356] [INFO] Using worker: threads

      Mar 18 00:40:35 ip-x gunicorn[28356]: [2021-03-18 00:40:35 +0000] [28385] [INFO] Booting worker with pid: 28385

      Mar 18 00:40:35 ip-x gunicorn[28356]: [2021-03-18 00:40:35 +0000] [28386] [INFO] Booting worker with pid: 28386

      Mar 18 00:40:35 ip-x gunicorn[28356]: [2021-03-18 00:40:35 +0000] [28388] [INFO] Booting worker with pid: 28388

      Mar 18 00:40:35 ip-x gunicorn[28356]: [2021-03-18 00:40:35 +0000] [28390] [INFO] Booting worker with pid: 28390

      Mar 18 00:40:35 ip-x gunicorn[28356]: [2021-03-18 00:40:35 +0000] [28391] [INFO] Booting worker with pid: 28391

       

       

       nginx.service - A high performance web server and a reverse proxy server

         Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)

         Active: active (running) since Thu 2021-03-18 00:27:10 UTC; 33min ago

           Docs: man:nginx(8)

        Process: 26481 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)

        Process: 26495 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)

        Process: 26484 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)

       Main PID: 26496 (nginx)

          Tasks: 2 (limit: 2348)

         CGroup: /system.slice/nginx.service

                 ─26496 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;

                 └─26497 nginx: worker process

       

      Mar 18 00:27:10 ip-x systemd[1]: Stopped A high performance web server and a reverse proxy server.

      Mar 18 00:27:10 ip-x systemd[1]: Starting A high performance web server and a reverse proxy server...

      Mar 18 00:27:10 ip-x systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument

      Mar 18 00:27:10 ip-x systemd[1]: Started A high performance web server and a reverse proxy server.

       

       

      My REMOTE_AUTH_BACKEND is not utilities. It is = 'netbox.custom_auth_backend. SAML2AttrUserBackend'

       

      And I am using PLUGINS = ['django3_saml2_nbplugin'] 

       

       

      Configuration.py

      REMOTE_AUTH_ENABLED = True


      REMOTE_AUTH_BACKEND = 'netbox.custom_auth_backend.SAML2AttrUserBackend'
      REMOTE_AUTH_AUTO_CREATE_USER = True
      REMOTE_AUTH_DEFAULT_GROUPS = []
      REMOTE_AUTH_DEFAULT_PERMISSIONS = []

       

      PLUGINS = ['django3_saml2_nbplugin'] 

      PLUGINS_CONFIG = {
         'django3_saml2_nbplugin': {      
              'AUTHENTICATION_BACKEND': REMOTE_AUTH_BACKEND,

       

              'ASSERTION_URL': 'https://netboxx.com',

       

              'ENTITY_ID': 'https://netboxx.com/',

       

              'METADATA_LOCAL_FILE_PATH': "/opt/netbox/netbox/netbox/xx.xml",

      --
      You received this message because you are subscribed to the Google Groups "NetBox" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
      To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/784256a9-f6f2-4fd3-8816-1dc037dd2d1dn%40googlegroups.com.

      Message has been deleted

      Brian Candler

      unread,
      Mar 18, 2021, 11:43:32 AM3/18/21
      to NetBox
      Why did you pick "netbox.custom_auth_backend. SAML2AttrUserBackend" ? What documentation are you following that said to use that value?

      Vinita Shah

      unread,
      Mar 18, 2021, 4:57:57 PM3/18/21
      to Brian Candler, NetBox

      Fixed this by changing

      "utilities.auth_backends.RemoteUserBackend" to "netbox.authentication.RemoteUserBackend"

       

      In my custom_auth_backend python script.

       

      Thank you Brian. Appreciate your help on this.

       


      Date: Thursday, March 18, 2021 at 8:43 AM
      To: NetBox <netbox-...@googlegroups.com>

      --

      You received this message because you are subscribed to the Google Groups "NetBox" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.

      Reply all
      Reply to author
      Forward
      0 new messages