Commit Graph

181 Commits

Author SHA1 Message Date
Kenneth Kehl
7b2e59dede switch to raw_get and raw_set to see exceptions 2024-01-10 10:30:44 -08:00
Kenneth Kehl
3dcb8d194e more debug 2024-01-10 09:10:52 -08:00
Kenneth Kehl
572c8ebb84 reformat 2024-01-09 14:45:11 -08:00
Kenneth Kehl
2f9b98c07e debug messages 2024-01-09 14:28:24 -08:00
Kenneth Kehl
5366992d1a format 2024-01-09 14:01:03 -08:00
Kenneth Kehl
d3ca06fec2 fix 2024-01-09 13:36:57 -08:00
Kenneth Kehl
be950a7322 no verification code on staging 2024-01-09 13:09:07 -08:00
Kenneth Kehl
88379c9e46 final 2024-01-05 10:35:14 -08:00
Kenneth Kehl
3209c6d723 remove print statements 2023-12-05 07:29:18 -08:00
Kenneth Kehl
eea6933712 notify-admin-931 2023-12-04 14:53:29 -08:00
Kenneth Kehl
065009bb7a merge from main and reformat 2023-08-29 16:21:18 -07:00
Kenneth Kehl
1ecb747c6d reformat 2023-08-29 14:54:30 -07:00
Kenneth Kehl
5a350560d7 notify-api-433b remove research mode 2023-08-25 12:09:00 -07:00
Kenneth Kehl
00fd3a72bb code review feedback, fix setup.cfg and reformat 2023-08-25 08:10:33 -07:00
Kenneth Kehl
026dc14021 notify-api-412 use black to enforce python style standards 2023-08-23 10:35:43 -07:00
Kenneth Kehl
1adc05a7c6 notify-admin-641 let platform admins export listing of all users (#370)
Co-authored-by: Kenneth Kehl <@kkehl@flexion.us>
2023-07-26 12:13:57 -04:00
Kenneth Kehl
4940d5e93b notify-api-332 rename organisation 2023-07-10 11:06:29 -07:00
Ryan Ahearn
abc7b09d0d Update app to utilize updated phone validation methods 2023-01-05 11:06:12 -05:00
stvnrlly
e9fdfd59f4 clean flake8 except provider code 2022-10-19 16:16:26 +00:00
Jim Moffet
ac8d8d3c29 clean up config 2022-06-25 18:36:39 -07:00
Katie Smith
bd4f74b359 Replace how .load is called
https://marshmallow.readthedocs.io/en/stable/upgrading.html#schemas-are-always-strict

`.load` doesn't return a `(data, errors)` tuple any more - only data is
returned. A `ValidationError` is raised if validation fails. The code
now relies on the `marshmallow_validation_error` error handler to handle
errors instead of having to raise an `InvalidRequest`. This has no
effect on the response that is returned (a test has been modified to
check).

Also added a new `password` field to the `UserSchema` so that we don't
have to specially check for password errors in the `.create_user` endpoint
- we can let marshmallow handle them.
2022-05-25 11:35:44 +01:00
Chris Hill-Scott
c2b6a9df80 Allow admin app to specify domain for registration email
This follows the pattern for invite emails where the admin app tells the
API which domain to use when generating the link.

This will starting working once the admin change is merged:
- [ ] TBC

It won’t break anything if it’s merged before the admin change.
2022-03-07 15:03:46 +00:00
Chris Hill-Scott
07f584e1d5 Allow admin app to specify domain for password reset
This follows the pattern for invite emails where the admin app tells the
API which domain to use when generating the link.

This will starting working once this admin change is merged:
- [ ] https://github.com/alphagov/notifications-admin/pull/4150/files

It won’t break anything if it’s merged before the admin change.
2022-02-02 17:15:09 +00:00
Chris Hill-Scott
544bfbf569 Add separate config item for failed login count
It’s confusing that changing `MAX_VERIFY_CODE_COUNT` also limits the
number of failed login attempts that a user of text messages 2FA can
make.

This makes the parameters independent, and adds a test to make sure any
future changes which affect the limit of failed login attempts are
covered.
2021-10-04 10:45:07 +01:00
Chris Hill-Scott
2c7e4657ce Don’t update email_access_validated_at on password reset
As of https://github.com/alphagov/notifications-admin/pull/4000/files
the admin app is doing this, so we don’t need to do it here as well.
2021-09-01 09:54:54 +01:00
Leo Hemsted
542b151875 rename verify webauth endpoint to complete
it doesn't really do any verification - that's the webauthn code in the
browser and the admin app that does that. Instead, this completes the
login flow, by marking the user as logged in in the database. Added a
docstring that explains this process a bit more, and also added a new
route: /<id>/complete/webauthn. We'll move the admin code over to use
this new url in time
2021-06-03 17:12:19 +01:00
Leo Hemsted
00b0227007 add endpoint for verifying webauthn login
with sms and email auth the api handles verifying logins in the
`/<user_id>/verify/code` endpoint, when it checks the code is valid etc.
The admin app has already done this for webauthn logins, but we still
need an API endpoint so that we can set up the user's db entry to have
a new logged in timestamp, a new session id (this is important for
logging out other browser sessions), etc.

Also, we need to be able to make sure that the user's max login count
isn't exceeded. If it's exceeded, we shouldn't let them log in even with
a valid webauthn check.

This endpoint is a POST where the admin passes in a json dict with key
"succesful" being True or False. True sets up the db stuff as mentioned.
False just increments the failed login count.
2021-05-17 20:37:46 +01:00
Pea Tyczynska
098c6f031b Add webauthn as an auth type.
Both in our models and as a migration to add it to auth_types
table.

Make sure that if we downgrade, we first clean up the data.
2021-05-13 12:44:36 +01:00
Rebecca Law
68d28aa83b The update of SQLAlchemy 1.4.10 has caused some conflicts in our code. This PR fixes most of those conflicts.
- sqlalchemy.sql.expression.case must include an else statement.
- clearly define list of columns for inbound_sms_history insert, getting the list from InboundSmsHistory.__table__.c was causing data type errors.
- remove relationships when not needed, the foreign key relationship is established in the creation of the column. This will get rid of the warnings referenced here: http://sqlalche.me/e/14/qzyx.
- update queries now that he user relationship in ServiceUser db model has been removed.
- move the check that a template is archived to the view instead of the dao method. The check was clearing the session before the version history could be done.

Deleting notifications in the night tasks still needs to be
investigated. The raw sql is causing an error.
2021-04-29 13:32:36 +01:00
Rebecca Law
85895a9e8b Revert "Scheduled weekly dependency update for week 16" 2021-04-28 10:17:16 +01:00
Rebecca Law
1b070d69a1 The update of SQLAlchemy 1.4.10 has caused some conflicts in our code. This PR fixes most of those conflicts.
- sqlalchemy.sql.expression.case must include an else statement.
- clearly define list of columns for inbound_sms_history insert, getting the list from InboundSmsHistory.__table__.c was causing data type errors.
- remove relationships when not needed, the foreign key relationship is established in the creation of the column. This will get rid of the warnings referenced here: http://sqlalche.me/e/14/qzyx.
- update queries now that he user relationship in ServiceUser db model has been removed.
- move the check that a template is archived to the view instead of the dao method. The check was clearing the session before the version history could be done.

Deleting notifications in the night tasks still needs to be
investigated. The raw sql is causing an error.
2021-04-26 11:50:30 +01:00
Ben Thorner
a91fde2fda Run auto-correct on app/ and tests/ 2021-03-12 11:45:45 +00:00
Leo Hemsted
dabdc2c4ac Merge pull request #3169 from alphagov/remove-old-user-email-endpoint
add POST get user by email endpoint
2021-03-05 14:06:57 +00:00
Leo Hemsted
e0234fecba add POST get user by email endpoint
the existing endpoint is a GET, and so leaves email addresses in log
files.

we've got an existing POST find_users_by_partial_email, but not one that
matches on a whole email address.
2021-03-05 12:58:45 +00:00
Rebecca Law
97d1bfaee8 Rename method for clarity
Added unit test for new method.
2021-02-25 08:10:52 +00:00
Rebecca Law
5986a65005 Check international number for alpha: NO if true then use number to send
SMS.

This is not a catch all for international SMS, the rules are quite
complex and still not completely understood. We are talking with our
provider who maybe able to sort this out for us. But in the meantime,
this should solve for the case that we understand.
2021-02-24 15:12:03 +00:00
Rebecca Law
77b76ea0a4 Rename variable, it's a better name now. 2021-02-17 13:15:29 +00:00
Rebecca Law
e77534fb17 Send text message that are to an international number from a number rather than "Notify"
Update `send_user_2fa_code` to send from number when recipient is international
Update `update_user_attribute` to send from number when recipient is international
2021-02-17 12:14:47 +00:00
Pea Tyczynska
51811de919 Improve variable names for readability
Also next_redirect parameter in _create_reset_password_url does
not have to be a default arg, so I removed that following review.
2020-10-09 17:47:26 +01:00
Pea Tyczynska
e91deff448 Put redirect link in reset password email link
This is so when users reset their password they are still
redirected to pages they were meant to visit.

This change was done specifically so everyone who is meant to see
broadcast tour sees it, but it will improve lives of all users
who wanted to visit a page on Notify but then had to reset
their password in the process
2020-10-05 16:58:10 +01:00
Leo Hemsted
2b7e05d4e4 restore email sign in code expiry functionality
reverts 789112a31f

however, keeps the changes to the tests as they were an improvement
2020-05-05 12:00:36 +01:00
Leo Hemsted
789112a31f don't expire email sign in codes on use
we're seeing issues with email clients sniffing links, and causing them
to expire before the user gets a chance to click on them. Temporarily
disable the expiry while we work on a more permanent solution.

The link will still expire after half an hour, and sms codes aren't
affected by this change
2020-05-04 12:01:57 +01:00
Pea Tyczynska
e794300ff3 Fix reset password flow
It was broken because of unhappy marshmallow schema and flag name
mismatch
2020-02-18 14:59:46 +00:00
Pea Tyczynska
0132d76c16 Validate email access based on code_type anot auth_type
when verifying the code is correct. This way if user has sms_auth
and we send them verification code to validate their email access,
and they click the link in the email, their access will be validated
correctly.
2020-01-31 17:19:24 +00:00
Pea Tyczynska
0eed4c99a7 Add email_access_valdiated_at field to user table, populate it
and update it when users have to use their email to interact with
Notify service.

Initial population:
If user has email_auth, set last_validated_at to logged_in_at.
If user has sms_auth,  set it to created_at.

Then:
Update email_access_valdiated_at date when:
- user with email_auth logs in
- new user is created
- user resets password when logged out, meaning we send them an
email with a link they have to click to reset their password.
2020-01-30 14:51:54 +00:00
Pea Tyczynska
b2f811662d Leaner serialize for user model for displaying list of users 2019-08-19 13:31:29 +01:00
Chris Hill-Scott
4a2e906dfb Merge pull request #2540 from alphagov/remove-old-fields-from-organisations-and-services
Remove old fields from organisations and services
2019-07-10 11:02:26 +01:00
Rebecca Law
2cd657cec6 Raise given exception 2019-06-25 16:18:48 +01:00
Chris Hill-Scott
4dd245ca87 Remove deprecated fields from orgs and services
Once the admin app has started using the new fields returned in
https://github.com/alphagov/notifications-api/pull/2539 these fields
won’t be needed any more.
2019-06-18 10:48:41 +01:00
Chris Hill-Scott
d974ab3b86 Return count of live services on organisations too
This makes it consistent, so the admin app can always rely on that
property being available.
2019-06-12 15:24:11 +01:00