Commit Graph

60 Commits

Author SHA1 Message Date
Katie Smith
c30d94bf5c Stop automatically resending email verification links
This commit stops a new email verification link from being sent to a
user if they click on an email link which has expired or which has
already been used. Instead, they will be see an error message with a
link to the sign in page. This stops the situation where someone could
log in indefinitely (without the needing to enter their password) by
trying to use a used / expired email verification link and receiving a
valid link automatically.
2019-01-22 13:59:16 +00:00
Katie Smith
398aef6d4c Revert "Stop automatically resending email verification links" 2019-01-21 15:44:15 +00:00
Katie Smith
9095893e03 Stop automatically resending email verification links
This commit stops a new email verification link from being sent to a
user if they click on an email link which has expired or which has
already been used. Instead, they will be see an error message with a
link to the sign in page. This stops the situation where someone could
log in indefinitely (without the needing to enter their password) by
trying to use a used / expired email verification link and receiving a
valid link automatically.
2019-01-21 14:29:22 +00:00
Leo Hemsted
3551d36f32 bump reqs 2018-11-14 13:35:24 +00:00
Leo Hemsted
0dabd4ffc0 remove any old file upload data on sign in
if a user signs in again, clear their file upload data from any
aborted journeys from before, so that their cookies don't fill up

also add some temporary logging when the session starts getting full.
2018-04-03 14:58:50 +01:00
Leo Hemsted
e000552e56 redirect to show_accounts_or_dashboard on login
show_accounts_or_dashboard has logic about where you should redirect
to. If we let it do this, then that's nicer than duplicating its
logic. We found that it wasn't accounting for orgs in redirects
properly.
2018-03-19 16:41:16 +00:00
Leo Hemsted
2f37e37278 rename choose_service to choose_account 2018-03-14 15:39:55 +00:00
Chris Hill-Scott
f3a0c505bd Enforce order and style of imports
Done using isort[1], with the following command:
```
isort -rc ./app ./tests
```

Adds linting to the `run_tests.sh` script to stop badly-sorted imports
getting re-introduced.

Chosen style is ‘Vertical Hanging Indent’ with trailing commas, because
I think it gives the cleanest diffs, eg:
```
from third_party import (
    lib1,
    lib2,
    lib3,
    lib4,
)
```

1. https://pypi.python.org/pypi/isort
2018-02-27 16:35:13 +00:00
chrisw
04f6d0a5e0 Updated code used flow 2017-11-09 17:06:57 +00:00
chrisw
1effec78e5 alter login flow to allow for email auth login 2017-11-09 16:07:28 +00:00
Leo Hemsted
1cacd92411 Merge pull request #1153 from alphagov/forget-me
Remove remember me cookie
2017-03-06 09:39:52 +00:00
Leo Hemsted
85efe0d117 remove flask's builtin remember me functionality
we don't need it cos we do it all ourselves
2017-03-02 16:55:10 +00:00
Rebecca Law
35f61125e8 Fix the user flow when the user account is locked.
The user has 10 tries at the password, after which the account is locked.
The same is true for the verify code, the user will have 10 tries before the user account is locked.
2017-02-28 14:41:31 +00:00
Rebecca Law
2d4e0a0631 Added a reset of failed_login_count when the user is activated.
Update user from the update-password api call (which resets the failed_login_count)
2017-02-28 11:56:40 +00:00
Leo Hemsted
4df12f5f4e ensure other 2FA pages also handle session id
specifically, the 2FA page when you first create an account is different to the login 2FA page
and also the 2FA page when you change your phone number is different as well
2017-02-24 16:32:59 +00:00
Leo Hemsted
f14a836baa check users' session id.
when a user enters their 2FA code, the API will store a random UUID
against them in the database - this code is then stored on the cookie
on the front end.

At the beginning of each authenticated request, we do the following
steps:
  * Retrieve the user's cookie, and get the user_id from it
  * Request that user's details from the database
  * populate current_user with the DB model
  * run the login_required decorator, which calls
    current_user.is_authenticated

is_authenticated now also checks that the database model matches the
cookie for session_id. The potential states and meanings are as follows:

 database | cookie | meaning
----------+--------+---------
 None     | None   | New user, or system just been deployed.
          |        | Redirect to start page.
----------+--------+---------
 'abc'    | None   | New browser (or cleared cookies). Redirect to
          |        | start page.
----------+--------+---------
 None     | 'abc'  | Invalid state (cookie is set from user obj, so
          |        | would only happen if DB is cleared)
----------+--------+---------
 'abc'    | 'abc'  | Same browser. Business as usual
----------+--------+---------
 'abc'    | 'def'  | Different browser in cookie - db has been changed
          |        | since then. Redirect to start
2017-02-22 17:31:13 +00:00
Imdad Ahad
2c51792ae5 Update two-factor to use new update password endpoint and refactor tests 2017-02-20 14:55:28 +00:00
Rebecca Law
cf3a933b1e Updated error message is the code is not the right size or data type.
Updated two_factor to error is the user account is locked (locked = over 10 failed_login_count)
2017-02-15 14:56:22 +00:00
Leo Hemsted
08881e5bd1 add get_active_services method
* all current invocations of get_services now call get_active_services
  EXCEPT for platform admin page (where we want to see inactive services
* cleaned up parameter names and unpacking (since *params is unhelpful)
* fixed incorrect kwarg name in conftest
2016-11-16 11:08:20 +00:00
Chris Hill-Scott
14b99e5a24 Go to platform admin page when logging in
If you’re a platform admin, you should go straight to the platform admin
page when you log in.

The all services page is just a crappier version of the same thing,
without all the stats, etc.
2016-10-30 09:16:35 +00:00
Imdad Ahad
defa7ac2c8 Remove spacing 2016-09-09 15:24:56 +01:00
Imdad Ahad
9eab8a726f - Add test to check that two-factor auth activates a user as expected
- Ensure DB user activation statusupdate only executed when required
- Fix test_should_activate_user_after_verify
2016-09-09 15:22:56 +01:00
Imdad Ahad
171eec5984 Remove pdb breaks 2016-09-08 16:59:32 +01:00
Imdad Ahad
65072e41d3 Fix issue where exception thrown when user does not activate email but successfully completes forgotten-password flow (which includes 2f) 2016-09-08 16:57:06 +01:00
Leo Hemsted
539950d772 when not logged in, redirect to sign-in
parts of the initial setup/login stages were throwing 500s if user
not already in process (ie: user directly navigated to url):
* /resend-email-verification
* /text-not-received
* /send-new-code
* verify
2016-06-17 13:53:48 +01:00
Adam Shimali
18ba6c16b4 In case user details were not in session the redirect did not use
url_for to redirect to sign in.
2016-06-06 14:46:16 +01:00
Adam Shimali
25170e7e42 Removed unused imports 2016-05-18 14:39:06 +01:00
Nicholas Staples
3122500ce0 Failed login count set to zero with password reset. 2016-04-26 11:51:34 +01:00
Nicholas Staples
48daac7b94 Merging conflict with two_factor.py
Fixed merge mistake with two_factor.py.
2016-03-30 10:11:06 +01:00
Nicholas Staples
644336b151 Merge with master. 2016-03-29 22:50:40 +01:00
Rebecca Law
b9528d49c4 Merge branch 'master' into platform-admin 2016-03-21 15:37:35 +00:00
Adam Shimali
792b42017a Revert "In registration flow If new sms requested then check and send redirected to two factor" 2016-03-21 13:44:53 +00:00
Rebecca Law
8ab4a5b150 Merge branch 'master' into platform-admin
Conflicts:
	tests/app/main/views/test_dashboard.py
2016-03-21 13:23:46 +00:00
Adam Shimali
c2c98248a1 If new sms requested, then check and send redirected to two factor
in all cases but should have redirected to verify for pending users.
2016-03-21 12:32:07 +00:00
Rebecca Law
d003dc4aa9 [WIP]: fixing unit tests 2016-03-18 10:49:22 +00:00
Adam Shimali
8561391cd2 The verify view was not passing along the next param to the two factor
view.

Now if it is passed and it is a url on the same domain that request
originates from then it is used.
2016-03-14 16:58:39 +00:00
Rebecca Law
29ddad60e7 Merge branch 'master' into forgot-password
Conflicts:
	app/main/views/two_factor.py
2016-03-08 15:03:25 +00:00
Rebecca Law
e735d772fe Added a test to check that the password is updated when the password exists in the session object on the two-factor page. 2016-03-08 14:58:29 +00:00
Martyn Inglis
5429107f93 Removed remember me checkbox
- remember me functionality always applied.
2016-03-07 14:39:20 +00:00
Nicholas Staples
c959678c49 Remember me functionality added and tested.
Merge extra.

Fixed comment.
2016-02-24 17:32:15 +00:00
Chris Hill-Scott
939954cd64 Skip ‘choose service’ page if user has one service
We used to do this by redirecting on the choose service page. However when we
lost the dropdown and this page also became the page for adding a new service
(in 3617f2e936) the redirect was removed.

This commit re-adds the redirect on the two factor page, so that it only happens
on first login.

So the flows are:

**Multiple services**
```
`Sign in` → `Enter two factor code` → `Choose service` → `Service dashboard`
```

**One service**
```
`Sign in` → `Enter two factor code` → `Service dashboard`
```

**No services (you’ve deleted all your services)**
`Sign in` → `Enter two factor code` → `Choose service` → `Add new service`
2016-02-05 14:50:55 +00:00
Rebecca Law
0dd20abbb3 Replace Current service with chosen service name. 2016-01-28 17:20:34 +00:00
Nicholas Staples
e322a5f1c3 Review comment fixes. 2016-01-28 11:34:15 +00:00
Nicholas Staples
2d35f5f36a All tests passing and merged with master. 2016-01-27 16:30:33 +00:00
Nicholas Staples
6959d695d3 Working tests, hopefully all code changes done. 2016-01-27 12:22:32 +00:00
Chris Hill-Scott
f15a59b0d6 Use 🐍 case in function names 2016-01-14 11:12:03 +00:00
Chris Hill-Scott
58317afdf1 Add page to choose services
Because a user can have multiple services, they need a way to navigate between
them. Normally they can use the ▶ Switcher to do this, except when:

- they first sign in
- they are on a page which isn’t associated with a service (eg user profile) in
  which case we can’t use the switcher because it won’t know what the ‘current’
  service is

So this commit adds a new page with a (fake) list of services.
2016-01-14 09:55:40 +00:00
Chris Hill-Scott
04b9c120d4 Add mocked service ID to all service-specific pages 2016-01-13 12:44:12 +00:00
Nicholas Staples
7001d8261d Fix for security hole with setting session['user_id'] before second factor of authentication has been authorised. 2016-01-07 12:43:10 +00:00
Nicholas Staples
ecc3485d72 Merge conflicts with master. 2016-01-05 17:24:13 +00:00