Skip to content

Commit

Permalink
Add initial future assume role to access requests
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwardDowling committed Jan 8, 2024
1 parent c4ca7dd commit 5fbe031
Show file tree
Hide file tree
Showing 16 changed files with 3,896 additions and 3,481 deletions.
11 changes: 6 additions & 5 deletions api/client/client.go
Expand Up @@ -1095,11 +1095,12 @@ func (c *Client) GetAccessRequestAllowedPromotions(ctx context.Context, req type
// SetAccessRequestState updates the state of an existing access request.
func (c *Client) SetAccessRequestState(ctx context.Context, params types.AccessRequestUpdate) error {
setter := proto.RequestStateSetter{
ID: params.RequestID,
State: params.State,
Reason: params.Reason,
Annotations: params.Annotations,
Roles: params.Roles,
ID: params.RequestID,
State: params.State,
Reason: params.Reason,
Annotations: params.Annotations,
Roles: params.Roles,
AssumeStartTime: params.AssumeStartTime,
}
if d := utils.GetDelegator(ctx); d != "" {
setter.Delegator = d
Expand Down
1,784 changes: 923 additions & 861 deletions api/client/proto/authservice.pb.go

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions api/constants/constants.go
Expand Up @@ -402,6 +402,12 @@ const (
TimeoutGetClusterAlerts = time.Millisecond * 750
)

const (
// MaxAssumeStartDuration latest duration into the future an access request's assume
// start time can be
MaxAssumeStartDuration = time.Hour * 24 * 7
)

const (
// WebAPIConnUpgrade is the HTTP web API to make the connection upgrade
// call.
Expand Down
6 changes: 6 additions & 0 deletions api/proto/teleport/legacy/client/proto/authservice.proto
Expand Up @@ -338,6 +338,12 @@ message RequestStateSetter {
// Roles, if present, overrides the existing set of roles associated
// with the access request.
repeated string Roles = 6 [(gogoproto.jsontag) = "roles,omitempty"];
// AssumeStartTime is the time the requested roles can be assumed.
google.protobuf.Timestamp AssumeStartTime = 7 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = true,
(gogoproto.jsontag) = "assume_start_time,omitempty"
];
}

// RequestID is the unique identifier of an access request.
Expand Down
7 changes: 7 additions & 0 deletions api/proto/teleport/legacy/types/events/events.proto
Expand Up @@ -1379,6 +1379,13 @@ message AccessRequestCreate {
// was promoted to.
// This field is only populated when the request is in the PROMOTED state.
string PromotedAccessListName = 15 [(gogoproto.jsontag) = "promoted_access_list_name,omitempty"];

// AssumeStartTime is the time the requested roles can be assumed.
google.protobuf.Timestamp AssumeStartTime = 16 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = true,
(gogoproto.jsontag) = "assume_start_time,omitempty"
];
}

// ResourceID is a unique identifier for a teleport resource. This is duplicated
Expand Down
14 changes: 14 additions & 0 deletions api/proto/teleport/legacy/types/types.proto
Expand Up @@ -2194,6 +2194,13 @@ message AccessReview {
// AccessList is the access list that this request was promoted to.
// This field is only populated when the request is in the PROMOTED state.
PromotedAccessList accessList = 9 [(gogoproto.jsontag) = "access_list,omitempty"];

// AssumeStartTime is the time the requested roles can be assumed.
google.protobuf.Timestamp AssumeStartTime = 10 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = true,
(gogoproto.jsontag) = "assume_start_time,omitempty"
];
}

// AccessReviewSubmission encodes the necessary parameters for submitting
Expand Down Expand Up @@ -2360,6 +2367,13 @@ message AccessRequestSpecV3 {
// was promoted to. Used by WebUI to display the title of the access list.
// This field is only populated when the request is in the PROMOTED state.
PromotedAccessList accessList = 20 [(gogoproto.jsontag) = "access_list,omitempty"];

// AssumeStartTime is the time the requested roles can be assumed.
google.protobuf.Timestamp AssumeStartTime = 21 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = true,
(gogoproto.jsontag) = "assume_start_time,omitempty"
];
}

// AccessRequestFilter encodes filter params for access requests.
Expand Down
19 changes: 19 additions & 0 deletions api/types/access_request.go
Expand Up @@ -49,6 +49,12 @@ type AccessRequest interface {
// GetAccessExpiry gets the expiration time for the elevated certificate
// that will be issued if the Access Request is approved.
GetAccessExpiry() time.Time
// GetAssumeStartTime gets the time the roles can be assumed
// if the Access Request is approved.
GetAssumeStartTime() *time.Time
// SetAssumeStartTime sets the time the roles can be assumed
// if the Access Request is approved.
SetAssumeStartTime(time.Time)
// SetAccessExpiry sets the expiration time for the elevated certificate
// that will be issued if the Access Request is approved.
SetAccessExpiry(time.Time)
Expand Down Expand Up @@ -198,6 +204,16 @@ func (r *AccessRequestV3) GetAccessExpiry() time.Time {
return r.Spec.Expires
}

// GetAssumeStartTime gets AssumeStartTime
func (r *AccessRequestV3) GetAssumeStartTime() *time.Time {
return r.Spec.AssumeStartTime
}

// SetAssumeStartTime sets AssumeStartTime
func (r *AccessRequestV3) SetAssumeStartTime(t time.Time) {
r.Spec.AssumeStartTime = &t
}

// SetAccessExpiry sets AccessExpiry
func (r *AccessRequestV3) SetAccessExpiry(expiry time.Time) {
r.Spec.Expires = expiry.UTC()
Expand Down Expand Up @@ -606,6 +622,9 @@ type AccessRequestUpdate struct {
// and must be a subset of the role list originally
// present on the request.
Roles []string
// AssumeStartTime sets the time the requestor can assume
// the requested roles.
AssumeStartTime *time.Time
}

// Check validates the request's fields
Expand Down

0 comments on commit 5fbe031

Please sign in to comment.