Skip to content

Commit

Permalink
public requests are not signed
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderGeere committed Nov 14, 2024
1 parent 7071f1b commit 71c8667
Showing 1 changed file with 1 addition and 34 deletions.
35 changes: 1 addition & 34 deletions mod/sign/s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ if(!process.env.AWS_S3_CLIENT){
//Assume the bucket is public if no credentials are supplied
console.log('Sign S3: AWS_S3_CLIENT was not found in the env')

s3 = public_s3
module.exports = s3
module.exports = null

}
else{
Expand Down Expand Up @@ -66,38 +65,6 @@ const commands = {
list: (req) => objectAction(req.params, ListObjectsCommand)
}

/**
@function public_s3
@async
@description
The public s3 method returns a url for the bucket.
Provides methods for list, get, trash and put.
@param {Object} req HTTP request.
@param {Object} res HTTP response.
@param {Object} req.params Request parameter.
@param {string} params.region
@param {string} params.bucket
@param {string} params.key
@param {string} params.command
@returns {Promise<String>} The signed url associated to the request params.
**/
async function public_s3(req, res){

if (!Object.hasOwn(commands, req.params.command)) {
return res.status(400).send(`S3 command validation failed.`)
}

//Public bucket URL
let signedUrl = `https://${req.params.bucket}.s3.${req.params.region}.amazonaws.com`
signedUrl = req.params.command !== 'list' ? signedUrl+`/${req.params.key}` : signedUrl

return (async () => {return JSON.stringify(signedUrl)})()
}

/**
@function s3
@async
Expand Down

0 comments on commit 71c8667

Please sign in to comment.