Skip to content

Commit b89bc32

Browse files
authored
fix(auditlog): keep writing to logs even postgres is disabled (#2076)
move `DisablePostgres` check after payload mutation to ensure auth_event logs have the same data prior to introduce of the `DisablePostgres` config
1 parent 8fa99bd commit b89bc32

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

internal/models/audit_log_entry.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,13 @@ func NewAuditLogEntry(config conf.AuditLogConfiguration, r *http.Request, tx *st
107107
"action": action,
108108
"log_type": ActionLogTypeMap[action],
109109
}
110-
l := AuditLogEntry{
111-
ID: id,
112-
Payload: JSONMap(payload),
113-
IPAddress: ipAddress,
110+
111+
if name, ok := actor.UserMetaData["full_name"]; ok {
112+
payload["actor_name"] = name
113+
}
114+
115+
if traits != nil {
116+
payload["traits"] = traits
114117
}
115118

116119
observability.LogEntrySetFields(r, logrus.Fields{
@@ -121,12 +124,10 @@ func NewAuditLogEntry(config conf.AuditLogConfiguration, r *http.Request, tx *st
121124
return nil
122125
}
123126

124-
if name, ok := actor.UserMetaData["full_name"]; ok {
125-
l.Payload["actor_name"] = name
126-
}
127-
128-
if traits != nil {
129-
l.Payload["traits"] = traits
127+
l := AuditLogEntry{
128+
ID: id,
129+
Payload: JSONMap(payload),
130+
IPAddress: ipAddress,
130131
}
131132

132133
if err := tx.Create(&l); err != nil {

0 commit comments

Comments
 (0)