|
1 | 1 | const s3config = require('../../../Config').config;
|
2 | 2 | const constants = require('../../../../constants');
|
| 3 | +const { isBackbeatUser } = require('../authorization/aclChecks'); |
3 | 4 |
|
4 | 5 | function _getBackend(objectMD, site) {
|
5 | 6 | const backends = objectMD ? objectMD.replicationInfo.backends : [];
|
@@ -68,14 +69,26 @@ function _getReplicationInfo(rule, replicationConfig, content, operationType,
|
68 | 69 | * @param {boolean} objSize - The size, in bytes, of the object being PUT
|
69 | 70 | * @param {string} operationType - The type of operation to replicate
|
70 | 71 | * @param {object} objectMD - The object metadata
|
| 72 | + * @param {AuthInfo} [authInfo] - authentication info of object owner |
71 | 73 | * @return {undefined}
|
72 | 74 | */
|
73 | 75 | function getReplicationInfo(objKey, bucketMD, isMD, objSize, operationType,
|
74 |
| - objectMD) { |
| 76 | + objectMD, authInfo) { |
75 | 77 | const content = isMD || objSize === 0 ? ['METADATA'] : ['DATA', 'METADATA'];
|
76 | 78 | const config = bucketMD.getReplicationConfiguration();
|
77 |
| - // If bucket does not have a replication configuration, do not replicate. |
78 |
| - if (config) { |
| 79 | + |
| 80 | + // Do not replicate object in the following cases: |
| 81 | + // |
| 82 | + // - bucket does not have a replication configuration |
| 83 | + // |
| 84 | + // - replication configuration does not apply to the object |
| 85 | + // (i.e. no rule matches object prefix) |
| 86 | + // |
| 87 | + // - object owner is an internal service account like Lifecycle |
| 88 | + // (because we do not want to replicate objects created from |
| 89 | + // actions triggered by internal services, by design) |
| 90 | + |
| 91 | + if (config && (!authInfo || !isBackbeatUser(authInfo.getCanonicalID()))) { |
79 | 92 | const rule = config.rules.find(rule => objKey.startsWith(rule.prefix));
|
80 | 93 | if (rule) {
|
81 | 94 | return _getReplicationInfo(rule, config, content, operationType,
|
|
0 commit comments