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????
This commit is contained in:
Chris Hill-Scott
2016-10-07 10:59:32 +01:00
parent 4ddc99781f
commit 6946d3af54
5 changed files with 46 additions and 18 deletions

View File

@@ -159,15 +159,23 @@ def test_should_create_api_key_with_type_normal(app_,
response = client.post(
url_for('main.create_api_key', service_id=service_id),
data={
'key_name': 'some default key name',
'key_name': 'Some default key name 1/2',
'key_type': 'normal'
}
)
assert response.status_code == 200
assert 'some default key name' in response.get_data(as_text=True)
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
keys = page.find_all('span', {'class': 'api-key-key'})
for index, key in enumerate([
'some_default_key_name_12-{}-{}'.format(service_id, fake_uuid),
service_id,
fake_uuid
]):
assert keys[index].text.strip() == key
post.assert_called_once_with(url='/service/{}/api-key'.format(service_id), data={
'name': 'some default key name',
'name': 'Some default key name 1/2',
'key_type': 'normal',
'created_by': api_user_active.id
})