From ba8f1b92a88a064504ea55ac568634c56707d96c Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sat, 9 Mar 2013 05:31:13 +0000 Subject: [PATCH] Put the user's name in post-authentication requests. In GET requests, it goes in the path; for POST requests, it can go in `%user'. This is to prevent caches from returning the wrong pages. I feel a bit stupid about not fixing this earlier. --- chpwd | 11 +++++++++++ list.fhtml | 1 + 2 files changed, 12 insertions(+) diff --git a/chpwd b/chpwd index 1e4248b..5925ddd 100755 --- a/chpwd +++ b/chpwd @@ -87,6 +87,7 @@ for short, long, props in [ ## The special variables, to be picked out by `cgiparse'. CGI.SPECIAL['%act'] = None CGI.SPECIAL['%nonce'] = None +CGI.SPECIAL['%user'] = None ## We don't want to parse arguments until we've settled on a context; but ## issuing redirects in the early setup phase fails because we don't know @@ -143,6 +144,14 @@ def dispatch_cgi(): ## `cgi-noauth'. if ctx != 'cgi-noauth': + ## The next part of the URL should be the user name, so that caches don't + ## cross things over. + expuser = CGI.SPECIAL['%user'] + if expuser is None: + if i >= np: raise U.ExpectedError, (404, 'Missing user name') + expuser = CGI.PATH[i] + i += 1 + ## If there's no token cookie, then we have to bail. try: token = CGI.COOKIE['chpwd-token'] except KeyError: @@ -166,6 +175,8 @@ def dispatch_cgi(): except HA.AuthenticationFailed, e: CGI.redirect(CGI.action('login', why = e.why)) return + if CU.USER != expuser: raise U.ExpectedError, (401, 'User mismatch') + CGI.STATE.kw['user'] = CU.USER ## Invoke the subcommand handler. c.cgi(CGI.PARAM, CGI.PATH[i:]) diff --git a/list.fhtml b/list.fhtml index a1b3f2c..3753313 100644 --- a/list.fhtml +++ b/list.fhtml @@ -121,6 +121,7 @@ + -- 2.11.0