Skip to content

Commit

Permalink
Define distinct types for all device events (#25320)
Browse files Browse the repository at this point in the history
  • Loading branch information
codingllama committed Apr 28, 2023
1 parent c56954b commit 50f539e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
23 changes: 23 additions & 0 deletions lib/events/api.go
Expand Up @@ -586,7 +586,30 @@ const (
SSMRunEvent = "ssm.run"

// DeviceEvent is the catch-all event for Device Trust events.
// Deprecated: Use one of the more specific event codes below.
DeviceEvent = "device"
// DeviceCreateEvent is emitted on device registration.
// This is an inventory management event.
DeviceCreateEvent = "device.create"
// DeviceDeleteEvent is emitted on device deletion.
// This is an inventory management event.
DeviceDeleteEvent = "device.delete"
// DeviceUpdateEvent is emitted on device updates.
// This is an inventory management event.
DeviceUpdateEvent = "device.update"
// DeviceEnrollEvent is emitted when a device is enrolled.
// Enrollment events are issued due to end-user action, using the trusted
// device itself.
DeviceEnrollEvent = "device.enroll"
// DeviceAuthenticateEvent is emitted when a device is authenticated.
// Authentication events are issued due to end-user action, using the trusted
// device itself.
DeviceAuthenticateEvent = "device.authenticate"
// DeviceEnrollTokenCreateEvent is emitted when a new enrollment token is
// issued for a device.
// Device enroll tokens are issued by either a device admin or during
// client-side auto-enrollment.
DeviceEnrollTokenCreateEvent = "device.token.create"

// BotJoinEvent is emitted when a bot joins
BotJoinEvent = "bot.join"
Expand Down
5 changes: 4 additions & 1 deletion lib/events/dynamic.go
Expand Up @@ -223,7 +223,10 @@ func FromEventFields(fields EventFields) (events.AuditEvent, error) {
e = &events.MFADeviceAdd{}
case MFADeviceDeleteEvent:
e = &events.MFADeviceDelete{}
case DeviceEvent:
case DeviceEvent, // Keep DeviceEvent here for backwards compatibility.
DeviceCreateEvent, DeviceDeleteEvent, DeviceUpdateEvent,
DeviceEnrollEvent, DeviceAuthenticateCode,
DeviceEnrollTokenCreateEvent:
e = &events.DeviceEvent{}
case LockCreatedEvent:
e = &events.LockCreate{}
Expand Down

0 comments on commit 50f539e

Please sign in to comment.