Skip to content

Commit

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

This reverts commit ea2d8d7.
  • Loading branch information
alexanderchan-scality committed Nov 29, 2022
1 parent f1f9ee0 commit f3323f5
Showing 1 changed file with 51 additions and 20 deletions.
71 changes: 51 additions & 20 deletions lib/api/bucketPut.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,21 @@ 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 @@ -175,31 +190,47 @@ function bucketPut(authInfo, request, log, callback) {
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',
}];
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);
}

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

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(
requestConstantParams.map(_buildConstantParams),
_buildConstantParams(requestConstantParams),
authInfo.getArn(),
log,
_handleAuthResults(locationConstraint, log, next),
Expand Down

0 comments on commit f3323f5

Please sign in to comment.