Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 17 additions & 44 deletions constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ const constants = {
// only public resources
publicId: 'http://acs.amazonaws.com/groups/global/AllUsers',
// All Authenticated Users is an ACL group.
allAuthedUsersId: 'http://acs.amazonaws.com/groups/' +
'global/AuthenticatedUsers',
allAuthedUsersId: 'http://acs.amazonaws.com/groups/' + 'global/AuthenticatedUsers',
// LogId is used for the AWS logger to write the logs
// to the destination bucket. This style of logging is
// to be implemented later but the logId is used in the
Expand All @@ -74,8 +73,7 @@ const constants = {

// Max size on put part or copy part is 5GB. For functional
// testing use 110 MB as max
maximumAllowedPartSize: process.env.MPU_TESTING === 'yes' ? 110100480 :
5368709120,
maximumAllowedPartSize: process.env.MPU_TESTING === 'yes' ? 110100480 : 5368709120,

// Max size allowed in a single put object request is 5GB
// https://docs.aws.amazon.com/AmazonS3/latest/dev/UploadingObjects.html
Expand All @@ -101,15 +99,14 @@ const constants = {
defaultApiBodySizeLimits: {
// Multi Objects Delete request can be large : up to 1000 keys of 1024 bytes is
// already 1mb, with the other fields it could reach 2mb
'multiObjectDelete': 2 * 1024 * 1024,
multiObjectDelete: 2 * 1024 * 1024,
// AWS sets the maximum size for bucket policies to 20 KB
// https://docs.aws.amazon.com/AmazonS3/latest/userguide/add-bucket-policy.html
'bucketPutPolicy': 20 * 1024,
bucketPutPolicy: 20 * 1024,
},

// hex digest of sha256 hash of empty string:
emptyStringHash: crypto.createHash('sha256')
.update('', 'binary').digest('hex'),
emptyStringHash: crypto.createHash('sha256').update('', 'binary').digest('hex'),

// Queries supported by AWS that we do not currently support.
// Non-bucket queries
Expand Down Expand Up @@ -164,8 +161,7 @@ const constants = {
/* eslint-enable camelcase */
mpuMDStoredOnS3Backend: { azure: true },
azureAccountNameRegex: /^[a-z0-9]{3,24}$/,
base64Regex: new RegExp('^(?:[A-Za-z0-9+/]{4})*' +
'(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$'),
base64Regex: new RegExp('^(?:[A-Za-z0-9+/]{4})*' + '(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$'),
productName: 'APN/1.0 Scality/1.0 Scality CloudServer for Zenko',
// location constraint delimiter
zenkoSeparator: ':',
Expand Down Expand Up @@ -203,32 +199,15 @@ const constants = {
invalidObjectUserMetadataHeader: 'x-amz-missing-meta',
// Bucket specific queries supported by AWS that we do not currently support
// these queries may or may not be supported at object level
unsupportedBucketQueries: [
],
suppressedUtapiEventFields: [
'object',
'location',
'versionId',
],
allowedUtapiEventFilterFields: [
'operationId',
'location',
'account',
'user',
'bucket',
],
arrayOfAllowed: [
'objectPutTagging',
'objectPutLegalHold',
'objectPutRetention',
],
unsupportedBucketQueries: [],
suppressedUtapiEventFields: ['object', 'location', 'versionId'],
allowedUtapiEventFilterFields: ['operationId', 'location', 'account', 'user', 'bucket'],
arrayOfAllowed: ['objectPutTagging', 'objectPutLegalHold', 'objectPutRetention'],
allowedUtapiEventFilterStates: ['allow', 'deny'],
allowedRestoreObjectRequestTierValues: ['Standard'],
// Only STANDARD class is supported, but keep the option to override supported values for now.
// This should be removed in CLDSRV-639.
validStorageClasses: process.env.VALID_STORAGE_CLASSES?.split(',') || [
'STANDARD',
],
validStorageClasses: process.env.VALID_STORAGE_CLASSES?.split(',') || ['STANDARD'],
lifecycleListing: {
CURRENT_TYPE: 'current',
NON_CURRENT_TYPE: 'noncurrent',
Expand Down Expand Up @@ -261,11 +240,7 @@ const constants = {
assumedRoleArnResourceType: 'assumed-role',
// Session name of the backbeat lifecycle assumed role session.
backbeatLifecycleSessionName: 'backbeat-lifecycle',
actionsToConsiderAsObjectPut: [
'initiateMultipartUpload',
'objectPutPart',
'completeMultipartUpload',
],
actionsToConsiderAsObjectPut: ['initiateMultipartUpload', 'objectPutPart', 'completeMultipartUpload'],
// if requester is not bucket owner, bucket policy actions should be denied with
// MethodNotAllowed error
onlyOwnerAllowed: [
Expand All @@ -279,14 +254,12 @@ const constants = {
rateLimitDefaultConfigCacheTTL: 30000, // 30 seconds
rateLimitDefaultBurstCapacity: 1,
rateLimitCleanupInterval: 10000, // 10 seconds
// S3-compatible Scality locations excluded as CRR cascade targets: they use the
// MultiBackend S3 path which bypasses putData/putMetadata routes, so loop detection
// cannot fire on those destinations.
crrCascadeBlockedLocationTypes: ['location-scality-ring-s3-v1', 'location-scality-artesca-s3-v1'],
// Supported attributes for the GetObjectAttributes 'x-amz-optional-attributes' header.
supportedGetObjectAttributes: new Set([
'StorageClass',
'ObjectSize',
'ObjectParts',
'Checksum',
'ETag',
]),
supportedGetObjectAttributes: new Set(['StorageClass', 'ObjectSize', 'ObjectParts', 'Checksum', 'ETag']),
};

module.exports = constants;
23 changes: 21 additions & 2 deletions lib/api/apiUtils/object/getReplicationInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,42 @@ function _canUserReplicate(authInfo) {
* @param {string} operationType - The type of operation to replicate
* @param {object} objectMD - The object metadata
* @param {AuthInfo} [authInfo] - authentication info of object owner
* @param {string[]} [blockedSiteTypes=[]] - location types to exclude from the returned backends
* @return {object|undefined}
*/
function getReplicationInfo(s3config, objKey, bucketMD, isMD, objSize, operationType, objectMD, authInfo) {
function getReplicationInfo(
s3config,
objKey,
bucketMD,
isMD,
objSize,
operationType,
objectMD,
authInfo,
blockedSiteTypes = [],
) {
const config = bucketMD.getReplicationConfiguration();
if (!config || !_canUserReplicate(authInfo)) {
return undefined;
}

const isCloud = site => !!replicationBackends[s3config.locationConstraints[site]?.type];
const rules = _withDefaultStorageClass(config.rules || [], s3config);
const backends = ReplicationConfiguration.resolveBackends(
const allBackends = ReplicationConfiguration.resolveBackends(
{ ...config, rules },
objKey,
isCloud,
objectMD?.replicationInfo?.backends,
);

const backends =
blockedSiteTypes.length > 0
? allBackends.filter(b => {
const loc = s3config.locationConstraints[b.site];
return !loc || !blockedSiteTypes.includes(loc.type);
})
: allBackends;

if (backends.length === 0) {
return undefined;
}
Expand Down
Loading
Loading