mirror of
https://github.com/gravitational/teleport.git
synced 2026-09-24 16:17:11 +08:00
Add Copy to AccessRequest. (#23638)
* Add Copy to AccessRequest. A Copy function has been added to the AccessRequest. This will assist in monitoring of access requests for the Okta app access integration feature. * Ensure all access request timestamps are UTC. * AccessReviews are also set to UTC.
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/gravitational/trace"
|
||||
|
||||
"github.com/gravitational/teleport/api/utils"
|
||||
@@ -103,6 +104,8 @@ type AccessRequest interface {
|
||||
GetDryRun() bool
|
||||
// SetDryRun sets the dry run flag on the request.
|
||||
SetDryRun(bool)
|
||||
// Copy returns a copy of the access request resource.
|
||||
Copy() AccessRequest
|
||||
}
|
||||
|
||||
// NewAccessRequest assembles an AccessRequest resource.
|
||||
@@ -168,7 +171,7 @@ func (r *AccessRequestV3) GetCreationTime() time.Time {
|
||||
|
||||
// SetCreationTime sets CreationTime
|
||||
func (r *AccessRequestV3) SetCreationTime(t time.Time) {
|
||||
r.Spec.Created = t
|
||||
r.Spec.Created = t.UTC()
|
||||
}
|
||||
|
||||
// GetAccessExpiry gets AccessExpiry
|
||||
@@ -178,7 +181,7 @@ func (r *AccessRequestV3) GetAccessExpiry() time.Time {
|
||||
|
||||
// SetAccessExpiry sets AccessExpiry
|
||||
func (r *AccessRequestV3) SetAccessExpiry(expiry time.Time) {
|
||||
r.Spec.Expires = expiry
|
||||
r.Spec.Expires = expiry.UTC()
|
||||
}
|
||||
|
||||
// GetRequestReason gets RequestReason
|
||||
@@ -261,7 +264,12 @@ func (r *AccessRequestV3) SetRoleThresholdMapping(rtm map[string]ThresholdIndexS
|
||||
|
||||
// SetReviews sets the list of currently applied access reviews.
|
||||
func (r *AccessRequestV3) SetReviews(revs []AccessReview) {
|
||||
r.Spec.Reviews = revs
|
||||
utcRevs := make([]AccessReview, len(revs))
|
||||
for i, rev := range revs {
|
||||
utcRevs[i] = rev
|
||||
utcRevs[i].Created = rev.Created.UTC()
|
||||
}
|
||||
r.Spec.Reviews = utcRevs
|
||||
}
|
||||
|
||||
// GetReviews gets the list of currently applied access reviews.
|
||||
@@ -363,7 +371,7 @@ func (r *AccessRequestV3) Expiry() time.Time {
|
||||
|
||||
// SetExpiry sets Expiry
|
||||
func (r *AccessRequestV3) SetExpiry(expiry time.Time) {
|
||||
r.Metadata.SetExpiry(expiry)
|
||||
r.Metadata.SetExpiry(expiry.UTC())
|
||||
}
|
||||
|
||||
// GetMetadata gets Metadata
|
||||
@@ -412,6 +420,11 @@ func (r *AccessRequestV3) SetDryRun(dryRun bool) {
|
||||
r.Spec.DryRun = dryRun
|
||||
}
|
||||
|
||||
// Copy returns a copy of the access request resource.
|
||||
func (r *AccessRequestV3) Copy() AccessRequest {
|
||||
return proto.Clone(r).(*AccessRequestV3)
|
||||
}
|
||||
|
||||
// GetLabel retrieves the label with the provided key. If not found
|
||||
// value will be empty and ok will be false.
|
||||
func (r *AccessRequestV3) GetLabel(key string) (value string, ok bool) {
|
||||
|
||||
Reference in New Issue
Block a user