Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Katha - 1142] -security fix, downloadableUrl API #445

Merged
merged 3 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ GENERIC_INVITATION_EMAIL_TEMPLATE_CODE=generic_invite
# Allowed host by CORS
ALLOWED_HOST = "http://examplDomain.com"

# Downloadabale url exipres after
DOWNLOAD_URL_EXPIRATION_DURATION = 120000

#database url
DATABASE_URL=postgres://postgres:postgres@localhost:5432/elevate-user

5 changes: 5 additions & 0 deletions src/envVariables.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ let enviromentVariables = {
optional: true,
default: '*',
},
DOWNLOAD_URL_EXPIRATION_DURATION: {
message: 'Required downloadable url expiration time',
optional: true,
default: 3600000,
},
}

let success = true
Expand Down
3 changes: 2 additions & 1 deletion src/generics/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ const getDownloadableUrl = async (imgPath) => {
bucketName: process.env.DEFAULT_GCP_BUCKET_NAME,
gcpProjectId: process.env.GCP_PROJECT_ID,
gcpJsonFilePath: path.join(__dirname, '../', process.env.GCP_PATH),
expiry: Date.now() + parseFloat(process.env.DOWNLOAD_URL_EXPIRATION_DURATION),
}
imgPath = await GcpFileHelper.getDownloadableUrl(options)
imgPath = await GcpFileHelper.getSignedDownloadableUrl(options)
} else if (process.env.CLOUD_STORAGE === 'AWS') {
const options = {
destFilePath: imgPath,
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"crypto": "^1.0.1",
"csvtojson": "^2.0.10",
"dotenv": "^10.0.0",
"elevate-cloud-storage": "2.0.0",
"elevate-cloud-storage": "2.6.1",
"elevate-encryption": "^1.0.1",
"elevate-logger": "^3.1.0",
"elevate-node-cache": "^1.0.6",
Expand Down