Skip to content

Commit 9c082d9

Browse files
authored
Merge pull request #88 from silinternational/develop
Release 2.3.0
2 parents 3c4ea33 + 25fdf73 commit 9c082d9

30 files changed

+1000
-259
lines changed

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,18 @@ jspm_packages
1313

1414
# Temporary copy of backups (used during Disaster Recovery)
1515
/recovery/TempCopyOfBackups
16+
17+
# JS files generated or copied during local development (see Makefile)
18+
/development/site/client-bundle.js
19+
/development/site/psl.min.js
20+
/development/site/webauthn-client.js
21+
22+
# Folder with cert files used for dev-server https-proxy / traefik
23+
development/cert
24+
25+
# Local environment variables files, typically with secrets
26+
local.env
27+
*.local.env
28+
29+
# Terraform
30+
.terraform/

.whitesource

Lines changed: 0 additions & 8 deletions
This file was deleted.

Dockerfile

Lines changed: 0 additions & 2 deletions
This file was deleted.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017 SIL International
3+
Copyright (c) 2017-2022 SIL International
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1-
start:
2-
echo This Makefile has no default action. Be specific.
1+
dev-server:
2+
node development/server
3+
4+
dynamodb:
5+
docker-compose up -d dynamodb
6+
7+
dynamodb-tables: dynamodb
8+
./development/create-tables.sh
9+
10+
list-dev-api-keys:
11+
./development/list-api-keys.sh
312

413
do-full-recovery:
514
docker-compose run --rm do-full-recovery
15+
16+
test:
17+
npm test

README.md

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ For details about the various API endpoints, see
1515
must be provided as an `x-api-key` header in the HTTP request.
1616
- We create a new API Key and email it to that email address.
1717
* NOTE: At the moment, we do not actually send that email, since our use case
18-
is so limited that we can simply look up the API Key in the database.
18+
is so limited that we can simply look up the API Key in the database. For
19+
local development, run `make list-dev-api-keys` to see it.
1920
- The consumer does a `POST` to `/api-key/activate`, providing the email address
2021
and the API Key.
2122
- We respond with an API Secret (which is actually an AES key, which we will use
@@ -261,6 +262,73 @@ gulp restore \
261262
```
262263
(Note: The restore time is a JavaScript timestamp, in milliseconds.)
263264

265+
## Running locally
266+
267+
To run this locally (such as for development)...
268+
269+
1. Open a terminal to **THIS** repo's root folder and run the following:
270+
- `make dynamodb-tables`
271+
* NOTE: You may need to run this twice. If it gives an error message,
272+
trying again should work. I think it's a timing issue, where it tries to
273+
create the dynamodb tables before the local dynamodb is _actually_ up
274+
enough to be ready for interaction.
275+
- `make dev-server`
276+
2. Add and activate api-key entry for yourself in your local serverless-mfa-api:
277+
- Submit a `POST` to <https://localhost:8080/prod/api-key> with a JSON body
278+
like the following:
279+
```json
280+
{ "email": "[email protected]" }
281+
```
282+
It should return a `204 No Content` response.
283+
- Run `make list-dev-api-keys`, and copy the "value" parameter's value.
284+
- Do a `POST` to <https://localhost:8080/prod/api-key/activate>, with a JSON
285+
body like the following:
286+
```json
287+
{
288+
"email": "[email protected]",
289+
"apiKey": "the-value-parameter-from-the-dynamo-db-table"
290+
}
291+
```
292+
It should return a `200 OK` with a JSON body containing an apiSecret that
293+
you will need. When copying that value, make sure you include any trailing
294+
equals signs (`=`).
295+
3. Clone the <https://github.com/silinternational/idp-in-a-box> repo.
296+
4. Put the apiSecret returned (including any trailing `=` signs) and the apiKey
297+
value you used in the JSON body into your local idp-in-a-box code's
298+
`/docker-compose/broker/local.env` file, both for the `MFA_TOTP_*` and
299+
`MFA_U2F_*` environment variables, something like this (but using **YOUR**
300+
values for the apiKey and apiSecret entries, not these dummy/sample values):
301+
```
302+
MFA_TOTP_apiBaseUrl=http://localhost:8080/
303+
MFA_TOTP_apiKey=347a15dc60f014bdd93e4fc59aab607b022c8e19
304+
MFA_TOTP_apiSecret=za3c5Op8XgQcWNK16Rg6Th3ndmJ2ZTGL4uEldAJxDes=
305+
306+
MFA_U2F_apiBaseUrl=http://localhost:8080/
307+
MFA_U2F_apiKey=347a15dc60f014bdd93e4fc59aab607b022c8e19
308+
MFA_U2F_apiSecret=za3c5Op8XgQcWNK16Rg6Th3ndmJ2ZTGL4uEldAJxDes=
309+
```
310+
5. Bring up the `idp-in-a-box` repo. See that repo's README.md for instructions.
311+
312+
## Serverless
313+
314+
To start a local container for development of Serverless configuration:
315+
316+
```
317+
docker-compose run --rm dev bash
318+
```
319+
320+
## Credential Rotation
321+
322+
### AWS Serverless User
323+
324+
1. Use the Terraform CLI to taint the old access key
325+
```
326+
terraform taint module.serverless-user.aws_iam_access_key.serverless
327+
```
328+
2. Run a new plan on Terraform Cloud
329+
3. Review the new plan and apply if it is correct
330+
4. Copy the new key and secret from the Terraform output into Codeship
331+
264332
## Glossary
265333
266334
- `API Key`: A hex string used to identify calls to most of the endpoints on

codeship/deploy-dev.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

codeship/deploy-prod.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

codeship/deploy.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
# Exit script with error if any step fails.
4+
set -e
5+
6+
# Print the Serverless version in the logs
7+
serverless --version
8+
9+
echo "Deploying stage $1..."
10+
serverless deploy --verbose --stage "$1"

codeship/setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# Exit script with error if any step fails.
44
set -e
55

6-
npm install -g serverless
7-
npm install
6+
npm install --no-fund -g serverless@3
7+
npm install --no-fund

0 commit comments

Comments
 (0)