python-social-auth / social-app-django

Python Social Auth - Application - Django
BSD 3-Clause "New" or "Revised" License
2.04k stars 380 forks source link

Incorrect padding with FedoraOpenId #241

Open atodorov opened 4 years ago

atodorov commented 4 years ago

I have previously reported this under https://github.com/python-social-auth/social-core/issues/270 which was then closed in favor of https://github.com/python-social-auth/social-app-django/issues/135, which was fixed in https://github.com/python-social-auth/social-app-django/pull/136.

However I am still seeing a problem with social_django 3.1.0 on Python 3.6

Error: Incorrect padding
  File "django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "social_django/utils.py", line 49, in wrapper
    return func(request, backend, *args, **kwargs)
  File "social_django/views.py", line 23, in auth
    return do_auth(request.backend, redirect_name=REDIRECT_FIELD_NAME)
  File "social_core/actions.py", line 27, in do_auth
    return backend.start()
  File "social_core/backends/base.py", line 34, in start
    if self.uses_redirect():
  File "social_core/backends/open_id.py", line 242, in uses_redirect
    return self.openid_request().shouldSendRedirect()
  File "social_core/backends/open_id.py", line 248, in openid_request
    params))
  File "openid/consumer/consumer.py", line 359, in begin
    return self.beginWithoutDiscovery(service, anonymous)
  File "openid/consumer/consumer.py", line 382, in beginWithoutDiscovery
    auth_req = self.consumer.begin(service)
  File "openid/consumer/consumer.py", line 610, in begin
    assoc = self._getAssociation(service_endpoint)
  File "openid/consumer/consumer.py", line 1178, in _getAssociation
    assoc = self.store.getAssociation(endpoint.server_url)
  File "social_core/store.py", line 43, in getAssociation
    for assoc_id, association in self.assoc.oids(server_url, handle):
  File "social_core/storage.py", line 227, in oids
    for assoc in cls.get(**kwargs)
  File "social_core/storage.py", line 227, in <listcomp>
    for assoc in cls.get(**kwargs)
  File "social_core/storage.py", line 235, in openid_association
    return OpenIdAssociation(assoc.handle, base64.decodestring(secret),
  File "python3.6/base64.py", line 554, in decodestring
    return decodebytes(s)
  File "python3.6/base64.py", line 546, in decodebytes
    return binascii.a2b_base64(s)

Looking at my original traceback and this one they look the same. If you can give me some tips how to debug I will send a pull request.

atodorov commented 4 years ago

Note: I am interested if others are having the same problem with other OpenID providers or not. Please comment so we can figure out if this is caused by the payload sent back from Fedora.