Skip to content

Commit

Permalink
Enable limited Access Requests feature for the Team plan (gravitation…
Browse files Browse the repository at this point in the history
…al#29866)

* Add access request monthly limit to Features

* Add a method to retrieve usage of Access Requests

* Verify access request limit when creating

* Remove AccessRequestsFeature.Enabled

Feature is always enabled now, the flag serves no purpose

* Expose usage of access requests in auth server

* Reimplement access request usage using audit log

* Disallow unauthenticated access to resource usage

* Tidy proto structures

* Start enforcing access request limit in auth

* Run GCI

* Add a license header to usage_test.go

* Add missing godoc

* Restructure usage proto per PR comments

* Construct proto.AccessRequestUsage in getARMU

* Reduce log level when encountering an unexpected event

* Simplify return

* Add godoc to GetResourcesUsage in client

* Fix merge mess-ups

* Count all requests, no matter their review state

* Factor out GetAccessRequestMonthlyUsage

* Move out resource usage to its own service

* Validate the limit after dry run is done

Unbreak UI when the limit is up

* Fix imports

* Remove Limit

SearchEvents will default to defaults.EventsIterationLimit

* Rename the service proto

* Add godocs to the gRPC service

* Move resource usage to a dedicated package

* Define single GetUsage rpc for all resource types

* Additions for limited access requests UI rework

* Add a test for GetAccessRequestMonthlyUsage

* Address lint

* Run GCI

* Add licenses where missing

* Expect CTA_UNSPEICIFED rather than `undefined`

* Expect CTA_UNSPECIFIED instead of undefined
  • Loading branch information
justinas authored Aug 16, 2023
1 parent ce64226 commit 96f3df9
Show file tree
Hide file tree
Showing 19 changed files with 2,182 additions and 1,040 deletions.
10 changes: 10 additions & 0 deletions api/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import (
loginrulepb "github.com/gravitational/teleport/api/gen/proto/go/teleport/loginrule/v1"
oktapb "github.com/gravitational/teleport/api/gen/proto/go/teleport/okta/v1"
pluginspb "github.com/gravitational/teleport/api/gen/proto/go/teleport/plugins/v1"
resourceusagepb "github.com/gravitational/teleport/api/gen/proto/go/teleport/resourceusage/v1"
samlidppb "github.com/gravitational/teleport/api/gen/proto/go/teleport/samlidp/v1"
trustpb "github.com/gravitational/teleport/api/gen/proto/go/teleport/trust/v1"
userloginstatev1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/userloginstate/v1"
Expand Down Expand Up @@ -4139,3 +4140,12 @@ func (c *Client) UpsertUserPreferences(ctx context.Context, in *userpreferencesp
}
return nil
}

// ResourceUsageClient returns an unadorned Resource Usage service client,
// using the underlying Auth gRPC connection.
// Clients connecting to non-Enterprise clusters, or older Teleport versions,
// still get a plugins client when calling this method, but all RPCs will return
// "not implemented" errors (as per the default gRPC behavior).
func (c *Client) ResourceUsageClient() resourceusagepb.ResourceUsageServiceClient {
return resourceusagepb.NewResourceUsageServiceClient(c.conn)
}
2,268 changes: 1,253 additions & 1,015 deletions api/client/proto/authservice.pb.go

Large diffs are not rendered by default.

312 changes: 312 additions & 0 deletions api/gen/proto/go/teleport/resourceusage/v1/resourceusage_service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 96f3df9

Please sign in to comment.