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

OpenID: Invalid base64-encoded string #2274

Closed
blueyed opened this issue Apr 21, 2019 · 0 comments · Fixed by #2275
Closed

OpenID: Invalid base64-encoded string #2274

blueyed opened this issue Apr 21, 2019 · 0 comments · Fixed by #2275

Comments

@blueyed
Copy link
Contributor

blueyed commented Apr 21, 2019

I am getting the following error when trying to login/signup with OpenID:

Error at /accounts/openid/login/
Invalid base64-encoded string: number of data characters (29) cannot be 1 more than a multiple of 4

The problem appears to be that the secret (bytes) gets saved via str() into the OpenIDStore (as b'Ks…k8=\n'), which then fails with decodestring in allauth/socialaccount/providers/openid/utils.py in getAssociation:

> …/django-allauth/allauth/socialaccount/providers/openid/utils.py(85)

  72         def storeAssociation(self, server_url, assoc=None):
  73             __import__('pdb').set_trace()
  74             try:
  75                 secret = base64.encodebytes(assoc.secret)
  76             except AttributeError:
  77                 # Python 2.x compat
  78                 secret = base64.encodestring(assoc.secret)
  79             OpenIDStore.objects.create(
  80                 server_url=server_url,
  81                 handle=assoc.handle,
  82                 secret=secret,
  83                 issued=assoc.issued,
  84                 lifetime=assoc.lifetime,
  85  ->             assoc_type=assoc.assoc_type
  86             )
 return None
(Pdb++) OpenIDStore.objects.get()
<OpenIDStore: https://openid.indieauth.com/openid>
(Pdb++) OpenIDStore.objects.get().secret
"b'T…\\n'"

This changed in Django 2.0, where previously force_text would decode the bytes into a string (in TextField), but now str() is used: https://github.com/django/django/blob/ba2057910644d3255a6283a16ceefbd0fceedafc/docs/releases/2.0.txt#L341-L359

Related commit: django/django@301de77

blueyed added a commit to blueyed/django-allauth that referenced this issue Apr 21, 2019
iarp pushed a commit to iarp/django-allauth that referenced this issue Jul 25, 2019
erikdbrown pushed a commit to AltSchool/django-allauth that referenced this issue Mar 4, 2020
erikdbrown pushed a commit to AltSchool/django-allauth that referenced this issue Mar 9, 2020
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

Successfully merging a pull request may close this issue.

1 participant