Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v12] Define distinct types for all device events #25320

Merged
merged 1 commit into from Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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