[MM-56339] Audit logs: on login add UserId and SessionId to audit's Actor field (#27446)

* on login add UserId and SessionId to audit's Actor field to match logout

* lint

* simplify to add only userId and sessionId

* AddToEventActor -> AddUser/SessionToEventActor

* fill in missing session data when logging the audit record

* why did it bump that? reverting.

* make modules-tidy

* trigger build

* add more context to the comment
Этот коммит содержится в:
Christopher Poile
2024-07-08 18:56:54 -04:00
коммит произвёл GitHub
родитель 9f312f48b5
Коммит 9b2f20210b
7 изменённых файлов: 110 добавлений и 18 удалений

Просмотреть файл

@@ -29,6 +29,15 @@ type Context struct {
// LogAuditRec logs an audit record using default LevelAPI.
func (c *Context) LogAuditRec(rec *audit.Record) {
// finish populating the context data, in case the session wasn't available during MakeAuditRecord
// (e.g., api4/user.go login)
if rec.Actor.UserId == "" {
rec.Actor.UserId = c.AppContext.Session().UserId
}
if rec.Actor.SessionId == "" {
rec.Actor.SessionId = c.AppContext.Session().Id
}
c.LogAuditRecWithLevel(rec, app.LevelAPI)
}