Skip to content

Commit

Permalink
By default, only allow signatures on whitelisted petitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Hainish committed Sep 28, 2015
1 parent ca210ac commit ce4e4fb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
9 changes: 9 additions & 0 deletions api/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@
*/

var joi = require('joi');
var wtpConfig = require('config').get('WE_THE_PEOPLE');

var petitionIdType = joi.string();
if(wtpConfig.get('WHITELIST_PETITIONS')){
petitionIdType = petitionIdType.valid(
wtpConfig.get('WHITELISTED_PETITIONS')
);
}

var signaturePOSTSchema = joi.object().keys({
firstName: joi.string().max(50).required(),
lastName: joi.string().max(50).required(),
email: joi.string().email().required(),
petitionId: petitionIdType.required(),
subscribeToEmails: joi.string()
});

Expand Down
3 changes: 2 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"WE_THE_PEOPLE": {
"API_KEY": "",
"API_URL": "",
"RATE_LIMIT": 1000
"RATE_LIMIT": 1000,
"WHITELIST_PETITIONS": true
},

"REDIS": {
Expand Down
6 changes: 5 additions & 1 deletion config/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

"WE_THE_PEOPLE": {
"API_KEY": "",
"API_URL": "http://sandbox.api.whitehouse.gov/v1"
"API_URL": "http://sandbox.api.whitehouse.gov/v1",
"WHITELISTED_PETITIONS": [
"4e7b218a4bd504c17a000001",
"4e7b21632ee8d04577000000"
]
}

}
3 changes: 2 additions & 1 deletion config/production.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

"WE_THE_PEOPLE": {
"API_KEY": "",
"API_URL": "https://api.whitehouse.gov/v1"
"API_URL": "https://api.whitehouse.gov/v1",
"WHITELISTED_PETITIONS": []
}

}

0 comments on commit ce4e4fb

Please sign in to comment.