Skip to content

Commit

Permalink
break: secure file upload and download (public and private)
Browse files Browse the repository at this point in the history
- prevents user uploads from being publicly accesible
- makes all S3 routes go through the API
- adds a new API Token concept to only allow BoPS to download user files
- side-effect: prevents users from downloading their own files
  • Loading branch information
gunar committed Aug 25, 2022
1 parent b142371 commit e81a8c1
Show file tree
Hide file tree
Showing 28 changed files with 1,057 additions and 266 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@ GOVUK_NOTIFY_SAVE_RETURN_EMAIL_TEMPLATE_ID=428c4dfd-a70b-44d6-9f81-b4f833d80405
GOVUK_NOTIFY_RESUME_EMAIL_TEMPLATE_ID=c7202e07-08cf-468e-a6a4-ac528d60d2f7
GOVUK_NOTIFY_REMINDER_EMAIL_TEMPLATE_ID=43be4c11-a406-4381-b2be-056a1127455d
GOVUK_NOTIFY_EXPIRY_EMAIL_TEMPLATE_ID=9619f89d-5d33-4cb0-a365-42c431ea9db3

FILE_API_KEY=filekey
1 change: 1 addition & 0 deletions api.planx.uk/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ GOVUK_NOTIFY_REMINDER_EMAIL_TEMPLATE_ID=43be4c11-a406-4381-b2be-056a1127455d
GOVUK_NOTIFY_EXPIRY_EMAIL_TEMPLATE_ID=9619f89d-5d33-4cb0-a365-42c431ea9db3

HASURA_PLANX_API_KEY=testtesttest
FILE_API_KEY=test
10 changes: 9 additions & 1 deletion api.planx.uk/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,12 @@ const dataMerged = async (id, ob = {}) => {
return ob;
};

export { getFlowData, getMostRecentPublishedFlow, getPublishedFlowByDate, dataMerged };
function buildFilePath(fileKey, fileName) {
if (!fileKey || !fileName) {
return null;
}

return `${fileKey}/${fileName}`;
}

export { getFlowData, getMostRecentPublishedFlow, getPublishedFlowByDate, dataMerged, buildFilePath };
1 change: 1 addition & 0 deletions api.planx.uk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"jsondiffpatch": "^0.4.1",
"jsonwebtoken": "^8.5.1",
"mime": "^3.0.0",
"multer": "^1.4.4",
"nanoid": "^3.3.4",
"notifications-node-client": "^5.1.1",
"passport": "^0.5.3",
Expand Down
Loading

0 comments on commit e81a8c1

Please sign in to comment.