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

[v17] Add initial expiry service #50775

Merged
merged 2 commits into from
Jan 14, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions api/proto/teleport/legacy/types/events/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,33 @@ message AccessRequestCreate {
];
}

// AccessRequestExpire is emitted when access request has expired.
message AccessRequestExpire {
// Metadata is a common event metadata
Metadata Metadata = 1 [
(gogoproto.nullable) = false,
(gogoproto.embed) = true,
(gogoproto.jsontag) = ""
];

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

// RequestID is access request ID
string RequestID = 3 [(gogoproto.jsontag) = "id"];

// ResourceExpiry is the time at which the access request resource will expire.
google.protobuf.Timestamp ResourceExpiry = 4 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = true,
(gogoproto.jsontag) = "expiry,omitempty"
];
}

// ResourceID is a unique identifier for a teleport resource. This is duplicated
// from api/types/types.proto to decouple the api and events types and because
// neither file currently imports the other.
Expand Down Expand Up @@ -4706,6 +4733,7 @@ message OneOf {
events.WorkloadIdentityUpdate WorkloadIdentityUpdate = 195;
events.WorkloadIdentityDelete WorkloadIdentityDelete = 196;
events.UserLoginAccessListInvalid UserLoginAccessListInvalid = 198;
events.AccessRequestExpire AccessRequestExpire = 199;
}
}

Expand Down
7 changes: 7 additions & 0 deletions api/proto/teleport/legacy/types/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2696,6 +2696,13 @@ message AccessRequestSpecV3 {
(gogoproto.nullable) = true,
(gogoproto.jsontag) = "assume_start_time,omitempty"
];

// ResourceExpiry is the time at which the access request resource will expire.
google.protobuf.Timestamp ResourceExpiry = 22 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = true,
(gogoproto.jsontag) = "expiry,omitempty"
];
}

enum AccessRequestScope {
Expand Down
7 changes: 6 additions & 1 deletion api/types/access_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,12 +445,17 @@ func (r *AccessRequestV3) SetName(name string) {

// Expiry gets Expiry
func (r *AccessRequestV3) Expiry() time.Time {
// Fallback on existing expiry in metadata if not set in spec.
if r.Spec.ResourceExpiry != nil {
return *r.Spec.ResourceExpiry
}
return r.Metadata.Expiry()
}

// SetExpiry sets Expiry
func (r *AccessRequestV3) SetExpiry(expiry time.Time) {
r.Metadata.SetExpiry(expiry.UTC())
t := expiry.UTC()
r.Spec.ResourceExpiry = &t
}

// GetMetadata gets Metadata
Expand Down
4 changes: 4 additions & 0 deletions api/types/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,10 @@ func (m *AccessRequestCreate) TrimToMaxSize(maxSize int) AuditEvent {
return out
}

func (m *AccessRequestExpire) TrimToMaxSize(maxSize int) AuditEvent {
return m
}

func (m *AccessRequestResourceSearch) TrimToMaxSize(maxSize int) AuditEvent {
size := m.Size()
if size <= maxSize {
Expand Down
Loading
Loading