Commit Graph

194 Commits

Author SHA1 Message Date
Cliff Hill
e64e500561 Debugging things is fun.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:37 -05:00
Cliff Hill
9523cc1d97 Cleaning up with black, isort, flake8.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:33 -05:00
Cliff Hill
7416de2a28 KeyType implemented.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:33 -05:00
Cliff Hill
a177042e77 Formatting cleanup for models.py
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:32 -05:00
Cliff Hill
3982f061b6 Made enums.py for all the enums to avoid cyclic imports.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:31 -05:00
Cliff Hill
ac9591ec7c More tweaks, trying to get tests to be clean.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:31 -05:00
Cliff Hill
43f18eed6a More changes for enums.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:41:57 -05:00
Cliff Hill
820ee5a942 Cleaning up a lot of things, getting Enums used everywhere.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:40:52 -05:00
Kenneth Kehl
f9f1013f5b notify-api-742 don't write phone numbers to db 2024-01-16 11:21:24 -08:00
Kenneth Kehl
c3cb60f3b0 fix registration so email gets sent 2024-01-11 11:11:12 -08:00
Kenneth Kehl
a8955ef78f fix flake8 2024-01-11 09:50:59 -08:00
Kenneth Kehl
ea8caf1ad9 remove debugging for 2fa issue 2024-01-11 09:38:00 -08:00
Kenneth Kehl
6f04915ee8 flake8 2024-01-10 11:20:33 -08:00
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