Thanks for your thoughts. I think most of the points you've raised were discussed during the implementation of this, either on the ticket (#20922) or on the linked pull request (or the documentation itself). Could you please take a look at the discussion there if you haven't? If after reading that you still have disagreements, please raise the issue on django-developers rather than this ticket tracker. Thanks!
Suggestions for documentations edits or additions would also be welcome.
p.s. To address one of your points, one of the decisions was indeed to put the burden on third party app coders to serialize session data as simple data types like strings which would be compatible with JSON. We made this change to contrib.messages for example.
The inconvenience is breaking compatibility with all third party apps that rely on storing extended data types (such as those supported by DjangoJSONEncoder) with the default settings. Properly serializing datetime (possibly tz-aware) can be hard, and changing the default puts the burden on third party apps coders.
They would have the option to either add two complexity layers (properly serializing/deserializing datetime objects, and not breaking compatibility with the previous versions of the same app), or to break compatibility with Django default settings.
I think the option of reverting the default to pickle should be also considered.
- using the raw JSONEncoder by default is not offering any significant security advantage over using an extended encoder. I feel like it's going to discourage coders to use JSONSerializer at all.
But I believe this decision didn't give a realistic weight to the impact on the community.
Btw could it be that you are mixing out Encoder and Serializer?
Personally I don't see any improvement in using an extended encoder -- in the end it's just more work for us and people complaining why we don't support their $magical class. In most if not all cases storing full objects in the session is wrong; what we could have supported would be timestamps, but those are storable as utc seconds easily enough… Why would the current status be discouraging anyone?
[...] that's what I'd call impact; the current impact is __only__ on [...]
The examples you mentioned (forms, admin) were significant improvements themselves, with big benefits to Django users. Switching the default session serializer to JSONSerializer is providing no benefit to any user. It's addressing a security problem (which is already documented) that only a few users have (can you provide a big^H^H^H list of users who use signed cookies but can't add a SESSION_SERIALIZER setting next to their SESSION_COOKIE_HTTPONLY and SESSION_COOKIE_SECURE settings?).
On Friday, September 20, 2013 2:55:33 PM UTC+2, Florian Apolloner wrote:Btw could it be that you are mixing out Encoder and Serializer?No, I say Serializer when I mean... well, a serializer, as specified by SESSION_SERIALIZER. I say Encoder when I mean the Encoder class used by JSONSerializer. It could be the one built into the json module, or it could be a derived one, such as DjangoJSONEncoder here https://github.com/django/django/blob/1.6b4/django/core/serializers/json.py#L79
It's either to change the default to PickleSerializer
or to mitigate the JSONSerializer issue supporting these data types:
- datetime, timedelta objects (supported by DjangoJSONEncoder)
- decimal objects (supported by DjangoJSONEncoder)
- arbitrary binary strings (b'\xe8')
- Geometry objects
And the answer is: there's no way for a matching Decoder to know when to decode any of these types, since there's no schema available.
A basic tenant in securing systems is that you make each piece of the system responsible for it's own security and you don't have it depend on the security of another system. Moving away from pickle as the default serialization engine ensures this property for the storage of session data.
I talked with the OP [or someone who talks a _lot_ like the OP:)]
And the answer is: there's no way for a matching Decoder to know when to decode any of these types, since there's no schema available.