Skip to content

Commit

Permalink
[plugins] add plugin audit events boilerplate to CUD operations (#45161)
Browse files Browse the repository at this point in the history
* [plugins] add plugin audit events boilerplate to CUD operations

This PR adds the required boilerplate code to emit audit events for `create`, `update` and `delete` operations.

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>

* handle comments

---------

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
  • Loading branch information
tigrato committed Sep 21, 2024
1 parent 15fcdf4 commit 1cdfa2e
Show file tree
Hide file tree
Showing 7 changed files with 3,345 additions and 1,520 deletions.
130 changes: 130 additions & 0 deletions api/proto/teleport/legacy/types/events/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4204,6 +4204,133 @@ message AzureOIDCIntegrationMetadata {
string ClientID = 2 [(gogoproto.jsontag) = "client_id,omitempty"];
}

// PluginCreate is emitted when a plugin resource is created.
message PluginCreate {
// Metadata is a common event metadata.
Metadata metadata = 1 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// User is a common user event metadata.
UserMetadata user = 2 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// ResourceMetadata is a common resource event metadata.
ResourceMetadata resource = 3 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

PluginMetadata plugin = 4 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// ConnectionMetadata holds information about the connection.
ConnectionMetadata connection = 5 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];
}

// PluginUpdate is emitted when a plugin resource is updated.
message PluginUpdate {
// Metadata is a common event metadata.
Metadata metadata = 1 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// User is a common user event metadata.
UserMetadata user = 2 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// ResourceMetadata is a common resource event metadata.
ResourceMetadata resource = 3 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

PluginMetadata plugin = 4 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// ConnectionMetadata holds information about the connection.
ConnectionMetadata connection = 5 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];
}

// PluginDelete is emitted when a plugin is deleted.
message PluginDelete {
// metadata is a common event metadata.
Metadata metadata = 1 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// User is a common user event metadata.
UserMetadata user = 2 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// ResourceMetadata is a common resource event metadata.
ResourceMetadata resource = 3 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

PluginMetadata plugin = 4 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

// ConnectionMetadata holds information about the connection.
ConnectionMetadata connection = 5 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];
}

// PluginMetadata contains information about plugin resources.
message PluginMetadata {
// plugin_type is the plugin type of the plugin resource.
// The value matches the types.PluginV1.Spec.Type field.
string plugin_type = 1 [(gogoproto.jsontag) = "plugin_type"];

// plugin is the resource without secrets.
types.PluginV1 plugin = 2 [(gogoproto.jsontag) = "plugin,omitempty"];

// has_credentials indicates whether the plugin has credentials.
bool has_credentials = 3 [(gogoproto.jsontag) = "has_credentials"];

// reuses_credentials indicates whether the plugin reuses credentials.
bool reuses_credentials = 4 [(gogoproto.jsontag) = "reuses_credentials"];
}

// OneOf is a union of one of audit events submitted to the auth service
message OneOf {
// Event is one of the audit events
Expand Down Expand Up @@ -4374,6 +4501,9 @@ message OneOf {
events.IntegrationDelete IntegrationDelete = 167;
events.SPIFFEFederationCreate SPIFFEFederationCreate = 168;
events.SPIFFEFederationDelete SPIFFEFederationDelete = 169;
events.PluginCreate PluginCreate = 170;
events.PluginUpdate PluginUpdate = 171;
events.PluginDelete PluginDelete = 172;
events.AutoUpdateConfigCreate AutoUpdateConfigCreate = 173;
events.AutoUpdateConfigUpdate AutoUpdateConfigUpdate = 174;
events.AutoUpdateConfigDelete AutoUpdateConfigDelete = 175;
Expand Down
Loading

0 comments on commit 1cdfa2e

Please sign in to comment.