-
Notifications
You must be signed in to change notification settings - Fork 256
Expand file tree
/
Copy pathbucketDeleteEncryption.js
More file actions
62 lines (54 loc) · 2.23 KB
/
bucketDeleteEncryption.js
File metadata and controls
62 lines (54 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const async = require('async');
const metadata = require('../metadata/wrapper');
const { metadataValidateBucket } = require('../metadata/metadataUtils');
const { pushMetric } = require('../utapi/utilities');
const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const { checkExpectedBucketOwner } = require('./apiUtils/authorization/bucketOwner');
/**
* Bucket Delete Encryption - Delete bucket SSE configuration
* @param {AuthInfo} authInfo - Instance of AuthInfo class with requester's info
* @param {object} request - http request object
* @param {object} log - Werelogs logger
* @param {function} callback - callback to server
* @return {undefined}
*/
function bucketDeleteEncryption(authInfo, request, log, callback) {
const bucketName = request.bucketName;
const metadataValParams = {
authInfo,
bucketName,
requestType: 'bucketDeleteEncryption',
request,
};
return async.waterfall([
next => metadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, next),
(bucket, next) => checkExpectedBucketOwner(request.headers, bucket, log, err => next(err, bucket)),
(bucket, next) => {
const sseConfig = bucket.getServerSideEncryption();
if (sseConfig === null) {
return next(null, bucket);
}
const updatedConfig = {
mandatory: false,
algorithm: sseConfig.algorithm,
cryptoScheme: sseConfig.cryptoScheme,
masterKeyId: sseConfig.masterKeyId,
};
bucket.setServerSideEncryption(updatedConfig);
return metadata.updateBucket(bucketName, bucket, log, err => next(err, bucket));
},
],
(err, bucket) => {
const corsHeaders = collectCorsHeaders(request.headers.origin, request.method, bucket);
if (err) {
log.trace('error processing request', { error: err, method: 'bucketDeleteEncryption' });
return callback(err, corsHeaders);
}
pushMetric('deleteBucketEncryption', log, {
authInfo,
bucket: bucketName,
});
return callback(null, corsHeaders);
});
}
module.exports = bucketDeleteEncryption;