jeremyschulman / netbox-plugin-auth-saml2

Netbox plugin for SSO using SAML2
119 stars 23 forks source link

importlib-resources version 6.0.0 #72

Open gurretp opened 1 year ago

gurretp commented 1 year ago

The new version of importlib-resources is not compatible with the plugin

step to reproduce: 1 install netbox and netbox-plugin-auth-saml2 2 pip install importlib-resources==6.0.0 3 run netbox manage script : ./manage.py migrate --noinput

the same configuration works fine with importlib-resources version 5.13.0

Expected Behavior ~/releases/netbox-3.5.6/netbox > ./manage.py migrate --noinput Operations to perform: Apply all migrations: admin, auth, circuits, contenttypes, core, dcim, django_rq, extras, ipam, sessions, social_django, taggit, tenancy, users, virtualization, wireless Running migrations: No migrations to apply.

Observed Behavior

~/releases/netbox-3.5.6/netbox > ./manage.py migrate --noinput Traceback (most recent call last): File "./manage.py", line 10, in execute_from_command_line(sys.argv) File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django/core/management/init.py", line 446, in execute_from_command_line utility.execute() File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django/core/management/init.py", line 440, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django/core/management/base.py", line 402, in run_from_argv self.execute(*args, cmd_options) File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django/core/management/base.py", line 448, in execute output = self.handle(*args, *options) File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django/core/management/base.py", line 96, in wrapped res = handle_func(args, kwargs) File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django/core/management/commands/migrate.py", line 97, in handle self.check(databases=[database]) File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django/core/management/base.py", line 475, in check all_issues = checks.run_checks( File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django/core/checks/registry.py", line 88, in run_checks new_errors = check(app_configs=app_configs, databases=databases) File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django/core/checks/urls.py", line 14, in check_url_config return check_resolver(resolver) File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django/core/checks/urls.py", line 24, in check_resolver return check_method() File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django/urls/resolvers.py", line 494, in check for pattern in self.url_patterns: File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django/utils/functional.py", line 57, in get res = instance.dict[self.name] = self.func(instance) File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django/urls/resolvers.py", line 715, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django/utils/functional.py", line 57, in get res = instance.dict[self.name] = self.func(instance) File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django/urls/resolvers.py", line 708, in urlconf_module return import_module(self.urlconf_name) File "/usr/lib64/python3.8/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 671, in _load_unlocked File "", line 843, in exec_module File "", line 219, in _call_with_frames_removed File "/srv/netbox/releases/netbox-3.5.6/netbox/netbox/urls.py", line 8, in from extras.plugins.urls import plugin_admin_patterns, plugin_patterns, plugin_api_patterns File "/srv/netbox/releases/netbox-3.5.6/netbox/extras/plugins/urls.py", line 38, in urlpatterns = import_string(f"{plugin_path}.api.urls.urlpatterns") File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django/utils/module_loading.py", line 30, in import_string return cached_import(module_path, class_name) File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django/utils/module_loading.py", line 15, in cached_import module = import_module(module_path) File "/usr/lib64/python3.8/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django3_saml2_nbplugin/api/urls.py", line 5, in path('', include('django3_auth_saml2.urls', namespace='django3_auth_saml2')), File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django/urls/conf.py", line 38, in include urlconf_module = import_module(urlconf_module) File "/usr/lib64/python3.8/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django3_auth_saml2/urls.py", line 3, in from . import views File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/django3_auth_saml2/views.py", line 20, in from saml2 import ( File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/saml2/entity.py", line 10, in from saml2.metadata import ENDPOINTS File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/saml2/metadata.py", line 2, in from saml2.algsupport import algorithm_support_in_metadata File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/saml2/algsupport.py", line 2, in from saml2.sigver import get_xmlsec_binary File "/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/saml2/sigver.py", line 16, in from importlib_resources import path as _resource_path ImportError: cannot import name 'path' from 'importlib_resources' (/srv/netbox/current/venv-py3/lib64/python3.8/site-packages/importlib_resources/init.py)

MichalMMac commented 1 year ago

I experience the same problem. The import error is happening in pysaml2 library used by django3_auth_saml2 There is an issue for it: https://github.com/IdentityPython/pysaml2/issues/917. path function was clearly removed from importlib_resources v6.0

The workaround mentioned in the linked issue works for me. I put importlib-resources==5.13.0 into my plugin_requirements.txt (for now).

PieterL75 commented 1 year ago

I guess you meant to put importlib-resources==5.13.0 in the local_requirements.txt of /opt/netbox Make sure it is before the django3-auth-saml2 and netbox-plugin-auth-saml2 lines

MichalMMac commented 1 year ago

@PieterL75 You are correct about the order of configurations lines. I probably chose a different filename to use in Dockerfile-Plugins.

MichalMMac commented 1 year ago

Up-to-date version of pysaml2 library does not suffer from this problem. The culprit is django3-auth-saml2 defining an explicit version requirement for pysaml2.

MichalMMac commented 1 year ago

And there is actually a PR for this https://github.com/jeremyschulman/django3-auth-saml2/pull/17

jeremyschulman commented 1 year ago

@MichalMMac, all - Thank you. I will update the other package today. I appreciate the heads up and your patience.

OliElli commented 1 year ago

Just hit this but thankfully the workaround works. Are you able to create a new release tag to include the fix?

jeremyschulman commented 1 year ago

@OliElli - are you referring to this release that was tagged v0.6.1? https://github.com/jeremyschulman/django3-auth-saml2/releases/tag/v0.6.1

OliElli commented 1 year ago

~Ah no, I was expecting a bump in the release tag for this project, should I instead separately tag the version of django-auth-saml2?~

Oops misunderstood, I'm already pinning this version so I'll update it. Thanks!