Opened 9 years ago
Last modified 12 days ago
#28473 assigned Bug
Consider SCRIPT_NAME for SECURE_REDIRECT_EXEMPT setting
| Reported by: | Jonas Haag | Owned by: | gaweng |
|---|---|---|---|
| Component: | HTTP handling | Version: | 1.11 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | yes |
| Easy pickings: | no | UI/UX: | no |
Description
Similar to #25598, SCRIPT_NAME should be considered for SECURE_REDIRECT_EXEMPT as well.
Generally speaking, there should be consistent handling of SCRIPT_NAME in the settings -- either consider it for all settings or for none.
Change History (7)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
See #25598 for discussion of the use case (the setting should be independent from the subpath the application is mounted at). This breaks existing sites, yes. I haven't had a look into the implementation.
comment:3 by , 9 years ago
| Component: | Uncategorized → HTTP handling |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:4 by , 2 months ago
I've got the same use case :
I set SCRIPT_NAME to "/some_script_name".
At first I wanted http://url.com/some_script_name/exempt1 and http://url.com/some_script_name/exempt2 to be served via http.
So I set SECURE_REDIRECT_EXEMPT=[r"^exempt1$", "^exempt2$""]
It took me some time to figure out that SECURE_REDIRECT_EXEMPT was not taking into account SCRIPT_NAME
I had to modify SECURE_REDIRECT_EXEMPT to [r"^some_script_name/exempt1$", r"^some_script_name/exempt2$"]
Seems to me using request.path_info rather than request.path would do the trick.
But changing that would break existing sites using SCRIPT_NAME + SECURE_REDIRECT_EXEMPT
Should we at least document this strange behaviour in https://docs.djangoproject.com/en/6.0/ref/settings/#secure-redirect-exempt ?
(I am using django version 6.0.5)
comment:5 by , 2 months ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:7 by , 12 days ago
| Patch needs improvement: | set |
|---|
The PR is marked as a draft on github, I'm going to take that as a signal that it is not ready for review yet. So I'm checking patch needs improvement to take it out of the review queue. If it is ready for review go ahead mark it as ready on github and I'll jump in.
I guess the idea would be to use
request.path_infoinstead ofrequest.pathin the SecurityMiddleware?Can you elaborate on the use case and how the behavior will change? Could the change break existing working configurations?