Skip to content

Commit ce4e4fb

Browse files
committed
By default, only allow signatures on whitelisted petitions
1 parent ca210ac commit ce4e4fb

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

api/validation.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,20 @@
33
*/
44

55
var joi = require('joi');
6+
var wtpConfig = require('config').get('WE_THE_PEOPLE');
7+
8+
var petitionIdType = joi.string();
9+
if(wtpConfig.get('WHITELIST_PETITIONS')){
10+
petitionIdType = petitionIdType.valid(
11+
wtpConfig.get('WHITELISTED_PETITIONS')
12+
);
13+
}
614

715
var signaturePOSTSchema = joi.object().keys({
816
firstName: joi.string().max(50).required(),
917
lastName: joi.string().max(50).required(),
1018
email: joi.string().email().required(),
19+
petitionId: petitionIdType.required(),
1120
subscribeToEmails: joi.string()
1221
});
1322

config/default.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"WE_THE_PEOPLE": {
1818
"API_KEY": "",
1919
"API_URL": "",
20-
"RATE_LIMIT": 1000
20+
"RATE_LIMIT": 1000,
21+
"WHITELIST_PETITIONS": true
2122
},
2223

2324
"REDIS": {

config/development.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
"WE_THE_PEOPLE": {
44
"API_KEY": "",
5-
"API_URL": "http://sandbox.api.whitehouse.gov/v1"
5+
"API_URL": "http://sandbox.api.whitehouse.gov/v1",
6+
"WHITELISTED_PETITIONS": [
7+
"4e7b218a4bd504c17a000001",
8+
"4e7b21632ee8d04577000000"
9+
]
610
}
711

812
}

config/production.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
"WE_THE_PEOPLE": {
1010
"API_KEY": "",
11-
"API_URL": "https://api.whitehouse.gov/v1"
11+
"API_URL": "https://api.whitehouse.gov/v1",
12+
"WHITELISTED_PETITIONS": []
1213
}
1314

1415
}

0 commit comments

Comments
 (0)