* Store server access log information in the request object * @param {object} request - HTTP request object * @param {object} bucket - Bucket metadata object * @param {string} raftSessionId - Raft session ID from metadata backend * @param {object} [options] - Optional configuration * @param {bo
(request, bucket, raftSessionId, options = {})
| 34 | * @return {undefined} |
| 35 | */ |
| 36 | function storeServerAccessLogInfo(request, bucket, raftSessionId, options = {}) { |
| 37 | /* eslint-disable no-param-reassign */ |
| 38 | |
| 39 | if (!request || !request.serverAccessLog) { |
| 40 | return; |
| 41 | } |
| 42 | |
| 43 | if (options.copySource) { |
| 44 | // Copy operations need information for a special GET log entry on the source side |
| 45 | if (!request.sourceServerAccessLog) { |
| 46 | request.sourceServerAccessLog = { enabled: false }; |
| 47 | } |
| 48 | const target = request.sourceServerAccessLog; |
| 49 | target.raftSessionID = raftSessionId; |
| 50 | if (bucket) { |
| 51 | target.bucketOwner = bucket.getOwner(); |
| 52 | target.bucketName = bucket.getName(); |
| 53 | } |
| 54 | if (bucket && bucket.getBucketLoggingStatus() && bucket.getBucketLoggingStatus().getLoggingEnabled()) { |
| 55 | target.enabled = true; |
| 56 | target.loggingEnabled = bucket.getBucketLoggingStatus().getLoggingEnabled(); |
| 57 | } |
| 58 | // Source auth runs on the same request object and overwrites the |
| 59 | // destination's aclRequired. Move the source value to its log entry |
| 60 | // and restore the destination value that was saved before source auth. |
| 61 | target.aclRequired = request.serverAccessLog.aclRequired; |
| 62 | request.serverAccessLog.aclRequired = options.savedAclRequired; |
| 63 | } else { |
| 64 | // Default behavior: store in main serverAccessLog |
| 65 | request.serverAccessLog.raftSessionID = raftSessionId; |
| 66 | if (bucket) { |
| 67 | request.serverAccessLog.bucketOwner = bucket.getOwner(); |
| 68 | } |
| 69 | if (bucket && bucket.getBucketLoggingStatus() && bucket.getBucketLoggingStatus().getLoggingEnabled()) { |
| 70 | request.serverAccessLog.enabled = true; |
| 71 | request.serverAccessLog.loggingEnabled = bucket.getBucketLoggingStatus().getLoggingEnabled(); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | /* eslint-enable no-param-reassign */ |
| 76 | } |
| 77 | |
| 78 | /** getNullVersionFromMaster - retrieves the null version |
| 79 | * metadata via retrieving the master key |
no test coverage detected