Skip to content

Commit 2a6661e

Browse files
committed
feat: add client id and secret as env vars
1 parent b37836d commit 2a6661e

File tree

6 files changed

+24
-10
lines changed

6 files changed

+24
-10
lines changed

.env

Whitespace-only changes.

.env.example

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
API_CLIENT_ID=
2+
API_CLIENT_SECRET=
13
INTEGRATION_PUBLIC_KEY=
2-
BASE_API_PATH=

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ node_modules/
1717
# misc
1818
package-lock.json
1919
.DS_Store
20-
.env
20+
.env.local
2121
.serverless
2222

2323
# local dev debugging

README.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ yarn watch
2929

3030
Post requests can then be made via `http://localhost:3000/dev/agnoStack/orders/12345`
3131

32-
## Deployment
32+
## AWS Deployment
3333

3434
```bash
3535
yarn deploy
@@ -41,13 +41,9 @@ All requests must contain the following request headers, provided from agnoStack
4141

4242
- x-organization-id
4343
- x-providerstack-id
44-
- x-client-id
45-
- x-client-secret
4644

4745
```bash
4846
curl --location --request POST 'http://localhost:3000/dev/agnoStack/orders/12345' \
4947
--header 'x-organization-id: YOUR_ORGANIZATION_ID' \
50-
--header 'x-client-id: YOUR_CLIENT_ID' \
51-
--header 'x-client-secret: YOUR_CLIENT_SECRET' \
5248
--header 'x-providerstack-id: YOUR_PROVIDERSTACK_ID'
5349
```

handlers.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ const {
44
processVerificationResponse,
55
} = require('@agnostack/verifyd')
66

7-
const { BASE_API_PATH, INTEGRATION_PUBLIC_KEY, INTEGRATION_DISABLE_RECRYPTION } = process.env
7+
const {
8+
BASE_API_PATH,
9+
API_CLIENT_ID,
10+
API_CLIENT_SECRET,
11+
INTEGRATION_PUBLIC_KEY,
12+
INTEGRATION_DISABLE_RECRYPTION,
13+
} = process.env
814

915
const BASE_HEADERS = {
1016
'Content-Type': 'application/json',
@@ -31,7 +37,11 @@ const proxy = async (event) => {
3137
const options = {
3238
method: 'POST',
3339
body: JSON.parse(event?.body ?? '{}'),
34-
headers: filterHeaders(event?.headers),
40+
headers: {
41+
...filterHeaders(event?.headers),
42+
'X-Client-Id': API_CLIENT_ID,
43+
'X-Client-Secret': API_CLIENT_SECRET,
44+
},
3545
}
3646

3747
const [

serverless.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,21 @@ provider:
1313
name: aws
1414
runtime: nodejs18.x
1515
region: us-east-1
16+
environment:
17+
BASE_API_PATH: https://api-dev.agnostack.io/integration/api
1618

1719
functions:
1820
proxy:
1921
handler: handlers.proxy
2022
events:
2123
- http:
22-
path: /agnoStack/{route+}
24+
path: /agnostack/{route+}
2325
method: post
26+
# TODO implement secure authorizer at the API gateway level
27+
# authorizer:
28+
# name: proxyAuthorizer
29+
# scopes:
30+
# - https://xyz123.execute-api.us-east-1.amazonaws.com/api
2431

2532
resources:
2633
Resources:

0 commit comments

Comments
 (0)