Skip to content

Commit 0bb98e8

Browse files
authored
Mntor 1539/separate data ingestion (#3034)
MNTOR-1539 - create Google Cloud Function version of /hibp/notify API endpoint
1 parent 2beb1f7 commit 0bb98e8

File tree

6 files changed

+598
-21
lines changed

6 files changed

+598
-21
lines changed

README.md

+24
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,30 @@ We track commits that are largely style/formatting via `.git-blame-ignore-revs`.
8888

8989
2. You may receive the error `Required environment variable was not set`. If this is the case, get the required env var(s) from another team member or ask in #fx-monitor-engineering. Otherwise, if the server started successfully, navigate to [localhost:6060](http://localhost:6060/)
9090

91+
### Cloud Functions
92+
93+
User breach notifications from HIBP are handled by a [GCP Cloud Function](https://cloud.google.com/functions). This can be emulated locally:
94+
95+
```sh
96+
npm run functions
97+
```
98+
99+
This function serves the `/api/v1/hibp/notify` route, which is responsible for:
100+
101+
1. receiving HTTP POST payloads with a bearer token from HIBP
102+
2. emailing any affected users
103+
104+
This can be tested using curl:
105+
106+
```sh
107+
curl \
108+
-H 'Content-Type: application/json' \
109+
-H 'Authorization: Bearer unsafe-default-token-for-dev' \
110+
-X POST \
111+
-d '{"breachName": "Gravatar", "hashPrefix": "...", "hashSuffixes": ["..."]}' \
112+
localhost:8080/api/v1/hibp/notify
113+
```
114+
91115
### Database
92116

93117
To create the database tables ...

0 commit comments

Comments
 (0)