Skip to content

Commit

Permalink
Merge branch 'development/7.10' into bugfix/CLDSRV-269/policy-checks-…
Browse files Browse the repository at this point in the history
…for-put-bucket-with-object-lock

(cherry picked from commit 09c8cd0)
  • Loading branch information
miniscruff authored and alexanderchan-scality committed Nov 24, 2022
1 parent 6861d7e commit ea2d8d7
Showing 1 changed file with 20 additions and 51 deletions.
71 changes: 20 additions & 51 deletions lib/api/bucketPut.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,6 @@ function bucketPut(authInfo, request, log, callback) {
'for internal purposes'));
}

let authParams;
let ip;
let requestConstantParams;
if (authInfo.isRequesterAnIAMUser()) {
authParams = auth.server.extractParams(request, log, 's3', request.query);
ip = requestUtils.getClientIp(request, config);
requestConstantParams = {
authParams,
ip,
bucketName,
request,
authInfo,
};
}

return waterfall([
next => _parseXML(request, log, next),
(locationConstraint, next) => {
Expand All @@ -190,47 +175,31 @@ function bucketPut(authInfo, request, log, callback) {
return next(null, locationConstraint);
}

requestConstantParams.locationConstraint = locationConstraint;
requestConstantParams.apiMethod = 'bucketPut';

return vault.checkPolicies(
_buildConstantParams(requestConstantParams),
authInfo.getArn(),
log,
_handleAuthResults(locationConstraint, log, next),
);
},
(locationConstraint, next) => {
if (!authInfo.isRequesterAnIAMUser()) {
return next(null, locationConstraint);
}
const authParams = auth.server.extractParams(request, log, 's3', request.query);
const ip = requestUtils.getClientIp(request, config);
const requestConstantParams = [{
authParams,
ip,
bucketName,
request,
authInfo,
locationConstraint: locationConstraint,
apiMethod: 'bucketPut',
}];

if (!_isObjectLockEnabled(request.headers)) {
return next(null, locationConstraint);
requestConstantParams.push({
...requestConstantParams[0],
apiMethod: 'bucketPutObjectLock',
});
requestConstantParams.push({
...requestConstantParams[0],
apiMethod: 'bucketPutVersioning',
});
}

requestConstantParams.apiMethod = 'bucketPutObjectLock';

return vault.checkPolicies(
_buildConstantParams(requestConstantParams),
authInfo.getArn(),
log,
_handleAuthResults(locationConstraint, log, next),
);
},
(locationConstraint, next) => {
if (!authInfo.isRequesterAnIAMUser()) {
return next(null, locationConstraint);
}

if (!_isObjectLockEnabled(request.headers)) {
return next(null, locationConstraint);
}

requestConstantParams.apiMethod = 'bucketPutVersioning';

return vault.checkPolicies(
_buildConstantParams(requestConstantParams),
requestConstantParams.map(_buildConstantParams),
authInfo.getArn(),
log,
_handleAuthResults(locationConstraint, log, next),
Expand Down

0 comments on commit ea2d8d7

Please sign in to comment.