add missing principalId in web notifications (#11777)

fixes #11561
This commit is contained in:
Harshavardhana 2021-03-13 10:52:43 -08:00 committed by GitHub
parent 5e003549cc
commit afbd3e41eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -225,10 +225,13 @@ func (web *webAPIHandlers) MakeBucket(r *http.Request, args *MakeBucketArgs, rep
reply.UIVersion = Version reply.UIVersion = Version
reqParams := extractReqParams(r)
reqParams["accessKey"] = claims.AccessKey
sendEvent(eventArgs{ sendEvent(eventArgs{
EventName: event.BucketCreated, EventName: event.BucketCreated,
BucketName: args.BucketName, BucketName: args.BucketName,
ReqParams: extractReqParams(r), ReqParams: reqParams,
UserAgent: r.UserAgent(), UserAgent: r.UserAgent(),
Host: handlers.GetSourceIP(r), Host: handlers.GetSourceIP(r),
}) })
@ -307,10 +310,13 @@ func (web *webAPIHandlers) DeleteBucket(r *http.Request, args *RemoveBucketArgs,
} }
} }
reqParams := extractReqParams(r)
reqParams["accessKey"] = claims.AccessKey
sendEvent(eventArgs{ sendEvent(eventArgs{
EventName: event.BucketRemoved, EventName: event.BucketRemoved,
BucketName: args.BucketName, BucketName: args.BucketName,
ReqParams: extractReqParams(r), ReqParams: reqParams,
UserAgent: r.UserAgent(), UserAgent: r.UserAgent(),
Host: handlers.GetSourceIP(r), Host: handlers.GetSourceIP(r),
}) })
@ -715,6 +721,11 @@ func (web *webAPIHandlers) RemoveObject(r *http.Request, args *RemoveObjectArgs,
err error err error
replicateSync bool replicateSync bool
) )
reqParams := extractReqParams(r)
reqParams["accessKey"] = claims.AccessKey
sourceIP := handlers.GetSourceIP(r)
next: next:
for _, objectName := range args.Objects { for _, objectName := range args.Objects {
// If not a directory, remove the object. // If not a directory, remove the object.
@ -756,7 +767,10 @@ next:
} }
if hasReplicationRules(ctx, args.BucketName, []ObjectToDelete{{ObjectName: objectName}}) || hasLifecycleConfig { if hasReplicationRules(ctx, args.BucketName, []ObjectToDelete{{ObjectName: objectName}}) || hasLifecycleConfig {
goi, gerr = getObjectInfoFn(ctx, args.BucketName, objectName, opts) goi, gerr = getObjectInfoFn(ctx, args.BucketName, objectName, opts)
if _, replicateDel, replicateSync = checkReplicateDelete(ctx, args.BucketName, ObjectToDelete{ObjectName: objectName, VersionID: goi.VersionID}, goi, gerr); replicateDel { if _, replicateDel, replicateSync = checkReplicateDelete(ctx, args.BucketName, ObjectToDelete{
ObjectName: objectName,
VersionID: goi.VersionID,
}, goi, gerr); replicateDel {
opts.DeleteMarkerReplicationStatus = string(replication.Pending) opts.DeleteMarkerReplicationStatus = string(replication.Pending)
opts.DeleteMarker = true opts.DeleteMarker = true
} }
@ -789,9 +803,9 @@ next:
EventName: eventName, EventName: eventName,
BucketName: args.BucketName, BucketName: args.BucketName,
Object: oi, Object: oi,
ReqParams: extractReqParams(r), ReqParams: reqParams,
UserAgent: r.UserAgent(), UserAgent: r.UserAgent(),
Host: handlers.GetSourceIP(r), Host: sourceIP,
}) })
if replicateDel { if replicateDel {
@ -933,9 +947,9 @@ next:
EventName: event.ObjectRemovedDelete, EventName: event.ObjectRemovedDelete,
BucketName: args.BucketName, BucketName: args.BucketName,
Object: objInfo, Object: objInfo,
ReqParams: extractReqParams(r), ReqParams: reqParams,
UserAgent: r.UserAgent(), UserAgent: r.UserAgent(),
Host: handlers.GetSourceIP(r), Host: sourceIP,
}) })
if dobj.DeleteMarkerReplicationStatus == string(replication.Pending) || dobj.VersionPurgeStatus == Pending { if dobj.DeleteMarkerReplicationStatus == string(replication.Pending) || dobj.VersionPurgeStatus == Pending {
dv := DeletedObjectVersionInfo{ dv := DeletedObjectVersionInfo{
@ -1325,12 +1339,15 @@ func (web *webAPIHandlers) Upload(w http.ResponseWriter, r *http.Request) {
scheduleReplication(ctx, objInfo.Clone(), objectAPI, sync) scheduleReplication(ctx, objInfo.Clone(), objectAPI, sync)
} }
reqParams := extractReqParams(r)
reqParams["accessKey"] = claims.AccessKey
// Notify object created event. // Notify object created event.
sendEvent(eventArgs{ sendEvent(eventArgs{
EventName: event.ObjectCreatedPut, EventName: event.ObjectCreatedPut,
BucketName: bucket, BucketName: bucket,
Object: objInfo, Object: objInfo,
ReqParams: extractReqParams(r), ReqParams: reqParams,
RespElements: extractRespElements(w), RespElements: extractRespElements(w),
UserAgent: r.UserAgent(), UserAgent: r.UserAgent(),
Host: handlers.GetSourceIP(r), Host: handlers.GetSourceIP(r),
@ -1511,12 +1528,15 @@ func (web *webAPIHandlers) Download(w http.ResponseWriter, r *http.Request) {
} }
} }
reqParams := extractReqParams(r)
reqParams["accessKey"] = claims.AccessKey
// Notify object accessed via a GET request. // Notify object accessed via a GET request.
sendEvent(eventArgs{ sendEvent(eventArgs{
EventName: event.ObjectAccessedGet, EventName: event.ObjectAccessedGet,
BucketName: bucket, BucketName: bucket,
Object: objInfo, Object: objInfo,
ReqParams: extractReqParams(r), ReqParams: reqParams,
RespElements: extractRespElements(w), RespElements: extractRespElements(w),
UserAgent: r.UserAgent(), UserAgent: r.UserAgent(),
Host: handlers.GetSourceIP(r), Host: handlers.GetSourceIP(r),
@ -1663,6 +1683,10 @@ func (web *webAPIHandlers) DownloadZip(w http.ResponseWriter, r *http.Request) {
archive := zip.NewWriter(w) archive := zip.NewWriter(w)
defer archive.Close() defer archive.Close()
reqParams := extractReqParams(r)
reqParams["accessKey"] = claims.AccessKey
respElements := extractRespElements(w)
for i, object := range args.Objects { for i, object := range args.Objects {
// Writes compressed object file to the response. // Writes compressed object file to the response.
zipit := func(objectName string) error { zipit := func(objectName string) error {
@ -1719,8 +1743,8 @@ func (web *webAPIHandlers) DownloadZip(w http.ResponseWriter, r *http.Request) {
EventName: event.ObjectAccessedGet, EventName: event.ObjectAccessedGet,
BucketName: args.BucketName, BucketName: args.BucketName,
Object: info, Object: info,
ReqParams: extractReqParams(r), ReqParams: reqParams,
RespElements: extractRespElements(w), RespElements: respElements,
UserAgent: r.UserAgent(), UserAgent: r.UserAgent(),
Host: host, Host: host,
}) })