@@ -10,6 +10,23 @@ const { onlyOwnerAllowed } = require('../../constants');
1010const { actionNeedQuotaCheck, actionWithDataDeletion } = require ( 'arsenal/build/lib/policyEvaluator/RequestContext' ) ;
1111const { processBytesToWrite, validateQuotas } = require ( '../api/apiUtils/quotas/quotaUtils' ) ;
1212
13+ function storeServerAccessLogInfo ( request , authInfo , bucket ) {
14+ if ( request &&
15+ request . serverAccessLog &&
16+ authInfo &&
17+ bucket &&
18+ bucket . getBucketLoggingStatus ( ) &&
19+ bucket . getBucketLoggingStatus ( ) . getLoggingEnabled ( ) ) {
20+ /* eslint-disable no-param-reassign */
21+ request . serverAccessLog . enabled = true ;
22+ request . serverAccessLog . bucketOwner = bucket . getOwner ( ) ;
23+ request . serverAccessLog . bucketName = bucket . getName ( ) ;
24+ request . serverAccessLog . authInfo = authInfo ;
25+ request . serverAccessLog . loggingEnabled = bucket . getBucketLoggingStatus ( ) . getLoggingEnabled ( ) ;
26+ /* eslint-enable no-param-reassign */
27+ }
28+ }
29+
1330/** getNullVersionFromMaster - retrieves the null version
1431 * metadata via retrieving the master key
1532 *
@@ -274,6 +291,7 @@ function standardMetadataValidateBucketAndObj(params, actionImplicitDenies, log,
274291 contentLength , withVersionId , log , err => next ( err , bucket , objMD ) ) ;
275292 } ,
276293 ] , ( err , bucket , objMD ) => {
294+ storeServerAccessLogInfo ( request , authInfo , bucket ) ;
277295 if ( err ) {
278296 // still return bucket for cors headers
279297 return callback ( err , bucket ) ;
@@ -296,6 +314,7 @@ function standardMetadataValidateBucketAndObj(params, actionImplicitDenies, log,
296314function standardMetadataValidateBucket ( params , actionImplicitDenies , log , callback ) {
297315 const { bucketName } = params ;
298316 return metadata . getBucket ( bucketName , log , ( err , bucket ) => {
317+ storeServerAccessLogInfo ( params . request , params . authInfo , bucket ) ;
299318 if ( err ) {
300319 // if some implicit actionImplicitDenies, return AccessDenied before
301320 // leaking any state information
0 commit comments