add acting user to the audit log
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
libregraph "github.com/owncloud/libre-graph-api-go"
|
||||
"github.com/owncloud/ocis/v2/extensions/graph/pkg/service/v0/errorcode"
|
||||
|
||||
ctxpkg "github.com/cs3org/reva/v2/pkg/ctx"
|
||||
"github.com/cs3org/reva/v2/pkg/events"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/render"
|
||||
@@ -83,7 +84,8 @@ func (g Graph) PostGroup(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if grp != nil && grp.Id != nil {
|
||||
g.publishEvent(events.GroupCreated{GroupID: *grp.Id})
|
||||
currentUser := ctxpkg.ContextMustGetUser(r.Context())
|
||||
g.publishEvent(events.GroupCreated{Executant: currentUser.Id, GroupID: *grp.Id})
|
||||
}
|
||||
render.Status(r, http.StatusOK)
|
||||
render.JSON(w, r, grp)
|
||||
@@ -202,7 +204,8 @@ func (g Graph) DeleteGroup(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
g.publishEvent(events.GroupDeleted{GroupID: groupID})
|
||||
currentUser := ctxpkg.ContextMustGetUser(r.Context())
|
||||
g.publishEvent(events.GroupDeleted{Executant: currentUser.Id, GroupID: groupID})
|
||||
render.Status(r, http.StatusNoContent)
|
||||
render.NoContent(w, r)
|
||||
}
|
||||
@@ -286,7 +289,8 @@ func (g Graph) PostGroupMember(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
g.publishEvent(events.GroupMemberAdded{GroupID: groupID, UserID: id})
|
||||
currentUser := ctxpkg.ContextMustGetUser(r.Context())
|
||||
g.publishEvent(events.GroupMemberAdded{Executant: currentUser.Id, GroupID: groupID, UserID: id})
|
||||
render.Status(r, http.StatusNoContent)
|
||||
render.NoContent(w, r)
|
||||
}
|
||||
@@ -330,7 +334,8 @@ func (g Graph) DeleteGroupMember(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
return
|
||||
}
|
||||
g.publishEvent(events.GroupMemberRemoved{GroupID: groupID, UserID: memberID})
|
||||
currentUser := ctxpkg.ContextMustGetUser(r.Context())
|
||||
g.publishEvent(events.GroupMemberRemoved{Executant: currentUser.Id, GroupID: groupID, UserID: memberID})
|
||||
render.Status(r, http.StatusNoContent)
|
||||
render.NoContent(w, r)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/CiscoM31/godata"
|
||||
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
|
||||
cs3rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
|
||||
ctxpkg "github.com/cs3org/reva/v2/pkg/ctx"
|
||||
revactx "github.com/cs3org/reva/v2/pkg/ctx"
|
||||
"github.com/cs3org/reva/v2/pkg/events"
|
||||
"github.com/go-chi/render"
|
||||
@@ -84,11 +85,13 @@ func (g Graph) ChangeOwnPassword(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
currentUser := ctxpkg.ContextMustGetUser(r.Context())
|
||||
g.publishEvent(
|
||||
events.UserFeatureChanged{
|
||||
UserID: u.Id.OpaqueId,
|
||||
Executant: currentUser.Id,
|
||||
UserID: u.Id.OpaqueId,
|
||||
Features: []events.UserFeature{
|
||||
events.UserFeature{Name: "password", Value: "***"},
|
||||
{Name: "password", Value: "***"},
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/CiscoM31/godata"
|
||||
ctxpkg "github.com/cs3org/reva/v2/pkg/ctx"
|
||||
revactx "github.com/cs3org/reva/v2/pkg/ctx"
|
||||
"github.com/cs3org/reva/v2/pkg/events"
|
||||
"github.com/go-chi/chi/v5"
|
||||
@@ -140,7 +141,8 @@ func (g Graph) PostUser(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
g.publishEvent(events.UserCreated{UserID: *u.Id})
|
||||
currentUser := ctxpkg.ContextMustGetUser(r.Context())
|
||||
g.publishEvent(events.UserCreated{Executant: currentUser.Id, UserID: *u.Id})
|
||||
|
||||
render.Status(r, http.StatusOK)
|
||||
render.JSON(w, r, u)
|
||||
@@ -197,7 +199,8 @@ func (g Graph) DeleteUser(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
g.publishEvent(events.UserDeleted{UserID: userID})
|
||||
currentUser := ctxpkg.ContextMustGetUser(r.Context())
|
||||
g.publishEvent(events.UserDeleted{Executant: currentUser.Id, UserID: userID})
|
||||
|
||||
render.Status(r, http.StatusNoContent)
|
||||
render.NoContent(w, r)
|
||||
@@ -247,10 +250,12 @@ func (g Graph) PatchUser(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
currentUser := ctxpkg.ContextMustGetUser(r.Context())
|
||||
g.publishEvent(
|
||||
events.UserFeatureChanged{
|
||||
UserID: nameOrID,
|
||||
Features: features,
|
||||
Executant: currentUser.Id,
|
||||
UserID: nameOrID,
|
||||
Features: features,
|
||||
},
|
||||
)
|
||||
render.Status(r, http.StatusOK)
|
||||
|
||||
Reference in New Issue
Block a user