MCPcopy
hub / github.com/scality/cloudserver / objectPutACL

Function objectPutACL

lib/api/objectPutACL.js:46–321  ·  view source on GitHub ↗

* Object Put ACL - Create object ACL * @param {AuthInfo} authInfo - Instance of AuthInfo class with requester's info * @param {object} request - http request object * @param {object} log - Werelogs logger * @param {function} cb - cb to server * @return {undefined}

(authInfo, request, log, cb)

Source from the content-addressed store, hash-verified

44 * @return {undefined}
45 */
46function objectPutACL(authInfo, request, log, cb) {
47 log.debug('processing request', { method: 'objectPutACL' });
48 const { bucketName, objectKey } = request;
49 const newCannedACL = request.headers['x-amz-acl'];
50 const possibleCannedACL = [
51 'private',
52 'public-read',
53 'public-read-write',
54 'authenticated-read',
55 'bucket-owner-read',
56 'bucket-owner-full-control',
57 ];
58 if (newCannedACL && possibleCannedACL.indexOf(newCannedACL) === -1) {
59 log.trace('invalid canned acl argument', { cannedAcl: newCannedACL });
60 monitoring.promMetrics('PUT', bucketName, 400, 'putObjectAcl');
61 return cb(errors.InvalidArgument);
62 }
63 if (!aclUtils.checkGrantHeaderValidity(request.headers)) {
64 log.trace('invalid acl header');
65 monitoring.promMetrics('PUT', bucketName, 400, 'putObjectAcl');
66 return cb(errors.InvalidArgument);
67 }
68 const possibleGroups = [
69 constants.publicId,
70 constants.allAuthedUsersId,
71 constants.logId,
72 ];
73
74 const decodedVidResult = decodeVersionId(request.query);
75 if (decodedVidResult instanceof Error) {
76 log.trace('invalid versionId query', {
77 versionId: request.query.versionId,
78 error: decodedVidResult,
79 });
80 return cb(decodedVidResult);
81 }
82 const reqVersionId = decodedVidResult;
83
84 const metadataValParams = {
85 authInfo,
86 bucketName,
87 objectKey,
88 versionId: reqVersionId,
89 getDeleteMarker: true,
90 requestType: request.apiMethods || 'objectPutACL',
91 request,
92 };
93
94 const possibleGrants = ['FULL_CONTROL', 'WRITE_ACP', 'READ', 'READ_ACP'];
95 const addACLParams = {
96 Canned: '',
97 FULL_CONTROL: [],
98 WRITE_ACP: [],
99 READ: [],
100 READ_ACP: [],
101 };
102
103 const grantReadHeader =

Callers 4

objectPutACL.jsFile · 0.85
transientBucket.jsFile · 0.85

Calls 8

collectCorsHeadersFunction · 0.85
getVersionIdResHeaderFunction · 0.85
pushMetricFunction · 0.85
debugMethod · 0.80
traceMethod · 0.80
decodeVersionIdFunction · 0.50

Tested by

no test coverage detected