Commit Graph

816 Commits

Author SHA1 Message Date
Leo Hemsted
26a985720c fix 500 errors with excel files > 500k size limit
werkzeug's internal workings keep files under 500kb in memory, and files
greater than 500kb as a TemporaryFile

(https://github.com/pallets/werkzeug/blob/0.11-maintenance/werkzeug/formparser.py#L38)

when we encounter a CSV or TSV, we call normalise_newlines, which invokes
`.read()`, however when we were passing straight into pyexcel, we called
`file.getvalue()` - this exists on BytesIO (small files) but not on
TemporaryFile objects (large files) - we were seeing 500 errors
2016-10-26 16:35:14 +01:00
imdadahad
a93333572f Merge pull request #995 from alphagov/fix-500s
Fix 500s
2016-10-25 12:20:31 +01:00
imdadahad
8f10eae9c3 Rename test 2016-10-25 10:46:10 +01:00
Imdad Ahad
2b5894bed9 Add check for current user not authenticated 2016-10-24 17:36:53 +01:00
Pete Herlihy
7bf18c9fd1 Merge pull request #997 from alphagov/go-live-page
Updated the request to go live page
2016-10-24 16:28:18 +01:00
Imdad Ahad
a707bd546c Updates:
* Fix tests
* Add tests for new message format
2016-10-24 16:10:41 +01:00
Imdad Ahad
876832801e Fix tests and other bits 2016-10-24 15:35:51 +01:00
Rebecca Law
a0ce270cf5 Update email domain list. 2016-10-18 13:51:34 +01:00
Chris Hill-Scott
6946d3af54 Make API key combination of secret and service ID
In research we’ve seen people mix up the service ID and API key because
they’re both 36 character UUIDs. We can’t get rid of the service ID
because it’s used to look up the API key.

Instead, we should change API key to be one long string, which contains
both the service ID, API key and (optionally) the name of the key. For
example:

```
casework_production-8b3aa916-ec82-434e-b0c5-d5d9b371d6a3-dcdc5083-2fee-4fba-8afd-51f3f4bcb7b0
```

We still need to keep the old, separate, key and service ID for a while
until people have updated their clients. But they’re now both on this
page, rather than on two separate pages, which should make for less
fussing anyway.

This shouldn’t be rolled out until the new clients are available.

- [ ] https://github.com/alphagov/notifications-python-client/pull/36
- [ ] https://github.com/alphagov/notifications-node-client/pull/10
- [ ] https://github.com/alphagov/notifications-ruby-client/pull/15
- [ ] https://github.com/alphagov/notifications-java-client/pull/38
- [ ] PHP????
2016-10-18 12:21:00 +01:00
Chris Hill-Scott
fb906fbfdb Make ‘too many rows’ error actually work
Was using the wrong attribute name on the instance of `RecipientCSV`
(needed to match 19df1eb4ef/notifications_utils/recipients.py (L156) )

The ‘can’t show file contents’ message wasn’t showing up, now it is.
2016-10-17 10:20:14 +01:00
Chris Hill-Scott
a32dcbf8e3 Error if a CSV file contains more than 50,000 rows
We want to limit the number of rows someone can have in a job, because
it gets too slow to process the file otherwise.

This should be the first error that a user sees, because we can’t work
out if there are other errors until they’ve got the file down to a
processable size.

This also means adding a message to say that the file can’t be displayed
if it doesn’t contain any processed rows.

***

https://www.pivotaltracker.com/story/show/129830161
2016-10-16 10:55:19 +01:00
Rebecca Law
f02bcd3338 Merge pull request #984 from alphagov/confirm-email-change
Send an email to the user when they change email address
2016-10-14 16:00:47 +01:00
Rebecca Law
a0e7d569e9 Send an email to the user when they change email address
This PR changes the flow to change an email address.
Once the user enter their password, they are told "Check your email".
An email has been sent to them containing a link to notify which contains an encrypted token.
The encrypted token contains the user id and new email address. Once the link is clicked the user's email address is updated to the new email address.
They are redirected to the /user-profile page.

Also in this commit is an update from flask.ext.login to flask_login.
2016-10-13 17:05:37 +01:00
Leo Hemsted
e4f0656a32 remove filtering of test messages from jobs
this is now down on the api side
2016-10-12 13:54:22 +01:00
Chris Hill-Scott
b48874dbad Fix all jobs being shown on the dashboard
The dashboard was showing the 50 most recent jobs, not the 50 most
recent in the last 7 days.
2016-10-12 11:31:59 +01:00
Leo Hemsted
daa848f4c5 Merge pull request #965 from alphagov/paginate-dashboard
Limit jobs on the dashboard
2016-10-11 11:36:22 +01:00
Chris Hill-Scott
645e935f55 Revert "Revert "Don’t let people create a normal key in trial mode""
Reverts alphagov/notifications-admin#976
2016-10-11 10:42:11 +01:00
Leo Hemsted
0fdd38b9c5 add tests for new jobs functionality 2016-10-10 17:15:57 +01:00
Chris Hill-Scott
8e323a81a8 Revert "Don’t let people create a normal key in trial mode" 2016-10-10 16:50:46 +01:00
Chris Hill-Scott
13227606a9 Merge pull request #973 from alphagov/remove-documentation
Remove documentation pages
2016-10-10 16:01:09 +01:00
Chris Hill-Scott
1fccc524a1 Remove documentation pages
These are out of date now and potentially misleading.

Adds a new error page for HTTP `410 GONE`. Looks like the 404 page, but
returns the appropriate error code to be a good web citizen.
2016-10-10 15:58:11 +01:00
Leo Hemsted
479623ee99 fix query param testing once and for all. hopefully
try and avoid comparing URLs as much as possible cos its hard
2016-10-10 15:43:01 +01:00
Leo Hemsted
aa458a15da update tests to reflect new code
also change jobs.py to filter out test jobs (since we dont need to see em)
and to use the new statuses filter rather than filtering on front end
2016-10-10 15:43:01 +01:00
Leo Hemsted
441a2717f2 make dashboard jobs list hit job api twice
once for scheduled jobs, once for past jobs

this ensures that if you have lots of scheduled jobs it can still return your last 50 jobs
2016-10-10 15:43:01 +01:00
Leo Hemsted
be97edce7f make add_rate_to_jobs singular
there was no reason for it to operate on a whole list at a time
2016-10-10 15:43:01 +01:00
Leo Hemsted
549a17c1f7 separate get_job and get_jobs in job_api_client
also remove the status parameter, as we never use it anywhere
2016-10-10 15:43:01 +01:00
Chris Hill-Scott
90d4fcaa52 Don’t let people create a normal key in trial mode
You can’t properly use a normal key when your service is in trial mode.

It’s theoretically useful to create a live key in preparation for going
live. This utitily outweighs the confusion it causes for people creating
their first keys in trial mode.

We should just remove the confusing option.
2016-10-10 14:40:13 +01:00
Leo Hemsted
b01323c28c fix query param testing once and for all. hopefully
try and avoid comparing URLs as much as possible cos its hard
2016-10-07 13:32:47 +01:00
Chris Hill-Scott
860b071f66 Test for query parameters in either order
They’re not deterministic, and were causing intermittant test failures.
2016-10-05 16:13:21 +01:00
Chris Hill-Scott
b760457ba9 Add monthly breakdown of usage
Basically:
- shows all the months from start of given financial year to now or end
  of given financial year (whichever is earliest)
- shows a breakdown of free and paid text messages for each of these
  months

Depends on:
- [x] https://github.com/alphagov/notifications-api/pull/699
2016-10-05 16:11:19 +01:00
Chris Hill-Scott
0a0bfa9232 Merge pull request #962 from alphagov/re-add-analytics
Re-add Google Analytics
2016-10-05 14:49:01 +01:00
Chris Hill-Scott
e095d6024c Revert "Remove Google Analytics"
This reverts commit f31170f5a2.
2016-10-05 10:55:04 +01:00
Chris Hill-Scott
3069858a9f Fix pagination on activity page
The activity page was AJAXified in
https://github.com/alphagov/notifications-admin/pull/952 but this
didn’t take pagination into account.

So if you visited page 2, the contents of the page would be replaced by
Javascript with the contents of page 1. So you’d never be able to see
anything beyond page 1, expect for a brief fraction of a second when the
page loaded.

This commit makes sure the AJAX request uses whatever page parameter is
in the URL of the original page.
2016-09-30 15:41:46 +01:00
Rebecca Law
2eb7360468 Merge pull request #959 from alphagov/remove-user-from-service
Allow platform admin to edit users.
2016-09-30 14:07:20 +01:00
Rebecca Law
5a50c945c7 Allow platform admin to edit users. 2016-09-30 11:48:16 +01:00
Chris Hill-Scott
f31170f5a2 Remove Google Analytics
Reverts https://github.com/alphagov/notifications-admin/pull/306

We’re not looking at the data from Analytics, so shouldn’t be collecting
it just in case.

<sup>Brought to you by the fun police.</sup>
2016-09-30 09:23:00 +01:00
Chris Hill-Scott
48891babc4 Add log of notifications to API integration page
Now that we’ve removed simulated notifications from the dashboard and
activity pages they’re not visible anywhere in the app.

While they should’t be visible to non-technical users, developers have
a real need for Notify to confirm that their code is doing what they
expect. This is needed especially when they’re just getting started with
Notify.

There’s no way of seeing this info from the API either, because a key
can only get notifications created with a key of that type.

It doesn’t make sense to make this a ‘mode’ of the dashboard or activity
because the information about notifications that developers need is
also different. So this commit adds up to 50 of the most recent
notifications sent via the API to the page that developers use as their
‘home’ page.

This also lets us explain the 7 days thing to developers via the
empty slate state of this area of the page.
2016-09-29 09:28:04 +01:00
Chris Hill-Scott
a04aad8825 Add additional params to get notifications client
We want to show a log of notifications that have been sent from the API.

The admin app uses its own private `/service/…/notifications` endpoint
for listing activity. This commit allows us to pass through two
optional, additional parameters to tell the API to:

- include or not include notifications created from a job
- include or not include notifications created with a test API key
2016-09-29 09:27:55 +01:00
Chris Hill-Scott
3e42042156 Add a page to manage a service’s whitelist
Services who are in alpha or building prototypes need a way of sending
to any email address or phone number without having to sign the MOU.

This commit adds a page where they can whitelist up to 5 email addresses
and 5 phone numbers.

It uses the ‘list entry’ UI pattern from the Digital Marketplace
frontend toolkit [1] [2] [3].

I had to do some modification:
- of the Javascript, to make it work with the GOV.UK Module pattern
- of the template to make it work with WTForms
- of the content security policy, because the list entry pattern uses
  Hogan[1], which needs to use `eval()` (this should be fine if we’re
  only allowing it for scripts that we serve)
- of our SASS lint config, to allow browser-targeting mixins to come
  after normal rules (so that they can override them)

This commit also adds a new form class to validate and populate the two
whitelists. The validation is fairly rudimentary at the moment, and
doesn’t highlight which item in the list has the error, but it’s
probably good enough.

The list can only be updated all-at-once, this is how it’s possible to
remove items from the list without having to make multiple `POST`
requests.

1. 434ad30791/toolkit/templates/forms/list-entry.html
2. 434ad30791/toolkit/scss/forms/_list-entry.scss
3. 434ad30791/toolkit/javascripts/list-entry.js
4. http://twitter.github.io/hogan.js/
2016-09-29 09:27:38 +01:00
Chris Hill-Scott
4a596c1dd2 Add a new banner for telling you about trial mode
We’ve found in research that developers have no idea they’re in trial
mode until they hit an error. And even then they don’t really know what
trial mode means.

So this commit:
- adds a message to the API integration page about trial mode
- puts it in a really yellow banner to draw attention to it
- adds the same banner to the settings page
2016-09-28 17:00:46 +01:00
Chris Hill-Scott
dfa3a9242f Add a separate page for linking to documentation
It’s going to get too cluttered to have these links on the API index
page.
2016-09-28 17:00:45 +01:00
Chris Hill-Scott
d9cc936972 Add an index page for the API integration
This commit adds a placeholder page which, for now, just has links to
the API keys page and links to the clients.

There’s more stuff to come on this page, but this commit just does the
reorganising so that it’s easier to review.
2016-09-28 17:00:45 +01:00
Martyn Inglis
0bf39c75d9 Fixed bug where there was an error when try and change email.
- it tried to send a verify code which no longer is applicable
- one stage of process removed and tests update properly

Flow is:

- Change email
- Confirm with password
- Done
2016-09-28 14:34:22 +01:00
Chris Hill-Scott
6a0bf88211 Merge pull request #950 from alphagov/8-char-password
Reduce minimum password length to 8 characters
2016-09-28 14:34:02 +01:00
Chris Hill-Scott
d9eac94f1e Make the activity page update with AJAX
The activity page looks the same as the job page. So it should behave
the same and not need manually refreshing to see the new stuff.
2016-09-27 15:34:47 +01:00
Chris Hill-Scott
d747389e2a Add variations on GOV.UK Notify to blacklist
There’s a chance that someone will run out of imagination and use
the name of the thing they’re signing up for as their password.

This wouldn’t be caught by the generic blacklist.
2016-09-27 12:24:46 +01:00
Chris Hill-Scott
68a6ceec78 Give better error message for blacklisted password
Telling the user what to do, rather than the mistake they’ve made is
usually better.
2016-09-27 11:51:12 +01:00
Chris Hill-Scott
136662bd30 Stop people using very common passwords
If a user chooses a very common password then an attacker could guess it
in relatively few attempts, circumventing the lockout.

CESG recommend blacklisting the most common passwords:

> …enforcing the requirement for complex character sets in passwords is
> not recommended. Instead, concentrate efforts on technical controls,
> especially:
>
> - defending against automated guessing attacks by either using account
>   lockout, throttling, or protective monitoring
> - blacklisting the most common password choices

How I made this list:

- went to the OWASP repository of security lists:
  https://github.com/danielmiessler/SecLists

- downloaded `10k_most_common.txt`, `twitter-banned.txt` and
  `500-worst-passwords.txt`

- filtered out any under 8 characters:
  ```
  sed -r '/^.{,7}$/d' passwords-twitter.txt > passwords-combined.txt
  sed -r '/^.{,7}$/d' passwords-500.txt >> passwords-combined.txt
  sed -r '/^.{,7}$/d' passwords.txt >> passwords-combined.txt
  ```

- filtered out any duplicates:
  ```
  cat passwords-combined.txt | awk '!x[$0]++' > passwords-combined-deduped.txt
  ```
2016-09-27 11:51:12 +01:00
Rebecca Law
4f20dceb9f Add email domains to whitelist for user registration. 2016-09-20 11:02:53 +01:00
Rebecca Law
ef792d9d2a Add a new domain for the email domain regex. 2016-09-15 09:39:44 +01:00