-
Notifications
You must be signed in to change notification settings - Fork 576
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: bucket severside encryption (#707)
* feat: bucket severside encryption * chore: ReadMe * fix: remove test sleep
- Loading branch information
1 parent
0ed0d57
commit 68be73e
Showing
6 changed files
with
156 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const proto = exports; | ||
// const jstoxml = require('jstoxml'); | ||
/** | ||
* deleteBucketEncryption | ||
* @param {String} bucketName - bucket name | ||
*/ | ||
|
||
proto.deleteBucketEncryption = async function deleteBucketEncryption(bucketName) { | ||
this._checkBucketName(bucketName); | ||
const params = this._bucketRequestParams('DELETE', bucketName, 'encryption'); | ||
params.successStatuses = [204]; | ||
params.xmlResponse = true; | ||
const result = await this.request(params); | ||
return { | ||
status: result.status, | ||
res: result.res | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const proto = exports; | ||
/** | ||
* getBucketEncryption | ||
* @param {String} bucketName - bucket name | ||
*/ | ||
|
||
proto.getBucketEncryption = async function getBucketEncryption(bucketName) { | ||
this._checkBucketName(bucketName); | ||
const params = this._bucketRequestParams('GET', bucketName, 'encryption'); | ||
params.successStatuses = [200]; | ||
params.xmlResponse = true; | ||
const result = await this.request(params); | ||
const encryption = result.data.ApplyServerSideEncryptionByDefault; | ||
return { | ||
encryption, | ||
status: result.status, | ||
res: result.res | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const proto = exports; | ||
// const jstoxml = require('jstoxml'); | ||
const obj2xml = require('../utils/obj2xml'); | ||
/** | ||
* putBucketEncryption | ||
* @param {String} bucketName - bucket name | ||
* @param {Object} options | ||
*/ | ||
|
||
proto.putBucketEncryption = async function putBucketEncryption(bucketName, options) { | ||
options = options || {}; | ||
this._checkBucketName(bucketName); | ||
const params = this._bucketRequestParams('PUT', bucketName, 'encryption', options); | ||
params.successStatuses = [200]; | ||
const paramXMLObj = { | ||
ServerSideEncryptionRule: { | ||
ApplyServerSideEncryptionByDefault: { | ||
SSEAlgorithm: options.SSEAlgorithm | ||
} | ||
} | ||
}; | ||
if (options.KMSMasterKeyID !== undefined) { | ||
paramXMLObj.ServerSideEncryptionRule.ApplyServerSideEncryptionByDefault.KMSMasterKeyID = options.KMSMasterKeyID; | ||
} | ||
const paramXML = obj2xml(paramXMLObj, { | ||
headers: true | ||
}); | ||
params.mime = 'xml'; | ||
params.content = paramXML; | ||
const result = await this.request(params); | ||
return { | ||
status: result.status, | ||
res: result.res | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters