Skip to content

Commit 545946b

Browse files
committed
add extra fields for filtering
1 parent b07ae66 commit 545946b

1 file changed

Lines changed: 36 additions & 11 deletions

File tree

pkg/auditserver/server.go

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,56 @@ import (
88
"github.com/spf13/viper"
99
"log/slog"
1010
"os"
11+
"time"
1112
)
1213

1314
type Request struct {
14-
MountClass string `json:"mount_class"`
15+
ID string `json:"id"`
16+
ClientID string `json:"client_id"`
17+
Operation string `json:"operation"`
1518
MountPoint string `json:"mount_point"`
16-
MountRunningVersion string `json:"mount_running_version"`
1719
MountType string `json:"mount_type"`
18-
Operation string `json:"operation"`
20+
MountAccessor string `json:"mount_accessor"`
21+
MountRunningVersion string `json:"mount_running_version"`
22+
MountClass string `json:"mount_class"`
23+
ClientToken string `json:"client_token"`
24+
ClientTokenAccessor string `json:"client_token_accessor"`
1925
Path string `json:"path"`
26+
RemoteAddress string `json:"remote_address"`
27+
RemotePort int `json:"remote_port"`
2028
}
2129

2230
type Response struct {
23-
MountAccessor string `json:"mount_accessor"`
24-
MountClass string `json:"mount_class"`
2531
MountPoint string `json:"mount_point"`
26-
MountRunningPluginVersion string `json:"mount_running_plugin_version"`
2732
MountType string `json:"mount_type"`
33+
MountAccessor string `json:"mount_accessor"`
34+
MountRunningPluginVersion string `json:"mount_running_plugin_version"`
35+
MountClass string `json:"mount_class"`
36+
Data struct {
37+
CreatedTime string `json:"created_time"`
38+
CustomMetadata map[string]string `json:"custom_metadata"`
39+
DeletionTime string `json:"deletion_time"`
40+
Destroyed bool `json:"destroyed"`
41+
Version int `json:"version"`
42+
} `json:"data"`
2843
}
2944

3045
type Auth struct {
31-
Accessor string `json:"accessor"`
32-
ClientToken string `json:"client_token"`
33-
DisplayName string `json:"display_name"`
46+
ClientToken string `json:"client_token"`
47+
Accessor string `json:"accessor"`
48+
DisplayName string `json:"display_name"`
49+
Policies []string `json:"policies"`
50+
TokenPolicies []string `json:"token_policies"`
3451
PolicyResults struct {
35-
Allowed bool `json:"allowed"`
52+
Allowed bool `json:"allowed"`
53+
GrantingPolicies []struct {
54+
Name string `json:"name"`
55+
NamespaceID string `json:"namespace_id"`
56+
Type string `json:"type"`
57+
} `json:"granting_policies"`
3658
} `json:"policy_results"`
59+
TokenType string `json:"token_type"`
60+
TokenIssueTime time.Time `json:"token_issue_time"`
3761
}
3862

3963
type AuditLog struct {
@@ -71,14 +95,15 @@ func (as *AuditServer) React(frame []byte, c gnet.Conn) (out []byte, action gnet
7195
"operation", auditLog.Request.Operation,
7296
"path", auditLog.Request.Path,
7397
"user", auditLog.Auth.DisplayName,
98+
"client_id", auditLog.Request.ClientID,
99+
"remote_addr", auditLog.Request.RemoteAddress,
74100
"time", auditLog.Time,
75101
}
76102
as.logger.Info("Received audit log", logAttrs...)
77103
}
78104

79105
return nil, gnet.Close
80106
}
81-
82107
func (as *AuditServer) shouldLog(auditLog *AuditLog) bool {
83108
// If no rules are defined, log all audit logs
84109
if len(as.compiledExpr) == 0 {

0 commit comments

Comments
 (0)