Commit Graph

129 Commits

Author SHA1 Message Date
Kenneth Kehl
22f9ff603a try using h3 instead of h4 2024-10-07 09:11:10 -07:00
Kenneth Kehl
86b217b1df remove extrtaneous comments 2024-09-26 09:22:16 -07:00
Kenneth Kehl
ddf9c6d3ec fix tests maybe 2024-09-03 10:37:05 -07:00
Kenneth Kehl
9e9ba9186a try mock 2024-09-02 10:30:29 -07:00
Kenneth Kehl
dcc8055377 more work on load test 2024-09-02 07:51:57 -07:00
Kenneth Kehl
c67407f090 fix some tests 2024-08-23 12:59:00 -07:00
Kenneth Kehl
bf556eb408 make settings button invisible if you don't have permission to manage settings 2024-07-16 13:01:12 -07:00
Kenneth Kehl
5a2ab02da6 initial 2024-07-16 09:57:07 -07:00
Kenneth Kehl
058a999ed0 ugh 2024-07-11 09:38:32 -07:00
Kenneth Kehl
26988d255f remove logged_in_elsewhere as per code review feedback 2024-05-08 12:45:01 -07:00
Kenneth Kehl
125ad7a2f7 remove logged in elsewhere check 2024-05-07 11:11:12 -07:00
Kenneth Kehl
cee2552706 notify-admin-931 2023-12-04 14:52:48 -08:00
Kenneth Kehl
36987e7202 notify-api-861 show eastern time 2023-11-16 12:24:27 -08:00
Kenneth Kehl
8c9721d8e2 notify-api-412 use black to enforce python coding style 2023-08-25 09:12:23 -07:00
Kenneth Kehl
476644369d notify-admin-211 remove nhs-specific code 2023-08-24 07:49:42 -07:00
Carlo Costino
9e609efa1c Remove webauthn hooks
This changeset removes webauthn from the Notify.gov admin app.  We are not using webauthn at all in our implementation and will be looking at an entirely different authentication system in the near future.

Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
2023-08-14 16:59:38 -04:00
Steven Reilly
13d0e46b52 blunt rename of org (#620) 2023-07-12 12:09:44 -04:00
Carlo Costino
92d25f5a69 Convert frontend display to be just UTC (#540)
This changeset converts the display of dates and times to be just UTC to match the recent changes in the backend.  This unwinds a bit of work that was done previously and allows us to start with a clean slate in how we want to approach displaying dates and times going forward. It also adds a bit of explanatory text to help users.

Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
Co-authored-by: stvnrlly <steven.reilly@gsa.gov>
2023-06-12 15:49:48 -04:00
Ryan Ahearn
a42617f776 Add logging around auth{entication,orization} calls 2023-04-26 11:25:24 -04:00
stvnrlly
293b3e2609 cleanup 2022-11-28 20:48:25 -05:00
stvnrlly
d45cbb2c86 util for naive dt parsing 2022-11-28 20:40:53 -05:00
stvnrlly
e12e780a05 code cleanup 2022-11-28 15:53:56 -05:00
stvnrlly
8bd1285bfa more test fixes 2022-11-28 10:48:51 -05:00
stvnrlly
46723b6c11 initial timezone pass, which breaks many tests 2022-11-22 12:00:29 -05:00
Chris Hill-Scott
c6dc0d513e Allow editing of pending users
At the moment if a user is pending we don’t show the ‘change’ link.

This is unhelpful because:
- there’s no way to remove this user
- there’s no way to change their phone number, if the reason that
  they are still pending is because they’ve been unable to receive
  the two factor code at the number they first provided
2022-05-05 09:42:14 +01:00
Chris Hill-Scott
c5d4bfd8ef Refactor to avoid direct string comparison
Direct string comparison in multiple places is prone to typos. It
also means that a consumer of the class needs to know that whether
a user is pending or active is held in the `state` property, which
is an implementation detail.
2022-05-05 09:39:32 +01:00
Chris Hill-Scott
5ac6efc580 Refactor logic out of Jinja before making more complicated
To keep the conditionals in the Jinja template more readable, this
commit moves the logic into a method on the model, where it can
be split over multiple statements and lines.
2022-05-05 09:38:40 +01:00
Chris Hill-Scott
8934e402e8 Make a model collection for organisations
This makes returning a user’s organisations consistent with how we
return their services.
2021-11-09 15:05:43 +00:00
Chris Hill-Scott
cbbc58e649 Make a model collection for services
This is tidier than having a manual loop.
2021-11-09 15:05:42 +00:00
Chris Hill-Scott
9281ca7d50 Sort services and orgs in presentation layer
The model layer shouldn’t need to be concerned with sorting. For
services this means we can make a `SerialisedModelCollection` rather
than writing a manual loop.
2021-11-09 15:05:42 +00:00
Chris Hill-Scott
4d4c9c0db2 Make services natively sortable 2021-11-09 15:05:42 +00:00
Chris Hill-Scott
5c1920fc20 Remove old method of updating email_access_validated_at
Previously we were passing a flag to the API which handled this. Now
we are doing it at the time of clicking the link, not at the time of
storing the new password. We don’t need to update the timestamp twice,
so this commit removes the code which tells the API to do it.
2021-08-19 11:14:47 +01:00
Chris Hill-Scott
cb59413581 Update email_access_validated_at on link click
When someone uses a fresh password reset link they have proved that they
have access to their inbox.

At the moment, when revalidating a user’s email address we wait until
after they’ve put in the 2FA code before updating the timestamp which
records when they last validated their email address[1].

We can’t think of a good reason that we need the extra assurance of a
valid 2FA code to assert that the user has access to their email –
they’ve done that just by clicking the link. When the user clicks the
link we already update their failed login count before they 2fa. Think
it makes sense to handle `email_access_validated_at` then too.

As a bonus, the functional tests never go as far as getting a 2FA code
after a password reset[2], so the functional test user never gets its
timestamp updated. This causes the functional tests start failing after
90 days. By moving the update to this point we ensure that the
functional tests will keep passing indefinitely.

1. This code in the API (91542ad33e/app/dao/users_dao.py (L131))
   which is called by this code in the admin app (9ba37249a4/app/utils/login.py (L26))
2. 5837eb01dc/tests/functional/preview_and_dev/test_email_auth.py (L43-L46)
2021-08-19 11:14:47 +01:00
Ben Thorner
dcfff87cc0 Continue to remove "roles" terminology
This renames the two functions we have to translate between UI and
DB permissions, as well as some of their associated variables to
make it clearer which kind of permission they contain.
2021-07-28 12:37:17 +01:00
Ben Thorner
ba9865e62e Start to remove use of the term "roles"
We don't use this term consistently and it's not defined anywhere.
Since most of the Admin app deals with user-facing permssions, it's
OK to just use the term "permissions". Where both types of permission
are present in the same file, we can more clearly distinguish them
as "UI permissions" and "DB permissions".
2021-07-28 12:37:16 +01:00
Ben Thorner
1127a03c32 Move and rename roles_and_permissions.py
This file does not represent a model, but rather a set of utilities
that are specific to user permissions (vs. service permissions).
2021-07-28 12:36:40 +01:00
Ben Thorner
832422fc66 Replace "admin roles" with "ui permissions"
In response to: [1].

While this does introduce a new term ("admin roles" is still used
elsewhere in the code), I plan to fix this in a follow-up PR (it
turned out to be quite a big change to do on this branch).

[1]: https://github.com/alphagov/notifications-admin/pull/3970#discussion_r673292339
2021-07-21 16:19:56 +01:00
Ben Thorner
9fafc092f7 Audit permissions when adding a user to a service
This is useful information to store for the event, which would be
lost if someone subsequently changed them.

Rather than updating lots of mock assertions, I've replaced them
with a single test / assert at a lower level, which is consistent
with auditing being a non-critical function.
2021-07-21 15:32:04 +01:00
Ben Thorner
171f911237 Audit when user permissions are changed
I've used the term "admin_roles" in the event data to try and show
that these are not the permissions we store in the DB. This is the
name we use for the abstracted form of permissions in the Admin app.
While we could store the DB permissions, that would be a bit more
effort and arguably it's clearer to keep the event data consistent
with the options the user actually saw / chose.
2021-07-21 15:32:03 +01:00
Ben Thorner
2241b119b0 Split (has_)permissions_for_service method
This avoids duplicating the code to get user permissions ("admin
roles") for a service, which we'll need in the next commit.
2021-07-21 15:32:02 +01:00
Ben Thorner
0f87ffe093 Move inline import to top of file
Usually we have imports at the top. It looks like the reason for
them being inline was to avoid a circular import, but we can also
avoid this by not importing everything from the app module.

Since we're about to add more imports from event_handlers, now is
a good time to refactor them. Note this matches how we import the
event handlers in every other module.
2021-07-21 15:32:01 +01:00
Ben Thorner
e72a260e13 Merge pull request #3947 from alphagov/allow-ccs
Allow other users to use security keys
2021-07-08 11:53:03 +01:00
Ben Thorner
4c2915ce86 Use API flag to give users access to WebAuthn
This allows us to roll out the feature to other users. Note that
the flag is also "True" if the user has "webauthn_auth" as their
auth type, so this is compatible with the more fine-grained check
we have on the authentication parts of the feature. We could do a
more explicit "can_use_webauthn or webauthn_auth" check here, but
the idea is that we'll be able to get rid of this flag eventually,
so I've optimised for brevity instead.

I've modified a couple of the unhappy-path tests to make it more
explicit that the flag is false, since it can be true for Platform
Admins and "normal users" alike.
2021-07-07 15:04:48 +01:00
Leo Hemsted
7b3751240c ensure user details are always in the session after entering password
We signal that we're mid-way through the sign-in flow by adding a
`user_details` dict to the session.

previously, we'd only put a user's details in the session in `User.sign_in`,
just before sending any 2fa prompt and redirecting to the two factor
pages.

However, we found a bug where a user with no session (eg, using a fresh
browser) tried to log in, but they had never clicked the link to
validate their email address when registering. Their user's state was
still in "pending", so we redirected to `main.resend_email_verification`
as intended - however, they didn't have anything in the session and the
resend page expected to get the email address to resend to out of that.

To be safe, as soon as we've confirmed the user has entered their
password correctly, lets save the session data at that point. That way
any redirects will be fine.
2021-06-29 18:13:25 +01:00
Ben Thorner
44cf2b16b5 Merge pull request #3923 from alphagov/refactor-email-verify
Split out utils code into separate modules
2021-06-14 10:28:28 +01:00
Chris Hill-Scott
f6aa5bdfb8 Refactor User.webauthn_credentials into a ModelList
This saves a bit of repetition, and lets us attach other methods to the
collection, rather than having multiple methods on the user object
prefixed with the same name, or random functions floating about.
2021-06-09 15:21:41 +01:00
Ben Thorner
7c27646d6a Extract user utility code into own module
This provides more room for expansion, and reduces the amount of
arbitrary code in the __init__.py file for the new package.
2021-06-09 13:19:05 +01:00
Chris Hill-Scott
45645728c7 Refactor into model
It’s generally an antipattern for the view layer code to be calling the
API client directly.
2021-06-08 09:31:20 +01:00
Leo Hemsted
73a444b33a rename webauthn auth functions
_complete_webauthn_authentication -> _verify_webauthn_authentication

This function just does verification of the actual auth process -
checking the challenge is correct, the signature matches the public key
we have stored in our database, etc.

verify_webauthn_login -> _complete_webauthn_login_attempt

This function doesn't do any actual verification, we've already verified
the user is who they say they are (or not), it's about marking the
attempt, either unsuccessful (we bump the failed_login_count in the db)
or successful (we set the logged_in_at and current_session_id in the
db).

This change also informs changes to the names of methods on the user
model and in user_api_client.
2021-06-02 12:06:10 +01:00
Leo Hemsted
0ec92e8c2f DRY attested webauthn creds data 2021-06-02 12:06:10 +01:00