Commit Graph

136 Commits

Author SHA1 Message Date
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
Chris Hill-Scott
b6fdb269e4 Return all required org and services info for user
The admin app now needs to know a few extra things about orgs and
services in order to list them. At the moment it does this by making
multiple API calls.

This commit adds extra fields to the existing response. Once the admin
app is using this fields we’ll be able to remove:
- `reponse['services_without_organisations']`
- `reponse['organisations']['services']`
2019-06-12 15:24:11 +01:00
Katie Smith
ffcd731a68 Add endpoint to archive a user
This archives a user if their state is 'active'.
2019-06-05 14:54:52 +01:00
Katie Smith
d981abf18e Allow user folder permissions to be updated
Updated the endpoint for `.set_permissions` to update a user's folder
permissions as well as permissions for a service. User folder
permissions are optional for now, since Admin is not currently passing
this data through.
2019-02-27 12:56:26 +00:00
Pea Tyczynska
211d3741ba Send confirmation emails to users when team manager edits their
email address  or mobile number.
2019-02-26 16:30:29 +00:00
Katie Smith
bcb1c483ca Change permissions endpoint to accept data in new format
The data posted to the `set_permissions` endpoint is currently sent as a
list of permissions:
`[{'permission': MANAGE_SETTINGS}, {'permission': MANAGE_TEMPLATES}]`.

This endpoint is going to also be used for folder permissions, so the
data now needs to be nested:

`{'permissions': [{'permission': MANAGE_SETTINGS}, {'permission': MANAGE_TEMPLATES}]}`

This changes the set_permissions endpoint to accept data in either
format. Once admin is sending data in the new format, the code can be
simplified.
2019-02-25 16:01:24 +00:00
Chris Hill-Scott
2f4f381fa4 Include live/trial mode in list of services
We need this so we can check in the admin whether users have any live
services.
2018-12-13 11:09:47 +00:00
Leo Hemsted
918e4b390f add postage to notification + noti_history
if it's a letter notification, postage must equal "first" or "second",
else it must equal null
2018-09-19 16:32:58 +01:00
Pea Tyczynska
782a8ab9e7 Add data endpoint for finding users by full or partial email 2018-07-13 15:47:20 +01:00
Leo Hemsted
3ddd43b45b move the dict building up into a separate function 2018-03-15 12:21:04 +00:00
Leo Hemsted
5871dee606 use joinedload to only hit the database once per request
also:

* only include active orgs
* write lots of tests
2018-03-14 15:39:31 +00:00
Leo Hemsted
91fa475645 add new endpoint to get organisations and services for a user
contains orgs, and unmapped services.

the orgs contain nested services - services the user is a part of that
belong to that org.

the unmapped services are any services that the user is a part of that
either don't have an org or have one that the user doesn't know about
2018-03-14 15:39:31 +00:00
Leo Hemsted
efec57db01 replace user_schema with serialize method on user model
this is so that we can filter out inactive organisations and services

note: can't remove user schema completely, as we still use it in
POST /user to create new users
2018-03-14 15:39:31 +00:00
Chris Hill-Scott
c0e2a478f6 Allow admin to specify domain for email auth links
Similar to https://github.com/alphagov/notifications-api/pull/1515

This lets the admin app pass in a domain to use for email auth links,
so that when it’s running on a different URL users who try to sign in
will get an email auth link for the domain they sign in on, not the
default admin domain for the environment in which the API is running.
2018-02-09 14:19:17 +00:00
Leo Hemsted
28d5f9b87f flake8 - remove unused imports and ensure they're always at the top of the file 2017-11-28 14:28:01 +00:00
Rebecca Law
ab5b7c20a7 Use sms sender or reply to email address of the Notify service in create_2fa_code depending on message type. 2017-11-27 16:52:52 +00:00
venusbb
3945007d24 add reply-to-text to user/rest persist notifications 2017-11-27 14:36:54 +00:00
Leo Hemsted
6332058781 remove PUT /user/<id> 2017-11-10 10:49:44 +00:00
Leo Hemsted
15bf888624 make user mobile num nullable if user has email_auth enabled 2017-11-09 19:07:44 +00:00
Leo Hemsted
048ddbb2a4 add separate activate user endpoint 2017-11-09 14:27:24 +00:00
Leo Hemsted
0146e2d935 attempt to reduce code duplication 2017-11-07 16:47:40 +00:00
Leo Hemsted
67ae1fdb7b PR changes - some comment clarification and code simplifying 2017-11-07 16:47:40 +00:00
Leo Hemsted
a231918317 put secret code in email url token 2017-11-07 16:47:26 +00:00
Leo Hemsted
6af616eb83 add name to personalisation and urlencode next param
also add tests
2017-11-07 16:47:26 +00:00
Leo Hemsted
dd326ec1d3 add new template to config
and rename existing new user email verification template for clarity
2017-11-07 16:47:26 +00:00
Leo Hemsted
b2756ac99d add email code verification
by hitting POST /<user_id>/email-code, we create an email two factor
code to send to the user. That email contains a link with a token that
will sign the user in when opened.

Also some other things:

"email verification" (aka when you first create an account) doesn't
hit the API anymore

refactor 2fa code verification and sending to use jsonschema, and share code between sms and email

Die marshmallow die!
2017-11-07 16:45:49 +00:00
Leo Hemsted
6c61a3fc2a Revert celery4
Revert the following three pull requests:
https://github.com/alphagov/notifications-api/pull/1085
https://github.com/alphagov/notifications-api/pull/1086
https://github.com/alphagov/notifications-api/pull/1088

celery 4.0.2 looked promising, however, on staging under mild load
(5/sec api calls) the performance was actually worse than 3.1.25
2017-07-19 15:17:19 +01:00
Martyn Inglis
786adb5d71 Move Queuenames in with the celery code, revamp config to allow move to celery 4.x 2017-07-12 12:01:52 +01:00
Chris Hill-Scott
f1399ca7f1 Fix support URLs in Notify emails 2017-06-07 11:58:10 +01:00
Martyn Inglis
2591d3a1df This massive set of changes uses the new queue names object throughout the app and tests.
Lots of changes, all changing the line of code that puts things into queues, and the code that tests that.
2017-05-25 10:51:49 +01:00
Rebecca Law
78242812ef Register a before_request event for all blueprints, that defines the authentication requirement.
There are three authentication methods:
 - requires_no_auth - public endpoint that does not require an Authorisation header
 - requires_auth - public endpoints that need an API key in the Authorisation header
 - requires_admin_auth - private endpoint that requires an Authorisation header which contains the API key for the defined as the client admin user
2017-03-16 18:15:49 +00:00
Rebecca Law
fd0bfbe2f6 If user account is locked return 404 even if the code is correct.
Update user.failed_login_count = 0 if code is correct.
New endpoint to reset the failed_login_count
2017-02-28 14:28:33 +00:00
Rebecca Law
fb61b4528b Remove resetting the failed_login_count to zero in the api. The admin app will deal with doing that. 2017-02-28 11:21:47 +00:00
Leo Hemsted
8bad5926ab dont set session_id or logged_in_at if user provides email code 2017-02-24 15:14:47 +00:00
Leo Hemsted
a47672f7e3 Add current_session_id to the user model, update on login
when we change the last logged in time, set the current session id to
a random uuid

this way, we can compare it to the cookie a user has, and if they
differ then we can log them out

also update user.logged_in_at at 2FA rather than password check, since
that feels more accurate
2017-02-22 17:30:55 +00:00
Leo Hemsted
521872ce63 update_user now resets failed_login_count if password is changed
until work is done to stop using PUT /user/{id} on the admin app, this
function also needs to reset failed logins, cos it's used during the
forgotten password flow
2017-02-16 17:39:47 +00:00
Leo Hemsted
ac9739f8a2 ensure we reset failed_login_count when appropriate
in verify_user_password, if succesful we reset the failed_login_count.
now we use failed_login_count for 2FA attempts, we need to make sure we
reset it in other places too, so that people don't get blocked,
especially in the reset-password user journey.

* verify_user_code - if it's succesful, reset the failed_login_count
* update_password - reset failed_login_count because either
  * you're logged in and so it's 0 anyway
  * you're resetting your password via pword reset link, and the old
    count isn't relevant anymore
2017-02-16 16:00:40 +00:00
Rebecca Law
ed4b9d34a6 Changes as per code review comments.
Fix my backward date math :P
2017-02-15 17:41:07 +00:00
Rebecca Law
52342afe3f Add a limit to the number of active 2fa codes that we create. At the moment that is set to 10. 2017-02-15 16:18:05 +00:00
Rebecca Law
6674640330 Removed resetting of the login count 2017-02-15 10:54:09 +00:00
Rebecca Law
5f48367ee5 Set the expiry time on a verify code (2fa) to 10 minutes.
When the verify code is wrong or expired increment the failed to login count for the user.
When the verify code is successfully used reset the failed login count to 0.
2017-02-14 14:04:11 +00:00
Imdad Ahad
69b1007c33 Add schema and separate endpoint to update a user password 2017-02-07 11:27:13 +00:00
Martyn Inglis
46d1e3bdb6 Two new methods needed to pass the service not the service ID into the create notifications methods. 2017-01-10 13:41:16 +00:00
minglis
0c6193e2e9 Merge pull request #775 from alphagov/do-not-write-test-data-to-the-history-table
Do not write test data to the history table
2017-01-10 13:05:06 +00:00
Rebecca Law
7bec9aefcc Removed unused imports. 2016-12-20 16:06:23 +00:00
Rebecca Law
a03732472c Refactor send_user_reset_password to persist and send message to the notify queue.
The reason for doing this is to ensure the tasks performed for the Notify users are not queued behind a large job, a way to
ensure priority for messages.

5th task for story: https://www.pivotaltracker.com/story/show/135839709
2016-12-20 11:55:26 +00:00