Skip to content

Commit f762831

Browse files
CLDSRV-636: Option for KMS to hide scality arn
To avoid breaking changes for clients
1 parent 6bbe2a8 commit f762831

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
}
8989
],
9090
"defaultEncryptionKeyPerAccount": true,
91+
"kmsHideScalityArn": false,
9192
"kmsAWS": {
9293
"providerName": "aws",
9394
"region": "us-east-1",

lib/Config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,11 @@ class Config extends EventEmitter {
12481248
assert(typeof this.defaultEncryptionKeyPerAccount === 'boolean',
12491249
'config.defaultEncryptionKeyPerAccount must be a boolean');
12501250

1251+
this.kmsHideScalityArn = Object.hasOwnProperty.call(config, 'kmsHideScalityArn')
1252+
? config.kmsHideScalityArn
1253+
: true; // By default hide scality arn to keep backward compatibility and simplicity
1254+
assert.strictEqual(typeof this.kmsHideScalityArn, 'boolean');
1255+
12511256
this.healthChecks = defaultHealthChecks;
12521257
if (config.healthChecks && config.healthChecks.allowFrom) {
12531258
assert(config.healthChecks.allowFrom instanceof Array,

lib/api/bucketGetEncryption.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const collectCorsHeaders = require('../utilities/collectCorsHeaders');
66
const { checkExpectedBucketOwner } = require('./apiUtils/authorization/bucketOwner');
77
const { metadataValidateBucket } = require('../metadata/metadataUtils');
88
const escapeForXml = s3middleware.escapeForXml;
9+
const { config } = require('../Config');
10+
const { getKeyIdFromArn } = require('arsenal/build/lib/network/KMSInterface');
911

1012
/**
1113
* Bucket Get Encryption - Get bucket SSE configuration
@@ -60,7 +62,11 @@ function bucketGetEncryption(authInfo, request, log, callback) {
6062
];
6163

6264
if (sseInfo.configuredMasterKeyId) {
63-
xml.push(`<KMSMasterKeyID>${escapeForXml(sseInfo.configuredMasterKeyId)}</KMSMasterKeyID>`);
65+
xml.push(`<KMSMasterKeyID>${escapeForXml(
66+
config.kmsHideScalityArn
67+
? getKeyIdFromArn(sseInfo.configuredMasterKeyId)
68+
: sseInfo.configuredMasterKeyId
69+
)}</KMSMasterKeyID>`);
6470
}
6571

6672
xml.push(

lib/utilities/collectResponseHeaders.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
const { getVersionIdResHeader } = require('../api/apiUtils/object/versioning');
22
const checkUserMetadataSize
33
= require('../api/apiUtils/object/checkUserMetadataSize');
4-
4+
const { config } = require('../Config');
5+
const { getKeyIdFromArn } = require('arsenal/build/lib/network/KMSInterface');
56
/**
67
* Pulls data from saved object metadata to send in response
78
* @param {object} objectMD - object's metadata
@@ -40,10 +41,11 @@ function collectResponseHeaders(objectMD, corsHeaders, versioningCfg,
4041
responseMetaHeaders['x-amz-server-side-encryption']
4142
= objectMD['x-amz-server-side-encryption'];
4243
}
43-
if (objectMD['x-amz-server-side-encryption-aws-kms-key-id'] &&
44+
const kmsKey = objectMD['x-amz-server-side-encryption-aws-kms-key-id'];
45+
if (kmsKey &&
4446
objectMD['x-amz-server-side-encryption'] === 'aws:kms') {
4547
responseMetaHeaders['x-amz-server-side-encryption-aws-kms-key-id']
46-
= objectMD['x-amz-server-side-encryption-aws-kms-key-id'];
48+
= config.kmsHideScalityArn ? getKeyIdFromArn(kmsKey) : kmsKey;
4749
}
4850

4951
responseMetaHeaders['Accept-Ranges'] = 'bytes';

0 commit comments

Comments
 (0)