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

SAML-Authentication: AttributeError: 'NoneType' object has no attribute 'strip' #7174

Closed
2 tasks done
mkrauser opened this issue Jan 28, 2022 · 2 comments
Closed
2 tasks done
Assignees
Labels
bug Something is broken.
Milestone

Comments

@mkrauser
Copy link

Describe the issue

I've configured weblate to use SAML-Authentication with google as IDP. The mapping is configured in Google like this:

Google Attribute Weblate Attribute Comment
First Name urn:oid:2.5.4.42
Last Name urn:oid:2.5.4.4
Primary email urn:oid:0.9.2342.19200300.100.1.1
Primary email urn:oid:0.9.2342.19200300.100.1.3
Primary email email This was required to make it work

The Full Name is not available as Field on Google's side.

When I debug the details-parameter within the function accounts/pipeline.py::user_full_name, it look's like this:

{
 'email': 'test@test.com',
 'first_name': 'John',
 'fullname': None,
 'last_name': 'Doe',
 'username': None
}

Since fullname is set, but not a string, this call fails:

full_name = details.get("fullname", "").strip()

I already tried

  • I've read and searched the documentation.
  • I've searched for similar issues in this repository.

Steps to reproduce the behavior

  1. Go to '...'
  2. Scroll down to '...'
  3. Click on '...'
  4. See error

Expected behavior

The SAML-Authentication should be successful and the user should be logged in

Screenshots

No response

Exception traceback

[2022-01-28 09:44:06,134: ERROR/367] Internal Server Error: /accounts/complete/saml/
 Traceback (most recent call last):
   File "/usr/local/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
     response = get_response(request)
   File "/usr/local/lib/python3.10/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.10/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
     return view_func(*args, **kwargs)
   File "/usr/local/lib/python3.10/site-packages/django/views/decorators/cache.py", line 56, in _wrapped_view_func
     response = view_func(request, *args, **kwargs)
   File "/usr/local/lib/python3.10/site-packages/weblate/accounts/views.py", line 1256, in social_complete
     return complete(request, backend)
   File "/usr/local/lib/python3.10/site-packages/django/views/decorators/cache.py", line 56, in _wrapped_view_func
     response = view_func(request, *args, **kwargs)
   File "/usr/local/lib/python3.10/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
     return view_func(*args, **kwargs)
   File "/usr/local/lib/python3.10/site-packages/social_django/utils.py", line 46, in wrapper
     return func(request, backend, *args, **kwargs)
   File "/usr/local/lib/python3.10/site-packages/social_django/views.py", line 31, in complete
     return do_complete(request.backend, _do_login, user=request.user,
   File "/usr/local/lib/python3.10/site-packages/social_core/actions.py", line 45, in do_complete
     user = backend.complete(user=user, *args, **kwargs)
   File "/usr/local/lib/python3.10/site-packages/social_core/backends/base.py", line 40, in complete
     return self.auth_complete(*args, **kwargs)
   File "/usr/local/lib/python3.10/site-packages/social_core/backends/saml.py", line 333, in auth_complete
     return self.strategy.authenticate(*args, **kwargs)
   File "/usr/local/lib/python3.10/site-packages/social_django/strategy.py", line 105, in authenticate
     return authenticate(*args, **kwargs)
   File "/usr/local/lib/python3.10/site-packages/django/views/decorators/debug.py", line 42, in sensitive_variables_wrapper
     return func(*func_args, **func_kwargs)
   File "/usr/local/lib/python3.10/site-packages/django/contrib/auth/__init__.py", line 76, in authenticate
     user = backend.authenticate(request, **credentials)
   File "/usr/local/lib/python3.10/site-packages/social_core/backends/base.py", line 80, in authenticate
     return self.pipeline(pipeline, *args, **kwargs)
   File "/usr/local/lib/python3.10/site-packages/social_core/backends/base.py", line 83, in pipeline
     out = self.run_pipeline(pipeline, pipeline_index, *args, **kwargs)
   File "/usr/local/lib/python3.10/site-packages/social_core/backends/base.py", line 113, in run_pipeline
     result = func(*args, **out) or {}
   File "/usr/local/lib/python3.10/site-packages/weblate/accounts/pipeline.py", line 413, in user_full_name
     full_name = details.get("fullname", "").strip()
 AttributeError: 'NoneType' object has no attribute 'strip'

How do you run Weblate?

Docker container

Weblate versions

  • Weblate: 4.10.1
  • Django: 4.0
  • siphashc: 2.1
  • translate-toolkit: 3.5.1
  • lxml: 4.7.1
  • Pillow: 8.4.0
  • bleach: 4.1.0
  • python-dateutil: 2.8.2
  • social-auth-core: 4.1.0
  • social-auth-app-django: 5.0.0
  • django-crispy-forms: 1.13.0
  • oauthlib: 3.1.1
  • django-compressor: 3.1
  • djangorestframework: 3.13.1
  • django-filter: 21.1
  • django-appconf: 1.0.5
  • user-agents: 2.2.0
  • filelock: 3.4.0
  • setuptools: 60.0.4
  • jellyfish: 0.8.9
  • openpyxl: 3.0.9
  • celery: 5.2.1
  • kombu: 5.2.2
  • translation-finder: 2.10
  • weblate-language-data: 2021.7
  • html2text: 2020.1.16
  • pycairo: 1.20.1
  • pygobject: 3.42.0
  • diff-match-patch: 20200713
  • requests: 2.26.0
  • django-redis: 5.2.0
  • hiredis: 2.0.0
  • sentry_sdk: 1.5.1
  • Cython: 0.29.26
  • misaka: 2.1.1
  • GitPython: 3.1.24
  • borgbackup: 1.1.17
  • pyparsing: 3.0.6
  • pyahocorasick: 1.4.2
  • python-redis-lock: 3.7.0
  • Python: 3.10.1
  • Git: 2.30.2
  • psycopg2: 2.9.2
  • psycopg2-binary: 2.9.2
  • phply: 1.2.5
  • chardet: 4.0.0
  • ruamel.yaml: 0.17.17
  • tesserocr: 2.5.2
  • akismet: 1.1
  • boto3: 1.20.26
  • zeep: 4.1.0
  • aeidon: 1.10.1
  • iniparse: 0.5
  • mysqlclient: 2.1.0
  • Mercurial: 6.0
  • git-svn: 2.30.2
  • git-review: 2.2.0
  • Redis server: 6.2.6
  • PostgreSQL server: 13.5
  • Database backends: django.db.backends.postgresql
  • Cache backends: default:RedisCache, avatar:FileBasedCache
  • Email setup: django.core.mail.backends.smtp.EmailBackend: mail.neubaukompass.de
  • OS encoding: filesystem=utf-8, default=utf-8
  • Celery: redis://cache:6379/1, redis://cache:6379/1, regular
  • Platform: Linux 4.19.0-18-cloud-amd64 (x86_64)

Weblate deploy checks

System check identified some issues:

INFOS:
?: (weblate.I021) Error collection is not set up, it is highly recommended for production use
	HINT: https://docs.weblate.org/en/weblate-4.10.1/admin/install.html#collecting-errors
?: (weblate.I028) Backups are not configured, it is highly recommended for production use
	HINT: https://docs.weblate.org/en/weblate-4.10.1/admin/backup.html

System check identified 2 issues (1 silenced).

Additional context

No response

@nijel nijel self-assigned this Jan 28, 2022
@nijel nijel added the bug Something is broken. label Jan 28, 2022
@nijel nijel added this to the 4.11 milestone Jan 28, 2022
@nijel nijel closed this as completed in 33d051b Jan 28, 2022
@github-actions
Copy link

Thank you for your report; the issue you have reported has just been fixed.

  • In case you see a problem with the fix, please comment on this issue.
  • In case you see a similar problem, please open a separate issue.
  • If you are happy with the outcome, don’t hesitate to support Weblate by making a donation.

@mkrauser
Copy link
Author

@nijel Wow, that was fast! Thank you so much for your work!

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

No branches or pull requests

2 participants