Opened 13 years ago

Closed 12 years ago

Last modified 12 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, 13 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, 12 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, 12 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. 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).

Version 0, edited 12 years ago by Vlada Macek (next)

comment:5 by Aymeric Augustin, 12 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