Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example setup not working #151

Open
FatemeKhodayari opened this issue Jul 16, 2023 · 4 comments
Open

Example setup not working #151

FatemeKhodayari opened this issue Jul 16, 2023 · 4 comments

Comments

@FatemeKhodayari
Copy link

Hi. The code within example_setup directory is not working neither in docker nor in normal setup. In both cases, it returns the following error

Traceback (most recent call last):
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/core/management/base.py", line 86, in wrapped
    saved_locale = translation.get_language()
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/utils/translation/__init__.py", line 254, in get_language
    return _trans.get_language()
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/utils/translation/__init__.py", line 57, in __getattr__
    if settings.USE_I18N:
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__
    self._setup(name)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/conf/__init__.py", line 69, in _setup
    self._wrapped = Settings(settings_module)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/conf/__init__.py", line 170, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "djangosaml2idp/example_setup/idp/idp/settings.py", line 166, in <module>
    from saml2.sigver import get_xmlsec_binary  # noqa
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/saml2/sigver.py", line 16, in <module>
    from importlib_resources import path as _resource_path
ImportError: cannot import name 'path' from 'importlib_resources' (djangosaml2idp/venv/lib64/python3.8/site-packages/importlib_resources/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/core/management/base.py", line 367, in run_from_argv
    connections.close_all()
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/db/utils.py", line 208, in close_all
    for alias in self:
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/utils/connection.py", line 73, in __iter__
    return iter(self.settings)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/utils/connection.py", line 45, in settings
    self._settings = self.configure_settings(self._settings)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/db/utils.py", line 144, in configure_settings
    databases = super().configure_settings(databases)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/utils/connection.py", line 50, in configure_settings
    settings = getattr(django_settings, self.settings_name)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__
    self._setup(name)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/conf/__init__.py", line 69, in _setup
    self._wrapped = Settings(settings_module)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/conf/__init__.py", line 170, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "djangosaml2idp/example_setup/idp/idp/settings.py", line 166, in <module>
    from saml2.sigver import get_xmlsec_binary  # noqa
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/saml2/sigver.py", line 16, in <module>
    from importlib_resources import path as _resource_path
ImportError: cannot import name 'path' from 'importlib_resources' (djangosaml2idp/venv/lib64/python3.8/site-packages/importlib_resources/__init__.py)
@belle05
Copy link

belle05 commented Jul 23, 2023

Hi! Not as a solution, but for the sake of running it locally, it works when you change
from importlib_resources import path as _resource_path

to
from importlib.resources import path as _resource_path

in your local saml2 files.

@atynianov
Copy link

changing pysaml2 version in requirements.txt for both idp and sp to from 6.5.1 to 7.3.1 solved the issue for me

@neighbour-oldhuang
Copy link

neighbour-oldhuang commented Jun 7, 2024

i use docker-compose startup apps, and visite sp /saml2/login/, got errors console log:

returncode=1
error=Signature status: FAILED
Failure reason: KEY-NOT-FOUND
Error: failed to sign file "/tmp/tmpipdsmmnp.xml"

output=
Internal Server Error: /saml2/login/
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/saml2/sigver.py", line 840, in sign_statement
(stdout, stderr, output) = self._run_xmlsec(com_list, [tmp.name])
File "/usr/local/lib/python3.8/site-packages/saml2/sigver.py", line 913, in _run_xmlsec
raise XmlsecError(errmsg)
saml2.sigver.XmlsecError: returncode=1
error=Signature status: FAILED
Failure reason: KEY-NOT-FOUND
Error: failed to sign file "/tmp/tmpipdsmmnp.xml"

output=

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.8/site-packages/djangosaml2/views.py", line 224, in login
session_id, request_xml = client.create_authn_request(
File "/usr/local/lib/python3.8/site-packages/saml2/client_base.py", line 451, in create_authn_request
msg = self._message(
File "/usr/local/lib/python3.8/site-packages/saml2/entity.py", line 577, in _message
signed_req = self.sign(
File "/usr/local/lib/python3.8/site-packages/saml2/entity.py", line 513, in sign
return signed_instance_factory(msg, self.sec, to_sign)
File "/usr/local/lib/python3.8/site-packages/saml2/sigver.py", line 324, in signed_instance_factory
signed_xml = seccont.sign_statement(
File "/usr/local/lib/python3.8/site-packages/saml2/sigver.py", line 1717, in sign_statement
return self.crypto.sign_statement(
File "/usr/local/lib/python3.8/site-packages/saml2/sigver.py", line 842, in sign_statement
raise SignatureError(com_list)
saml2.sigver.SignatureError: ['/usr/bin/xmlsec1', '--sign', '--privkey-pem', '/app/certificates/private.key', '--id-attr:ID', 'urn:oasis:names:tc:SAML:2.0:protocol:AuthnRequest', '--node-id', 'id-38Rm2TT1e8HUs4gop', '--output', '/tmp/tmp31g312dh.xml', '/tmp/tmpipdsmmnp.xml']
[07/Jun/2024 03:39:01] "GET /saml2/login/ HTTP/1.1" 500 124061

@abybaddi009
Copy link

Hi. The code within example_setup directory is not working neither in docker nor in normal setup. In both cases, it returns the following error

Traceback (most recent call last):
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/core/management/base.py", line 86, in wrapped
    saved_locale = translation.get_language()
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/utils/translation/__init__.py", line 254, in get_language
    return _trans.get_language()
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/utils/translation/__init__.py", line 57, in __getattr__
    if settings.USE_I18N:
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__
    self._setup(name)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/conf/__init__.py", line 69, in _setup
    self._wrapped = Settings(settings_module)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/conf/__init__.py", line 170, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "djangosaml2idp/example_setup/idp/idp/settings.py", line 166, in <module>
    from saml2.sigver import get_xmlsec_binary  # noqa
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/saml2/sigver.py", line 16, in <module>
    from importlib_resources import path as _resource_path
ImportError: cannot import name 'path' from 'importlib_resources' (djangosaml2idp/venv/lib64/python3.8/site-packages/importlib_resources/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/core/management/base.py", line 367, in run_from_argv
    connections.close_all()
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/db/utils.py", line 208, in close_all
    for alias in self:
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/utils/connection.py", line 73, in __iter__
    return iter(self.settings)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/utils/connection.py", line 45, in settings
    self._settings = self.configure_settings(self._settings)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/db/utils.py", line 144, in configure_settings
    databases = super().configure_settings(databases)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/utils/connection.py", line 50, in configure_settings
    settings = getattr(django_settings, self.settings_name)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__
    self._setup(name)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/conf/__init__.py", line 69, in _setup
    self._wrapped = Settings(settings_module)
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/django/conf/__init__.py", line 170, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "djangosaml2idp/example_setup/idp/idp/settings.py", line 166, in <module>
    from saml2.sigver import get_xmlsec_binary  # noqa
  File "djangosaml2idp/venv/lib64/python3.8/site-packages/saml2/sigver.py", line 16, in <module>
    from importlib_resources import path as _resource_path
ImportError: cannot import name 'path' from 'importlib_resources' (djangosaml2idp/venv/lib64/python3.8/site-packages/importlib_resources/__init__.py)

Hey @FatemeKhodayari, I have created a sample project and published it here: https://github.com/abybaddi009/django-idp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants