Skip to content

Commit

Permalink
Add initial expiry service (#49267)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwardDowling committed Jan 6, 2025
1 parent 7131032 commit e089631
Show file tree
Hide file tree
Showing 16 changed files with 4,337 additions and 3,445 deletions.
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 @@ -4700,6 +4727,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 @@ -2692,6 +2692,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

0 comments on commit e089631

Please sign in to comment.