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

Base YadisServiceManager, OpenIDServiceEndpoint on dict to make them serializable #68

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ofalk
Copy link

@ofalk ofalk commented Feb 26, 2024

Both objects end up as data in a serialized object, when used with django-openid-auth. Django switched to JSONSerializer that can no longer serialize these objects (in contrast to the Picke-based serializer) and hence throws an error. The easiest solution is to base both on dict objects that can be easily be serialized by JSON, but it also requires us to create corresponding getter/setter methods, plus ensure if we end up with a plain dict, we "convert" that to the real object: The new _from_dict() functions.

This problem has been described in the past, but the usual workaround was to switch to PickleSerializer, which poses a security risk and isn't actually a real fix. Pre-Django 5.x using the Pickle-based serializer worked, but now it's completely gone and that workaround is no longer an option.

This is my take on fixing the underlying issue of YaidServiceManager and OpenIDServiceEndpoint not being serializable with JSON session serializer.

Refs:

…ON) serializable

Both objects end up as data in a serialized object, when used with
django-openid-auth. Django switched to JSONSerializer that can no longer
serialize these objects (in contrast to the Picke-based serializer) and
hence throws an error. The easiest solution is to base both on dict
objects that can be easily be serialized by JSON, but it also requires
us to create corresponding getter/setter methods, plus ensure if we end
up with a plain dict, we "convert" that to the real object: The new
_from_dict functions.
@ofalk
Copy link
Author

ofalk commented Feb 26, 2024

BTW. I've applied this in production for libravatar.org and it WorksForMe(tm).

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 this pull request may close these issues.

1 participant