Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test-imp-deny-changes #5340

Draft
wants to merge 29 commits into
base: improvement/CLDSRV-431-misc-api-impDeny
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3866660
CLDSRV-426: update ACL permission checks for implicitDeny logic
KazToozs Sep 11, 2023
93e886c
CLDSRV-426: add tests for ACL permission check updates
KazToozs Sep 11, 2023
8714bc6
CLDSRV-427: update bucket/object perm checks to account for implicit …
KazToozs Aug 28, 2023
41e0285
fixup: lint
KazToozs Aug 28, 2023
42a8288
fixup: retrocompatibility changes
KazToozs Aug 30, 2023
e75fd7e
fixup: retrocompatibility changes
KazToozs Aug 30, 2023
5a2a7c6
fixup: retrocompatibility changes
KazToozs Aug 30, 2023
548a28d
fixup: retrocompatibility changes
KazToozs Aug 30, 2023
46d7af2
CLDSRV-428: put apis updated for implicit deny
KazToozs Aug 28, 2023
9fea4b8
fixup: missing constants change
KazToozs Aug 28, 2023
cd2db8f
linting
KazToozs Aug 30, 2023
2492aad
api updates
KazToozs Sep 12, 2023
96f4877
skip irrelevant apis
KazToozs Sep 12, 2023
144eacf
lint
KazToozs Sep 12, 2023
0733f75
test skips
KazToozs Sep 12, 2023
5e7ae37
lint
KazToozs Sep 12, 2023
70766b8
lint
KazToozs Sep 12, 2023
8cafabd
CLDSRV-430: add delete API implicit deny logic
KazToozs Sep 13, 2023
d25741d
CLDSRV-430: update delete API tests for impDeny logic
KazToozs Sep 13, 2023
3cc52d8
fixup: skips
KazToozs Sep 13, 2023
c802961
CLDSRV-429: update get apis with impDeny logic
KazToozs Sep 13, 2023
882b6e2
CLDSRV-429: update get apis tests with impDenylogic
KazToozs Sep 13, 2023
4722df4
fixup: skips
KazToozs Sep 13, 2023
3f21e42
fixup: skips
KazToozs Sep 13, 2023
844ec13
CLDSRV-431: implment other API impDeny logic
KazToozs Sep 13, 2023
796986f
CLDSRV-431: updatye other API impDeny test logic
KazToozs Sep 13, 2023
224c1a3
fixup: remove skips
KazToozs Sep 13, 2023
9e46a89
fixup: remove skips
KazToozs Sep 13, 2023
288b2d0
test-imp-deny-changes
KazToozs Sep 15, 2023
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
2 changes: 2 additions & 0 deletions constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ const constants = {
'objectDeleteTagging',
'objectGetTagging',
'objectPutTagging',
'objectPutLegalHold',
'objectPutRetention',
],
// response header to be sent when there are invalid
// user metadata in the object's metadata
Expand Down
10 changes: 5 additions & 5 deletions lib/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const api = {
// no need to check auth on website or cors preflight requests
if (apiMethod === 'websiteGet' || apiMethod === 'websiteHead' ||
apiMethod === 'corsPreflight') {
request.iamAuthzResults = false;
request.actionImplicitDenies = false;
return this[apiMethod](request, log, callback);
}

Expand Down Expand Up @@ -254,11 +254,11 @@ const api = {
return callback(checkedResults);
}
returnTagCount = checkedResults.returnTagCount;
request.iamAuthzResults = checkedResults.isImplicitDeny;
request.actionImplicitDenies = checkedResults.isImplicitDeny;
} else {
// create an object of keys apiMethods with all values to false
request.iamAuthzResults = apiMethods.reduce((acc, curr) => {
acc[curr] = false;
// create an object of keys apiMethods with all values to true
request.actionImplicitDenies = apiMethods.reduce((acc, curr) => {
acc[curr] = true;
return acc;
}, {});
}
Expand Down
331 changes: 240 additions & 91 deletions lib/api/apiUtils/authorization/permissionChecks.js

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions lib/api/apiUtils/bucket/bucketDeletion.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function _deleteMPUbucket(destinationBucketName, log, cb) {
});
}

function _deleteOngoingMPUs(authInfo, bucketName, bucketMD, mpus, log, cb) {
function _deleteOngoingMPUs(authInfo, bucketName, bucketMD, mpus, request, log, cb) {
async.mapLimit(mpus, 1, (mpu, next) => {
const splitterChar = mpu.key.includes(oldSplitter) ?
oldSplitter : splitter;
Expand All @@ -40,7 +40,7 @@ function _deleteOngoingMPUs(authInfo, bucketName, bucketMD, mpus, log, cb) {
byteLength: partSizeSum,
});
next(err);
});
}, request);
}, cb);
}
/**
Expand All @@ -49,11 +49,13 @@ function _deleteOngoingMPUs(authInfo, bucketName, bucketMD, mpus, log, cb) {
* @param {object} bucketMD - bucket attributes/metadata
* @param {string} bucketName - bucket in which objectMetadata is stored
* @param {string} canonicalID - account canonicalID of requester
* @param {object} request - request object given by router
* including normalized headers
* @param {object} log - Werelogs logger
* @param {function} cb - callback from async.waterfall in bucketDelete
* @return {undefined}
*/
function deleteBucket(authInfo, bucketMD, bucketName, canonicalID, log, cb) {
function deleteBucket(authInfo, bucketMD, bucketName, canonicalID, request, log, cb) {
log.trace('deleting bucket from metadata');
assert.strictEqual(typeof bucketName, 'string');
assert.strictEqual(typeof canonicalID, 'string');
Expand Down Expand Up @@ -100,7 +102,7 @@ function deleteBucket(authInfo, bucketMD, bucketName, canonicalID, log, cb) {
}
if (objectsListRes.Contents.length) {
return _deleteOngoingMPUs(authInfo, bucketName,
bucketMD, objectsListRes.Contents, log, err => {
bucketMD, objectsListRes.Contents, request, log, err => {
if (err) {
return next(err);
}
Expand Down
11 changes: 9 additions & 2 deletions lib/api/apiUtils/object/abortMultipartUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ function abortMultipartUpload(authInfo, bucketName, objectKey, uploadId, log,
// but the requestType is the more general 'objectDelete'
const metadataValParams = Object.assign({}, metadataValMPUparams);
metadataValParams.requestType = 'objectPut';
const authzIdentityResult = request ? request.actionImplicitDenies : true;

async.waterfall([
function checkDestBucketVal(next) {
metadataValidateBucketAndObj(metadataValParams, log,
metadataValidateBucketAndObj(metadataValParams, authzIdentityResult, log,
(err, destinationBucket) => {
if (err) {
return next(err, destinationBucket);
Expand Down Expand Up @@ -56,9 +57,15 @@ function abortMultipartUpload(authInfo, bucketName, objectKey, uploadId, log,
function abortExternalMpu(mpuBucket, mpuOverviewObj, destBucket,
next) {
const location = mpuOverviewObj.controllingLocationConstraint;
const originalIdentityImpDenies = request.actionImplicitDenies;
// eslint-disable-next-line no-param-reassign
// eslint-disable-next-line no-param-reassign
delete request.actionImplicitDenies;
return data.abortMPU(objectKey, uploadId, location, bucketName,
request, destBucket, locationConstraintCheck, log,
request, destBucket, locationConstraintCheck, log,
(err, skipDataDelete) => {
// eslint-disable-next-line no-param-reassign
request.actionImplicitDenies = originalIdentityImpDenies;
if (err) {
return next(err, destBucket);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/api/bucketDelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function bucketDelete(authInfo, request, log, cb) {
request,
};

return metadataValidateBucket(metadataValParams, log,
return metadataValidateBucket(metadataValParams, request.actionImplicitDenies, log,
(err, bucketMD) => {
const corsHeaders = collectCorsHeaders(request.headers.origin,
request.method, bucketMD);
Expand All @@ -43,7 +43,7 @@ function bucketDelete(authInfo, request, log, cb) {
log.trace('passed checks',
{ method: 'metadataValidateBucket' });
return deleteBucket(authInfo, bucketMD, bucketName,
authInfo.getCanonicalID(), log, err => {
authInfo.getCanonicalID(), request, log, err => {
if (err) {
return cb(err, corsHeaders);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/api/bucketDeleteCors.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ function bucketDeleteCors(authInfo, request, log, callback) {
}
log.trace('found bucket in metadata');

if (!isBucketAuthorized(bucket, requestType, canonicalID, authInfo, log, request)) {
if (!isBucketAuthorized(bucket, requestType, canonicalID, authInfo,
request.actionImplicitDenies, log, request)) {
log.debug('access denied for user on bucket', {
requestType,
method: 'bucketDeleteCors',
Expand Down
2 changes: 1 addition & 1 deletion lib/api/bucketDeleteEncryption.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function bucketDeleteEncryption(authInfo, request, log, callback) {
};

return async.waterfall([
next => metadataValidateBucket(metadataValParams, log, next),
next => metadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, next),
(bucket, next) => checkExpectedBucketOwner(request.headers, bucket, log, err => next(err, bucket)),
(bucket, next) => {
const sseConfig = bucket.getServerSideEncryption();
Expand Down
2 changes: 1 addition & 1 deletion lib/api/bucketDeleteLifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function bucketDeleteLifecycle(authInfo, request, log, callback) {
requestType: 'bucketDeleteLifecycle',
request,
};
return metadataValidateBucket(metadataValParams, log, (err, bucket) => {
return metadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, (err, bucket) => {
const corsHeaders = collectCorsHeaders(headers.origin, method, bucket);
if (err) {
log.debug('error processing request', {
Expand Down
2 changes: 1 addition & 1 deletion lib/api/bucketDeletePolicy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function bucketDeletePolicy(authInfo, request, log, callback) {
requestType: 'bucketDeletePolicy',
request,
};
return metadataValidateBucket(metadataValParams, log, (err, bucket) => {
return metadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, (err, bucket) => {
const corsHeaders = collectCorsHeaders(headers.origin, method, bucket);
if (err) {
log.debug('error processing request', {
Expand Down
2 changes: 1 addition & 1 deletion lib/api/bucketDeleteReplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function bucketDeleteReplication(authInfo, request, log, callback) {
requestType: 'bucketDeleteReplication',
request,
};
return metadataValidateBucket(metadataValParams, log, (err, bucket) => {
return metadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, (err, bucket) => {
const corsHeaders = collectCorsHeaders(headers.origin, method, bucket);
if (err) {
log.debug('error processing request', {
Expand Down
3 changes: 2 additions & 1 deletion lib/api/bucketDeleteWebsite.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ function bucketDeleteWebsite(authInfo, request, log, callback) {
}
log.trace('found bucket in metadata');

if (!isBucketAuthorized(bucket, requestType, canonicalID, authInfo, log, request)) {
if (!isBucketAuthorized(bucket, requestType, canonicalID, authInfo,
request.actionImplicitDenies, log, request)) {
log.debug('access denied for user on bucket', {
requestType,
method: 'bucketDeleteWebsite',
Expand Down
2 changes: 1 addition & 1 deletion lib/api/bucketGet.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ function bucketGet(authInfo, request, log, callback) {
listParams.marker = params.marker;
}

metadataValidateBucket(metadataValParams, log, (err, bucket) => {
metadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, (err, bucket) => {
const corsHeaders = collectCorsHeaders(request.headers.origin,
request.method, bucket);
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion lib/api/bucketGetACL.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function bucketGetACL(authInfo, request, log, callback) {
},
};

metadataValidateBucket(metadataValParams, log, (err, bucket) => {
metadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, (err, bucket) => {
const corsHeaders = collectCorsHeaders(request.headers.origin,
request.method, bucket);
if (err) {
Expand Down
3 changes: 2 additions & 1 deletion lib/api/bucketGetCors.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ function bucketGetCors(authInfo, request, log, callback) {
const corsHeaders = collectCorsHeaders(request.headers.origin,
request.method, bucket);

if (!isBucketAuthorized(bucket, requestType, canonicalID, authInfo, log, request)) {
if (!isBucketAuthorized(bucket, requestType, canonicalID, authInfo,
request.actionImplicitDenies, log, request)) {
log.debug('access denied for user on bucket', {
requestType,
method: 'bucketGetCors',
Expand Down
2 changes: 1 addition & 1 deletion lib/api/bucketGetEncryption.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function bucketGetEncryption(authInfo, request, log, callback) {
};

return async.waterfall([
next => metadataValidateBucket(metadataValParams, log, next),
next => metadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, next),
(bucket, next) => checkExpectedBucketOwner(request.headers, bucket, log, err => next(err, bucket)),
(bucket, next) => {
// If sseInfo is present but the `mandatory` flag is not set
Expand Down
2 changes: 1 addition & 1 deletion lib/api/bucketGetLifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function bucketGetLifecycle(authInfo, request, log, callback) {
requestType: 'bucketGetLifecycle',
request,
};
return metadataValidateBucket(metadataValParams, log, (err, bucket) => {
return metadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, (err, bucket) => {
const corsHeaders = collectCorsHeaders(headers.origin, method, bucket);
if (err) {
log.debug('error processing request', {
Expand Down
3 changes: 2 additions & 1 deletion lib/api/bucketGetLocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ function bucketGetLocation(authInfo, request, log, callback) {
const corsHeaders = collectCorsHeaders(request.headers.origin,
request.method, bucket);

if (!isBucketAuthorized(bucket, requestType, canonicalID, authInfo, log, request)) {
if (!isBucketAuthorized(bucket, requestType, canonicalID, authInfo,
request.actionImplicitDenies, log, request)) {
log.debug('access denied for account on bucket', {
requestType,
method: 'bucketGetLocation',
Expand Down
2 changes: 1 addition & 1 deletion lib/api/bucketGetNotification.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function bucketGetNotification(authInfo, request, log, callback) {
request,
};

return metadataValidateBucket(metadataValParams, log, (err, bucket) => {
return metadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, (err, bucket) => {
const corsHeaders = collectCorsHeaders(headers.origin, method, bucket);
if (err) {
log.debug('error processing request', {
Expand Down
2 changes: 1 addition & 1 deletion lib/api/bucketGetObjectLock.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function bucketGetObjectLock(authInfo, request, log, callback) {
requestType: 'bucketGetObjectLock',
request,
};
return metadataValidateBucket(metadataValParams, log, (err, bucket) => {
return metadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, (err, bucket) => {
const corsHeaders = collectCorsHeaders(headers.origin, method, bucket);
if (err) {
log.debug('error processing request', {
Expand Down
2 changes: 1 addition & 1 deletion lib/api/bucketGetPolicy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function bucketGetPolicy(authInfo, request, log, callback) {
request,
};

return metadataValidateBucket(metadataValParams, log, (err, bucket) => {
return metadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, (err, bucket) => {
const corsHeaders = collectCorsHeaders(headers.origin, method, bucket);
if (err) {
log.debug('error processing request', {
Expand Down
2 changes: 1 addition & 1 deletion lib/api/bucketGetReplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function bucketGetReplication(authInfo, request, log, callback) {
requestType: 'bucketGetReplication',
request,
};
return metadataValidateBucket(metadataValParams, log, (err, bucket) => {
return metadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, (err, bucket) => {
const corsHeaders = collectCorsHeaders(headers.origin, method, bucket);
if (err) {
log.debug('error processing request', {
Expand Down
2 changes: 1 addition & 1 deletion lib/api/bucketGetVersioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function bucketGetVersioning(authInfo, request, log, callback) {
request,
};

metadataValidateBucket(metadataValParams, log, (err, bucket) => {
metadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, (err, bucket) => {
const corsHeaders = collectCorsHeaders(request.headers.origin,
request.method, bucket);
if (err) {
Expand Down
3 changes: 2 additions & 1 deletion lib/api/bucketGetWebsite.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ function bucketGetWebsite(authInfo, request, log, callback) {

const corsHeaders = collectCorsHeaders(request.headers.origin,
request.method, bucket);
if (!isBucketAuthorized(bucket, requestType, canonicalID, authInfo, log, request)) {
if (!isBucketAuthorized(bucket, requestType, canonicalID, authInfo,
request.actionImplicitDenies, log, request)) {
log.debug('access denied for user on bucket', {
requestType,
method: 'bucketGetWebsite',
Expand Down
2 changes: 1 addition & 1 deletion lib/api/bucketHead.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function bucketHead(authInfo, request, log, callback) {
requestType: 'bucketHead',
request,
};
metadataValidateBucket(metadataValParams, log, (err, bucket) => {
metadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, (err, bucket) => {
const corsHeaders = collectCorsHeaders(request.headers.origin,
request.method, bucket);
if (err) {
Expand Down
Loading
Loading