python3-openid
python3-openid copied to clipboard
Base YadisServiceManager, OpenIDServiceEndpoint on dict to make them 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.
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:
- https://github.com/openid/python-openid/issues/17
- https://stackoverflow.com/questions/20301338/django-openid-auth-typeerror-openid-yadis-manager-yadisservicemanager-object-is
BTW. I've applied this in production for libravatar.org and it WorksForMe(tm).