MM-22785 audit server CLI (#14144)
Add auditing to server CLI. Also: - simplify auditing in API layer - reduce number of AddMeta calls - have models serialize themselves - more consistent field naming
Этот коммит содержится в:
@@ -29,7 +29,7 @@ func (c *Context) LogAuditRec(rec *audit.Record) {
|
||||
c.LogAuditRecWithLevel(rec, app.RestLevel)
|
||||
}
|
||||
|
||||
// LogAuditRec logs an audit record using specificed Level.
|
||||
// LogAuditRec logs an audit record using specified Level.
|
||||
func (c *Context) LogAuditRecWithLevel(rec *audit.Record, level audit.Level) {
|
||||
if rec == nil {
|
||||
return
|
||||
@@ -42,15 +42,12 @@ func (c *Context) LogAuditRecWithLevel(rec *audit.Record, level audit.Level) {
|
||||
}
|
||||
rec.Fail()
|
||||
}
|
||||
if cid := c.App.GetClusterId(); cid != "" {
|
||||
rec.AddMeta(audit.KeyClusterID, cid)
|
||||
}
|
||||
c.App.Srv().Audit.LogRecord(level, *rec)
|
||||
}
|
||||
|
||||
// MakeAuditRecord creates a audit record pre-populated with data from this context.
|
||||
func (c *Context) MakeAuditRecord(event string, initialStatus string) *audit.Record {
|
||||
return &audit.Record{
|
||||
rec := &audit.Record{
|
||||
APIPath: c.App.Path(),
|
||||
Event: event,
|
||||
Status: initialStatus,
|
||||
@@ -58,8 +55,11 @@ func (c *Context) MakeAuditRecord(event string, initialStatus string) *audit.Rec
|
||||
SessionID: c.App.Session().Id,
|
||||
Client: c.App.UserAgent(),
|
||||
IPAddress: c.App.IpAddress(),
|
||||
Meta: audit.Meta{},
|
||||
Meta: audit.Meta{audit.KeyClusterID: c.App.GetClusterId()},
|
||||
}
|
||||
rec.AddMetaTypeConverter(model.AuditModelTypeConv)
|
||||
|
||||
return rec
|
||||
}
|
||||
|
||||
func (c *Context) LogAudit(extraInfo string) {
|
||||
|
||||
Ссылка в новой задаче
Block a user