Commit Graph
557 Commits
Author SHA1 Message Date
Andrew LeFevre 3064f7e44d Add agentless connection integration test (#23120)
* add agentless connection integration test

* address feedback
2023-03-16 15:20:31 +00:00
rosstimothy b0dc78610e Migrate upserting CAs to gRPC (#23140)
Adds `UpsertCertAuthority` to the `teleport.v1.trust.TrustService`
and deprecates the HTTP api. The `services.Trust` interface was
also updated to include a `context.Context` in both
`CreateCertAuthority` and `UpsertCertAuthority.

To ensure backwards compatibility the `auth.Client` will first
attempt to use the gRPC client and if that fails with a not
implemented error it will fallback to using HTTP.

Part of #6394
2023-03-16 14:46:43 +00:00
rosstimothy f02468e9fb Migrate the delete ca api to gRPC (#23070)
Adds `DeleteCertAuthority` to the trust grpc service and deprecates
the legacy HTTP api. Additionally the `DeleteCertAuthority` method
in the `services.Trust` interface now takes a `context.Context` as
the first parameter. In order to plumb the context through from all
the call sites `DeleteRemoteCluster` from `services.Presence` was
also modified to take a `context.Context` as the first parameter.
2023-03-15 13:11:37 +00:00
Brian Joerger 5a3a374203 Decouple SkipLocalAuth, UseKeyPrincipal, and static auth methods. (#21182)
* Fix TestDiagnoseSSHConnection to be less strict on the exact unknown user error message, which may vary between OS's.

* Decouple/refactor SkipLocalAuth, UseKeyPrincipal, and static auth methods.

* Resolve comments.

* * Add tests for new methods

* Update proxy ssh principal test to catch regression

* Bump predicate error in switch case priority
2023-03-14 23:22:08 +00:00
STeve (Xin) Huang 3a0ab15f4a Support App access behind load balancer (#22565)
* Support App access behind load balancer

* revert unecessary change

* fix lint

* Fix UT

* minor refactor
2023-03-14 13:47:41 +00:00
Jeff Pihach 1513294b7b Add CreatedBy and CreatedOn fields to locks. (#22667)
* Add CreatedBy and CreatedOn fields to locks.

* Move the setting of the CreatedBy and CreatedOn for locks to the server instead of the client.

* Add tests for the tctl resource lock import and for the tctl lock create command.

* Use clockwork for time in lock creation tests.

* Make fake clock optional and use the golang 0 date.

* Change CreatedOn to CreatedAt.

* Allow a custom time to be passed through as a fake clock.

* Actually accept a fake clock with useFakeClock.

* Pass Clock through as a configuration value when initializing Teleport for the tests.

* Test cleanup

* Set CreatedBy and CreatedAt values in test mocks.

* Fix failing test from enabling clock passthrough to auth.
2023-03-13 16:14:24 +00:00
Tiago Silva 674a3a1ec1 Removes deprecated KindKubeService objects (#22663)
This PR removes the `types.KindKubeService` objects that were
deprecated in Teleport 11.

Teleport 12 removed the double heartbeat and for Teleport 13 we can
safely drop the support of the old hearbeat based on `types.Server`
objects.

Clients older than Teleport 12 connecting to a Teleport 13 server will
fail since they cannot heartbeat using the old mechanism.
2023-03-13 10:55:39 +00:00
Lisa Kim 98230bb2b3 Add per-session mfa support to connection testers (#22528)
* Add MFAAuthenticateResponse field to GenerateUserCerts

* Pass MFA response for connection testers

* Add checking MFA web endpoint

* Address CRs
2023-03-09 20:27:30 +00:00
Zac Bergquist 2ae9d770fc Refactor tctl's dependencies (#22693)
* Move configuration from lib/service to lib/service/servicecfg

The new servicecfg package will hold only configuration for services.
This will allow other packages (like tctl and tsh) to depend on
servicecfg without pulling in all of lib/service (which has a number
of platform-specific details).

This is the first step towards being able to build tctl for Windows.

* Move PAM and BPF config into servicecfg

This breaks a compile-time dependency on BPF/PAM for tctl.
2023-03-09 17:48:36 +00:00
Michael Wilson 49c64aabcb Move the authorizer into its own package. (#22776)
* Move the authorizer into its own package.

The Authorizer and associated functions and constants have been moved into
their own package `authz`. This will allow us to more easily create separate
services for gRPC functionality so that we're not pushing as much into the
`lib/auth` package.

Though this PR is large, the only actual code change here is making
`ContextForLocalUser` exported and changing the `permissions_test.go` so that
it doesn't rely on the `lib/auth` package.

* Use context functions.

* Test and linting fixes.

* Add in a temporary alias file to ensure e still compiles.

* Use functions instead of var aliases for performance reasons.

* Adding in godocs, cleaning up tests.

* Fix tests.

* Add a few more aliases.
2023-03-09 02:21:10 +00:00
Anton Miniailo 8f3b2b181b Enabled IP pinning enforcement for Kube and DB (#22310) 2023-03-08 14:20:47 +00:00
Tobiasz Heller 0b3a67f69f Remove GetSessionEvents from external loggers (#22071) (#22703)
Remove GetSessionEvents from external loggers
2023-03-07 15:48:00 +00:00
a5370d58fc Allow node to handle old and new way of client IP propagation on the same listener (#22572)
* Allow node to handle old and new way of client IP propagation on same listener

With addition of signed PROXY headers, node was listening on multiplexer, but because
 of that it couldn't processing incoming connection from older proxies
 when ProxyHelloSignature was used, because
 both ends were waiting for the other side to send data first.
 Here we integrate ability to handle PROXY headers into connection itself,
 so we can start ssh server without waiting for multiplexer to detect connection

* Remove unneeded code

* Improve comment's wording

Co-authored-by: Michael Wilson <mike@mdwn.dev>

* Improve comment's wording

Co-authored-by: Michael Wilson <mike@mdwn.dev>

* Fix imports

* Unexport function

* Add godoc

* Remove unneeded comment

* Move ProxyHelloSignature to constants

* Check that proxyline is verified

* Use Warn() instead of Warnf()

* Move ProxyHelloSignature to api/constants

* Add timeout for getting host CA during proxyline verification.

* Rearrange conditions

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

* Clarify comment.

---------

Co-authored-by: Michael Wilson <mike@mdwn.dev>
Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2023-03-07 13:55:02 +00:00
Anton Miniailo 96d10f0d83 Add MaxRetryPeriod for cachePolicy config to use in tests (#22656)
This fixes couple of flaky tests that surfaced after recent changes to the
retry logic/timeouts.
2023-03-06 19:00:17 +00:00
Nic Klaassen 884cbc0a32 temporarily disable TestHSMDualAuthRotation (#22568)
This test has become pretty flaky recently, disabling it for now until I
can find the root cause or fix the test.

Flaky test issue: https://github.com/gravitational/teleport/issues/20217
2023-03-04 04:20:11 +00:00
Forrest aaee695927 node hb and watcher scalability improvements (#21490)
* node hb and watcher scalability improvements

* ensure that node has ample time to hb

* fix degraded state

* hbv2 test cov
2023-03-03 17:39:00 +00:00
Jakub Nyckowski 8329021148 Skip building webassets in CI (#22549)
* Skip building webassets in CI

Building webassets is not always needed and many of our CI build just builds them and ends up not using them after.
This PR skips building the webassets for all pipelines where they are not needed. This should save us some time and $$.

* Make some changes to trigger CI

* Create the missing directory
2023-03-03 15:14:25 +00:00
Anton Miniailo 3633c6181e Add secure client IP propagation throughout teleport (#21080) 2023-02-28 20:38:12 +00:00
Noah StrideandAlan Parra f3ba5750a8 Make tctl nodes add / tctl tokens add use CreateToken RPC (#21189)
* Start removing generateToken

* Refactor `tokens add` to use `CreateToken` RPC

* Correct deprecation version

* Remove calls to GenerateToken

* Start tests for token crud

* Allow user role rules to be provided wth CreateUserAndRole helper

* Add TestCreateToken to tls_test

* Add TestUpsertToken

* Add GetTokens test

* Add TestGetToken

* Add test for DeleteToken RPC

* Dedupe error assertions

* Add support for emitting trusted cluster token creation events to Create/UpsertToken

* Fix imports

* Change parameter order to appease linter

* Fix broken token expiry test

* Fix token expiry time for TestAuth_RegisterUsingToken

* Remove unnecessary cleanup

* Apply suggestions from code review

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* Change test comment from deprecation notice

* `make gprc` after code review changes

* Update lib/auth/tls_test.go

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* Update lib/auth/tls_test.go

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* Update lib/auth/tls_test.go

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* Update lib/auth/tls_test.go

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* Rename tests

* Update lib/auth/tls_test.go

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* More test cases for GetTokens

* Improve message on duplicate token

---------

Co-authored-by: Alan Parra <alan.parra@goteleport.com>
2023-02-16 09:36:55 +00:00
STeve (Xin) Huang fd98549e45 Skip deleting server heartbeats during in-process restart (#21648)
* Skip deleting server heartbeats during in-process restart

* context.TODO() -> context.Background()

* fix lint
2023-02-14 14:10:31 +00:00
Rafał Cieślak 6490755d2b Turn off parallelization of teleterm's integration tests (#21710)
* Add trace.DebugReport to flaky teleterm integration test

* Turn off parallelization of teleterm's integration tests
2023-02-13 16:19:04 +00:00
Gabriel CoradoandRafał Cieślak bc63dddd7b Verify if proxy can handle application requests when creating session (#20418)
* feat(app): ensure there are healthy app services when creating session

* Apply suggestions from code review

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>

* chore: code review updates

* refactor(app): preflight connection before creating session

* chore(web): change error message

* reafactor(app): change redirect to launcher rule

* refactor(app): rename preflight connection to health check app server

* refactor(apiserver): rename preflight connection

* refactor(apiserver): rename preflight connection

* refactor(apiserver): remove health check property

* test(appaccess): adjust new http status codes returned

---------

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>
2023-02-10 10:42:55 +00:00
Grzegorz ZdunekandRafał Cieślak 7ed92c1c18 Connect: return logged in user in ListRootClusters (#20809)
* Add integration/teleterm_test with tests for get* and list* clusters

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>

* Move `testAddingRootCluster to integration/teleterm_test

* Add `ClusterWithDetails` type instead of enriching existing `Cluster` with optional properties

* Remove unnecessary condition

* Add license

* Bunch of renames

* Do more in mustLogin

* Remove watcher

---------

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>
2023-02-08 16:45:53 +00:00
Noah Stride 476a4a7e82 context.TODO() tidying (#21288)
* Use `ctx` rather than `context.TODO()` where available

* Further propagation of context

* Use `context.Background()` instead of `context.TODO()` where appropriate in tests

* Further remove `context.TODO` from tests

* Appease linter on parameter order
2023-02-07 09:01:35 +00:00
Marco André Dinis 97b2a33ff8 Add RBAC labels for Database Services access (#21093)
* Add RBAC labels for Databas Services access

This PR adds a new set of Labels that controls access to the
DatabaseService resource.

We changed the `RoleSet.checkAccess` to allow for checks in Resources
without Labels.
However adding complexity to this function is something that can bit us
in the future.
So, this PR reverts that change and adds a new set of labels.
Those labels will control whether the RoleSet has access to
DatabaseServices.

Given that this is a new condition that we add to the default `editor`
role, we had to create a migration/backfill for the roles that don't
have them.
This allow us to migrate the roles created previously and add this new
allow condition.

* remove preset for remote proxy and database labels

* Remove db_service_labels wildcard from editor preset role

* Fix early exit logic
2023-02-03 17:58:27 +00:00
Rafał Cieślak 3ac5a0aedb Refactor prehog & teleterm protos to match project conventions (#20810)
* Adjust go_package of lib/prehog Go protobufs

This makes them follow the pattern set out by api/proto and proto.

* Adjust go_package of lib/teleterm Go protobufs

* Use single buf.gen.yaml to generate JS protos

This also entailed changing the location of lib/teleterm protos and changing
the value of their package specifier to match the conventions in other parts
of the codebase. This is a breaking change but that is fine for Connect
as the protos are used locally only and each build ships with matching
protobufs.

* Make web/packages/teleterm use protobufs from gen-proto-js

We used to copy protobufs over to web/packages/teleterm/src/services/tshd
since webapps used to be in a separate repo.

This is no longer the case, so we can just make teleterm use protobufs
from gen-proto-js.

* Move prehog & teleterm protos into proto/teleport/lib

* Generate JS protos to gen/proto/js

* Move lib/teleterm Go protobufs to gen/proto/go

* Move lib/prehog Go protobufs to gen/proto/go

* Rename lib/teleterm proto package

* Re-enable linter rules for teleterm & prehog

* Update prehogv1 path in usagereporter_test.go

* Use except instead of ignore_only to allow Google API-style responses

* Add UNARY_RPC to api/proto & proto

* Ignore gen/ when running addlicense

* buf-js.gen.yaml: Remove comment about lack of go_package for JS

* Move prehog protos to proto/prehog/v1alpha

* Adjust prehog's go_package to match proto package
2023-02-03 14:47:06 +00:00
rosstimothy b17f687f5f Track active ssh sessions established via the web (#20231)
* Track active ssh sessions established via the web

Adds open session tracking in `web.Handler` and introduces a new
 `web.Server` to prevent closing the web `http.Server` during
a graceful shutdown if there are still open sessions. From the
`http.Server/Shutdown` docs:

> Shutdown does not attempt to close nor wait for hijacked
> connections such as WebSockets. The caller of Shutdown should
> separately notify such long-lived connections of shutdown and wait
> for them to close, if desired.

Because the web sessions use WebSockets, `Shutdown` will not
wait for them to be idle before terminating. This used to work due
to the fact that web sessions dialed the Proxy SSH Port  to establish the
SSH session. Which meant that all accounting of active user connections
by `sshutils/server.go` was accurate. But now that sessions are
established directly via the `proxy.Router` the web sessions were
unaccounted for.

The `web.Server` now mimics the behavior of `sshutils/server.go` for
Shutdown. Only once all the active web sessions have been terminated
will the underlying http.Server be shutdown.

Fixes #20227
2023-01-27 14:38:39 +00:00
Gavin Frazar 6d9bb25505 update app access reserved headers (#20741)
* Add x-teleport-api-error to reserved headers
* Update app tests for rewritten headers
* Add test case for x-teleport-api-error
* Fix test for XForwardedSsl since it was effectively untested before
* Refactor leaf test to parse the response from dumper app
* Update docs reference reserved headers
2023-01-27 00:01:02 +00:00
Krzysztof Skrzętnicki 1a184bfbe5 Pass parent context to prompt.Confirmation() in identityfile. (#20685) 2023-01-26 11:09:31 +00:00
rosstimothy 362cb46412 Add test that verifies connectivity when Auth is down (#20450)
Ensures that if a user has a valid certificate and Auth is down
that they can still establish a session to nodes.
2023-01-24 21:07:11 +00:00
Rafał Cieślak c4897417fe Add integration test for deamon.Service.AddCluster (#20332)
* Add integration test for daemon.Service.AddCluster

* Call SaveProfile on clusterClient rather than cfg

This way we don't have to explicitly set ClientStore as
client.NewClient(cfg) does that for us.
2023-01-24 08:10:02 +00:00
Rafał Cieślak 3c77541d06 Integ tests: Use address of web UI as Proxy.PublicAddrs (#20328)
i.Web is also used as tconf.Proxy.WebAddr.Addr a couple of lines below.

When pinging the proxy, TeleportClient takes the response and updates a
couple of values based on that response. If proxySettings.SSH.PublicAddr
is not empty, it tries to parse the address and then set it as
tc.WebProxyAddr. [1]

If it cannot parse the port number, it uses the default (3080).

What is getting returned as `proxySettings.SSH.PublicAddr`? That's determined
by setProxyPublicAddressesSettings in lib/service/proxy_settings.go. [2]
It uses the first element from Proxy.PublicAddrs.

Now, the integration test helpers set up the Teleport instance in such
way that the first Proxy.PublicAddrs is set to i.Hostname which resolves
to just "localhost" in tests. So if any test pings the proxy first and then
tries to make another request with the same TeleportClient, the subsequent
request will try to reach out to localhost:3080. This happened to me when
trying to add a new test. [3]

This PR fixes this by making sure that the first element of Proxy.PublicAddrs
actually points at the address of the web UI.

See also the message from Marek about backwards compatibility of
SSHProxyHostPort. [4] [5]

[1] https://github.com/gravitational/teleport/blob/885d7397ab3746154342712bec86bcdb3ea93eab/lib/client/api.go#L3666-L3673
[2] https://github.com/gravitational/teleport/blob/806a568ada7c640a64eb60f718e7d56be34049ad/lib/service/proxy_settings.go#L112
[3] https://github.com/gravitational/teleport/pull/20263
[4] https://gravitational.slack.com/archives/C0DF0TPMY/p1673895327794379?thread_ts=1673891288.249809&cid=C0DF0TPMY
[5] https://github.com/gravitational/teleport/blob/db7fdff8097bcc883af8d9dde6a271d07e418550/api/client/webclient/webclient.go#L490
2023-01-20 12:13:14 +00:00
Edward Dowling 3cd847e3ff Allow updating of trusted cluster role maps (#18168) 2023-01-13 19:06:17 +00:00
Andrew LeFevre e71f024a9f Add OpenSSH CA (#20020)
* WIP adding OpenSSH CA

* fix creating OpenSSH CA for tests

* fix a test name and tctl usage flag

* fix 'tctl status' not displaying openssh CA sometimes

* add OpenSSH CA to TestInit_bootstrap, remove TLS key pair

* add OpenSSH CA to a few more places

* make help text of 'tctl auth rotate' more helpful and accurate

* fix web cert export test

* tbot doesn't need to know about OpenSSH CA

* address feedback

* fix comment formatting
2023-01-13 18:23:19 +00:00
Jakub NyckowskiandHugo Shaka 4e5a776c43 Temporary skip TestReverseTunnelCollapse (#20198)
* Temporary skip TestReverseTunnelCollapse

Co-authored-by: Hugo Shaka <hugo.hervieux@goteleport.com>
2023-01-13 17:04:02 +00:00
Ryan ClarkandZac Bergquist f2fbe92dcb Change the application access authentication flow (#17592)
* Change the application access auth flow to use a CORS POST request

* Remove auth state cookie

* Close the response body in tests

* Change the CSP to allow cross origin requests to the application

* Change the cookies to lax mode

* Update lib/web/app/handler_test.go

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>

* Fix the proxy URL in tests

* Update webassets ref

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
2023-01-12 21:57:01 +00:00
Sam Freiberg bd5853a3b2 Remove default type from cert rotation (#20059)
* Make `all` cert rotations explicit and mark as deprecated
2023-01-12 21:14:02 +00:00
rosstimothy 3aa295c87c Convert usages of types.NewRoleV3 to types.NewRole (#19793)
Closes #14345
2023-01-11 16:58:22 +00:00
Jakub Nyckowski a611535dce Unbundle TestAppInvalidateAppSessionsOnLogout (#20027)
The "tets bundling" introduced in TesAppAccess() made TestAppInvalidateAppSessionsOnLogout test very unstable as other tests are modifying the state of the whole suit.
Removing the test from the bundle seems to fix it.
2023-01-10 15:44:46 +00:00
rosstimothy 54b8fce42b Multiplex Proxy SSH port (#19813) 2023-01-06 11:54:05 -05:00
Brian Joerger 488af75797 Client store generalization (#19420)
- Add a generalized client store made up of a key, profile, and trusted certs store. Each sub store can support different backends (~/.tsh, identity_file, in-memory). 
- Replace custom identity file handling with in-memory client store.
- Fix issues with trusted certs handling.
2023-01-06 01:34:04 +00:00
Michael 7d78090841 Update webapi/sessions route (#19892) 2023-01-05 12:23:28 -06:00
Tiago Silva 40861809a6 Add RoleV6 resource type (#19324)
This PR includes a new Role resource version that is compatible with V5 spec.

The new resource introduces the `kubernetes_resources` definition that allows operators to limit the Kubernetes resources that each member can access. The `kubernetes_resources` entries must follow the following format: `{"kind":"<kind>", "namespace":"<namespace>","name":"<pod>"}`. Currently, it only supports objects of `kind` `pod`. Valid examples `<namespace>/<name>:
- `*/*`: matches all pods in all namespaces.
- `default/*`: matches all pods in the `default` namespace.
- `*/nginx-*`: matches every pod prefixed with `nginx-` in every namespace.

For older resource versions - V5, V4, V3 - `kubernetes_resources` is automatically populated with `{"kind":"pod","namespace":"*","name":"*"}` to keep compatibility. For the newest version, it's mandatory to define its value otherwise access to pods will be denied.

Part of #18434
2023-01-05 09:58:12 +00:00
Tiago Silva c3fe7c092f Update Kubernetes Dependencies (#19695)
This PR replaces the following PRs opened by dependabot:
- #19678 
- #19677 

It also bumps:

- Bump k8s.io/api from v0.25.4 to v0.26.0
- Bump k8s.io/apiextensions-apiserver from v0.25.4 to v0.26.0
- Bump k8s.io/apimachinery from v0.25.4 to v0.26.0
- Bump k8s.io/apiserver from v0.25.4 to v0.26.0
- Bump k8s.io/cli-runtime from v0.25.4 to v0.26.0
- Bump k8s.io/kubectl from v0.25.4 to v0.26.0
- Bump k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed to v0.0.0-20221128185143-99ec85e7a448
- Bump sigs.k8s.io/controller-runtime from v0.13.1 to v0.14.1
2022-12-29 22:49:22 +00:00
Gavin Frazar 4330e43cc9 security: Prevent app access authz bypass 2022-12-28 09:24:02 -08:00
STeve (Xin) Huang 39cee50cc9 Fix Too many requests error in github actions test (#19606) 2022-12-23 03:47:02 +00:00
Marco André Dinis adcdc2459f Add DatabaseService heartbeat (#19570)
n the context of Teleport Discover, we must be able to known if there's any DatabaseService available to proxy a given Database resource.
If there's none available, we will offer a script for the user to run and install a DatabaseService which proxies the desired Database resource.

By DatabaseService, we mean the process that Teleport binary manages when the `teleport.yaml` config has the following section:
```yaml
db_service:
  enabled: "yes"
```

To accomplish this we are creating a new resource: DatabaseService.
The UI will fetch all DatabaseServices and check if there's any ResourceMatcher that matches the DatabaseLabels.

Previous PRs created the DatabaseService resource and its CRUD methods.

This PR adds an heartbeat for DatabaseServices similar to what we have for Databases.
There's also a new command to list DatabaseServices using `tctl`:
```
$ tctl get db_service --format text
Name                                 Resource Matchers                      
------------------------------------ -------------------------------------- 
a6065ee9-d5ee-4555-8d47-94a78625277b (Labels: <all databases>)              
d4e13f2b-0a55-4e0a-b363-bacfb1a11294 (Labels: env=[prod],aws-tag=[xyz abc]) 
```


Test using Teleport Cloud
```
dinis@lenix ~/p/cloudagents> tctl get db_services
kind: db_service
metadata:
  expires: "2022-12-21T18:05:10Z"
  id: 1671645310983808522
  name: 2a28d394-900c-42ea-a120-eed918e4526b
spec:
  resources:
  - labels:
      aws-tag:
      - xyz
      - abc
      env: prod
version: v1
dinis@lenix ~/p/cloudagents> tctl status
Cluster  marcoacme.cloud.gravitational.io                                        
Version  12.0.0-dev 
```

Part of #19032
Related #19363 #19469
2022-12-22 09:19:02 +01:00
Steven Martin e1ebc332f8 spell fixes (#19419) 2022-12-16 19:01:28 +00:00
Rafał Cieślak 519c9aa0df Improve error handling in Connect gateway integration test (#19145)
mockTSHDEventsClient will most likely be called outside of the test
goroutine, so we shouldn't use require.NoError there.

helpers.SetupUserCreds returns an error which I did not inspect. The linter
didn't warn me about it for some reason.
2022-12-15 09:49:20 +00:00
Russell Jones 7895fddc57 Added the ability to supply Access Request TTLs
Added the ability to specify two CLI flags for Access Requests:
"--request-ttl" and "--session-ttl".

Updated "CreateAccessRequest" to adhere to the following rules.

If an Access Request does not have a TTL set (expiration time
types.AccessRequest resource itself), a default of 1 hour is used. Next,
the request value is truncated by the lifetime of the certificate,
requested expiration, and then strictest session TTL on all roles
requested.

Similar logic is followed for the expiration time of the elevated
certificate that will be issued if the Access Request is approved. First
the requested value is truncated by the lifetime of the certificate,
requested expiration, and then strictest session TTL on all roles
requested.

The output of "tsh requests ls" and "tctl requests ls" has been updated
to display the TTL values.
2022-12-14 15:18:33 -08:00