-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaudit.go
More file actions
70 lines (60 loc) · 2.58 KB
/
Copy pathaudit.go
File metadata and controls
70 lines (60 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package audit
import (
"context"
"time"
)
// Action represents the type of state-changing operation that occurred.
type Action string
const (
ActionWorkflowApplied Action = "workflow.applied"
ActionWorkflowExecuted Action = "workflow.executed"
ActionStepStarted Action = "step.started"
ActionStepCompleted Action = "step.completed"
ActionStepFailed Action = "step.failed"
ActionStepSkipped Action = "step.skipped"
ActionStepContinuedOnError Action = "step.continued_on_error"
ActionExecutionCancelled Action = "execution.cancelled"
ActionArtifactPersisted Action = "artifact.persisted"
// Admin operations.
ActionUserCreated Action = "user.created"
ActionUserDeleted Action = "user.deleted"
ActionUserRoleChanged Action = "user.role_changed"
ActionTeamCreated Action = "team.created"
ActionTeamDeleted Action = "team.deleted"
ActionAPIKeyCreated Action = "apikey.created"
ActionAPIKeyRevoked Action = "apikey.revoked"
ActionCredentialCreated Action = "credential.created"
ActionCredentialDeleted Action = "credential.deleted"
ActionCredentialRotated Action = "credential.rotated"
ActionAuthFailed Action = "auth.failed"
// Email trigger operations.
ActionEmailTriggerFired Action = "email.trigger.fired"
ActionEmailConnectionEstablished Action = "email.connection.established"
ActionEmailConnectionFailed Action = "email.connection.failed"
// Budget operations.
ActionBudgetExceeded Action = "budget.exceeded"
ActionBudgetWarning Action = "budget.warning"
ActionBudgetUpdated Action = "budget.updated"
)
// Resource identifies the target of an audit event.
type Resource struct {
Type string // e.g., "workflow_definition", "workflow_execution", "step_execution"
ID string
}
// Event represents a single audit event emitted by a state-changing operation.
type Event struct {
ID string
Timestamp time.Time
Actor string // who performed the action (e.g., "cli", "scheduler", user ID)
Action Action // what happened
Resource Resource // what was affected
Before any // optional: state before the change
After any // optional: state after the change
Metadata map[string]string // optional: additional context
TeamID string // optional: team scope for multi-tenant audit queries
}
// Emitter is the interface for emitting audit events. Implementations may
// discard events (no-op), log them, or persist them to a database.
type Emitter interface {
Emit(ctx context.Context, event Event) error
}