Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#18265 closed New feature (wontfix)

request.user cached value does not track request.session change

Reported by: Vlada Macek Owned by: nobody
Component: contrib.auth Version: dev
Severity: Normal Keywords:
Cc: Melvyn Sopacua Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

During the Single-Sign On technique implementation I came to the need of replacing request.session with a new session or just setting request.session = None.

The descriptor in AuthenticationMiddleware nevertheless does not remember the session for which it sets the request._cached_user.

IMHO, the descriptor should cache the session key when it saves the _cached_user and allow _cached_user to be used only when the session key did not unchange.

Currently everyone who changes the session during the request processing HAS to dig into the AuthenticationMiddleware internals and modify the _cached_user to get valid request.user. That's hard to maintain.

I can offer the patch, but would like to get some response first.

Change History (5)

comment:1 by Vlada Macek, 12 years ago

Type: UncategorizedNew feature

comment:2 by Melvyn Sopacua, 12 years ago

Cc: Melvyn Sopacua added
Triage Stage: UnreviewedDesign decision needed

Submitter will provide patch if feature is considered useful.

comment:3 by Aymeric Augustin, 11 years ago

Resolution: wontfix
Status: newclosed

I'm sorry, but if replacing request.session isn't supported. It isn't possible to anticipate the side effects in general. It's up to you to deal with the specific consequences in your project.

comment:4 by Vlada Macek, 11 years ago

Thank you for the answer. I try to understand your position.

In my humble opinion every piece of code maintaining any cached value should be clever enough to track the cached value validity (or at least support such testing). It looks like it's currently the only thing standing in the way of supporting request.session replacing (which IMO is not too shameful technique by itself).

Last edited 11 years ago by Vlada Macek (previous) (diff)

comment:5 by Aymeric Augustin, 11 years ago

You can write to django-developers and see if other people would be interested by this change.

Note: See TracTickets for help on using tickets.
Back to Top