Merge lp:~deryck/launchpad/reauth-for-email-363916 into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Deryck Hodge on 2012-08-07 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 15763 |
| Proposed branch: | lp:~deryck/launchpad/reauth-for-email-363916 |
| Merge into: | lp:launchpad |
| Prerequisite: | lp:~deryck/launchpad/support-pape-max-auth-age |
| Diff against target: |
660 lines (+198/-93) 6 files modified
lib/lp/registry/browser/person.py (+9/-1) lib/lp/registry/stories/gpg-coc/xx-gpg-coc.txt (+6/-0) lib/lp/registry/stories/mailinglists/subscriptions.txt (+102/-88) lib/lp/services/webapp/login.py (+17/-4) lib/lp/services/webapp/tests/test_session.py (+42/-0) lib/lp/testing/pages.py (+22/-0) |
| To merge this branch: | bzr merge lp:~deryck/launchpad/reauth-for-email-363916 |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Richard Harding (community) | 2012-08-07 | Approve on 2012-08-07 | |
|
Review via email:
|
|||
Commit Message
Require users to re-authenticate when changing email address info.
Description of the Change
This branch ensures that a user has to re-authenticate when editing email info. This builds on the work I did in the pre-req branch to add support for PAPE extension's max_auth_age option when logging in.
The work here is really to add a check on the freshness of a login. If the login is less than 2 minutes old, we allow the user to edit his or her email settings. If not, we signal for a fresh login. To do this, the lp session is updated to store the logintime, and then a helper method is added to check the logintime in the session. There is a test added for this. The only other new work is to use this isFreshLogin helper in the view and redirect too +login if a fresher login is required. All the rest is updating doctests to ensure we have a fresh login to avoid the isFreshLogin, and there is a new setupBrowser function to help do this in doctests.
In later branches, I'll apply this for ssh and gpg and will factor out the code in lp.registry.
The work does add about 100 lines of code, but I have preceeding branches that refactored tests to prepare for this work. And in total, I'm still about -200 LOC, even after this branch lands.
There is a bit of lint still in the long subscriptions doctest, but none that I added. I didn't, however, fix the existing lint because the diff would have grown significantly for very minor lint changes (mostly too long lines in the documentation parts of the test).
| Deryck Hodge (deryck) wrote : | # |
Thanks for the review, Rick!
The test helper is following the pattern of setupBrowserFor
As for line #515, I think that's just a style preference and we don't have a rule about being explicit there, I don't think. I prefer the return by itself, rather than inside an else statement. Less code and all, for the same result.
For the timing question, I wondered even if it should be a config value, but wasn't sure. So I'll keep thinking on that, but roll on forward for now. If I changed it, I'll do it in one of the follow on branches.
Thanks, again, for the review!

Should the setupBrowserFre shLogin provide the ability to setup based on email/etc to skip some test boilerplate? It could use kwargs to allow passing an email or name for the getByXXX
#515
Can we add the else just to jump out the if condition returning a value
#517
Should the timing be a constant in the module for easy finding/change/use?