mirror of
https://github.com/paralus/paralus.git
synced 2026-08-24 15:47:19 +00:00
Merge pull request #59 from vivekhiwarkar/add_audit_points
Adding audit points
This commit is contained in:
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
## Unreleased
|
||||
|
||||
## Added
|
||||
|
||||
- Adding more audit points for better visibility from [vivekhiwarkar](https://github.com/vivekhiwarkar)
|
||||
|
||||
## [0.1.2] - 2022-08-12
|
||||
|
||||
## Fixed
|
||||
|
||||
@@ -16,9 +16,10 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
AuditActionCreate = "create"
|
||||
AuditActionDelete = "delete"
|
||||
AuditActionUpdate = "update"
|
||||
AuditActionCreate = "create"
|
||||
AuditActionDelete = "delete"
|
||||
AuditActionUpdate = "update"
|
||||
AuditActionDownload = "download"
|
||||
)
|
||||
|
||||
func CreateUserAuditEvent(ctx context.Context, al *zap.Logger, db bun.IDB, action string, name string, id uuid.UUID, rolesBefore, rolesAfter, groupsBefore, groupsAfter []uuid.UUID) {
|
||||
@@ -389,6 +390,24 @@ func CreateApiKeyAuditEvent(ctx context.Context, al *zap.Logger, action string,
|
||||
}
|
||||
}
|
||||
|
||||
func DownloadCliConfigAuditEvent(ctx context.Context, al *zap.Logger, action string, user string) {
|
||||
sd, ok := GetSessionDataFromContext(ctx)
|
||||
if !ok {
|
||||
_log.Warn("unable to create audit event: could not fetch info from context")
|
||||
return
|
||||
}
|
||||
|
||||
detail := &audit.EventDetail{
|
||||
Message: fmt.Sprintf("CLI config %sed for %s", action, user),
|
||||
Meta: map[string]string{
|
||||
"username": user,
|
||||
},
|
||||
}
|
||||
if err := audit.CreateV1Event(al, sd, detail, fmt.Sprintf("cliconfig.%s.success", action), ""); err != nil {
|
||||
_log.Warn("unable to create audit event", err)
|
||||
}
|
||||
}
|
||||
|
||||
func RevokeKubeconfigAuditEvent(ctx context.Context, al *zap.Logger, user string) {
|
||||
sd, ok := GetSessionDataFromContext(ctx)
|
||||
if !ok {
|
||||
|
||||
@@ -941,6 +941,7 @@ func (s *userService) RetrieveCliConfig(ctx context.Context, req *userrpcv3.ApiK
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
CreateApiKeyAuditEvent(ctx, s.al, AuditActionCreate, req.Username)
|
||||
}
|
||||
|
||||
cliConfig := &common.CliConfigDownloadData{
|
||||
@@ -954,6 +955,7 @@ func (s *userService) RetrieveCliConfig(ctx context.Context, req *userrpcv3.ApiK
|
||||
Partner: part.Name,
|
||||
}
|
||||
|
||||
DownloadCliConfigAuditEvent(ctx, s.al, AuditActionDownload, req.Username)
|
||||
return cliConfig, nil
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user