[MM-64686] Expose audit logging functionality via plugin API (#31204)
This commit exposes audit logging functionality to plugins via the plugin API, allowing plugins to create and log audit records. Additionally, it addresses a gob encoding issue that could cause plugin crashes when audit data contains nil pointers or unregistered types.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
efb960a160
Коммит
aaa62a40ae
@@ -17,7 +17,6 @@ import (
|
||||
"github.com/mattermost/mattermost/server/public/shared/i18n"
|
||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/app"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/audit"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/utils"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/utils/fileutils"
|
||||
)
|
||||
@@ -65,7 +64,7 @@ func authorizeOAuthApp(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
auditRec := c.MakeAuditRecord("authorizeOAuthApp", audit.Fail)
|
||||
auditRec := c.MakeAuditRecord("authorizeOAuthApp", model.AuditStatusFail)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
c.LogAudit("attempt")
|
||||
|
||||
@@ -93,7 +92,7 @@ func deauthorizeOAuthApp(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
auditRec := c.MakeAuditRecord("deauthorizeOAuthApp", audit.Fail)
|
||||
auditRec := c.MakeAuditRecord("deauthorizeOAuthApp", model.AuditStatusFail)
|
||||
auditRec.AddMeta("client_id", clientId)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
|
||||
@@ -135,7 +134,7 @@ func authorizeOAuthPage(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
auditRec := c.MakeAuditRecord("authorizeOAuthPage", audit.Fail)
|
||||
auditRec := c.MakeAuditRecord("authorizeOAuthPage", model.AuditStatusFail)
|
||||
auditRec.AddMeta("client_id", authRequest.ClientId)
|
||||
auditRec.AddMeta("scope", authRequest.Scope)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
@@ -243,7 +242,7 @@ func getAccessToken(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
redirectURI := r.FormValue("redirect_uri")
|
||||
|
||||
auditRec := c.MakeAuditRecord("getAccessToken", audit.Fail)
|
||||
auditRec := c.MakeAuditRecord("getAccessToken", model.AuditStatusFail)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
auditRec.AddMeta("grant_type", grantType)
|
||||
auditRec.AddMeta("client_id", clientId)
|
||||
@@ -275,9 +274,9 @@ func completeOAuth(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
service := c.Params.Service
|
||||
|
||||
auditRec := c.MakeAuditRecord("completeOAuth", audit.Fail)
|
||||
auditRec := c.MakeAuditRecord("completeOAuth", model.AuditStatusFail)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
audit.AddEventParameter(auditRec, "service", service)
|
||||
model.AddEventParameterToAuditRec(auditRec, "service", service)
|
||||
|
||||
oauthError := r.URL.Query().Get("error")
|
||||
if oauthError == "access_denied" {
|
||||
@@ -440,7 +439,7 @@ func loginWithOAuth(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
auditRec := c.MakeAuditRecord("loginWithOAuth", audit.Fail)
|
||||
auditRec := c.MakeAuditRecord("loginWithOAuth", model.AuditStatusFail)
|
||||
auditRec.AddMeta("service", c.Params.Service)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
|
||||
@@ -476,7 +475,7 @@ func mobileLoginWithOAuth(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
auditRec := c.MakeAuditRecord("mobileLoginWithOAuth", audit.Fail)
|
||||
auditRec := c.MakeAuditRecord("mobileLoginWithOAuth", model.AuditStatusFail)
|
||||
auditRec.AddMeta("service", c.Params.Service)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
|
||||
@@ -511,7 +510,7 @@ func signupWithOAuth(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
auditRec := c.MakeAuditRecord("signupWithOAuth", audit.Fail)
|
||||
auditRec := c.MakeAuditRecord("signupWithOAuth", model.AuditStatusFail)
|
||||
auditRec.AddMeta("service", c.Params.Service)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user