Commit graph

1487 commits

Author SHA1 Message Date
STeve (Xin) Huang 6fed15d13f
Add an option to bootstrap database service to teleport discovery boostrap (#28720)
* Add an option to bootstrap database service access at `tsh discovery boostrap`

* fix var name

* use a TargetService enum
2023-07-12 14:29:30 +00:00
Forrest ae42a6e0d0
remove alert maximums (#28967) 2023-07-11 21:15:32 +00:00
Steven Martin 7efb6635b3
include endpoint_url parameter for tctl sso configure github (#28842)
* include endpoint_url parameter for tctl sso configure github

* add api-endpoint-url paramter

* unify GitHub endpoint descriptions
2023-07-11 20:05:33 +00:00
Rafał Cieślak 732ad92d5f
tctl alerts ack: Make --reason optional (#28939)
This fixes `tctl alerts ack ls` which used to not work due to the reasons
described in the comment.

Providing a reason is still required. The only difference is that instead
of having the CLI fail immediately if the flag is missing, the CLI will
issue a request to the cluster which will fail due to a missing reason.
2023-07-11 14:49:28 +00:00
Brian Joerger 8a13de3ef9
Fix ssh env var parsing by checking after cf.AuthConnector is guaranteed to be set. (#27970) 2023-07-10 17:29:04 +00:00
Rafał Cieślak 2003088382
tctl alert ls: Always show alert ID (#28808) 2023-07-10 16:09:49 +00:00
Tiago Silva 4da3e820ad
Deduplicate resources for tsh request search when replicas>1 (#28661)
When the number of replicas of a resource is bigger than 1 - i.e.
`kube_cluster`, `app`, `db` - `tsh request search` printed
all the registered resources instead of ignoring the repeated rows.

This PR excludes the repeated resource ids from the table and request
command.

Before:
```
$ tsh request search --kind kube_cluster
Name       Hostname Labels                                                             Resource ID
---------- -------- ------------------------------------------------------------------ -----------------------------------
local               env=tiago                                                          /tele.local/kube_cluster/local
my-cluster          teleport.internal/resource-id=89b78b53-600f-4545-922c-96d20ee15182 /tele.local/kube_cluster/my-cluster
my-cluster          teleport.internal/resource-id=89b78b53-600f-4545-922c-96d20ee15182 /tele.local/kube_cluster/my-cluster
my-cluster          teleport.internal/resource-id=89b78b53-600f-4545-922c-96d20ee15182 /tele.local/kube_cluster/my-cluster

To request access to these resources, run
> tsh request create --resource /tele.local/kube_cluster/local --resource /tele.local/kube_cluster/my-cluster --resource /tele.local/kube_cluster/my-cluster --resource /tele.local/kube_cluster/my-cluster \
    --reason <request reason>

```

After:

```
$ tsh request search --kind kube_cluster
Name       Hostname Labels                                                             Resource ID
---------- -------- ------------------------------------------------------------------ -----------------------------------
local               env=tiago                                                          /tele.local/kube_cluster/local
my-cluster          teleport.internal/resource-id=89b78b53-600f-4545-922c-96d20ee15182 /tele.local/kube_cluster/my-cluster

To request access to these resources, run
> tsh request create --resource /tele.local/kube_cluster/local --resource /tele.local/kube_cluster/my-cluster \
    --reason <request reason>

```
2023-07-10 13:55:55 +00:00
STeve (Xin) Huang a86283e261
Connect Kube gateway part 1: lib/teleterm/gateway (#28312)
* Connect Kube gateway part 1: lib/teleterm/gateway

* fix lint

* move IsDB/IsKube to resource URI

* address review comments

* config dir

* use ProfileDir instead of ConfigDir

* remove NewKubeForwardProxyWithListener
2023-07-10 12:58:23 +00:00
Forrest 628d77f6bb
rework instance hbs to be more scalable and to track upgraders (#27895) 2023-07-08 02:15:56 +00:00
Tiago Silva f8c75a043d
Fix tsh kube credentials lock when no-login is required (#28435)
This PR moves the creation of the `lock` file right before the login
call is attempted instead of creating it for any call.

This fixes a problem where we create the lock file even if no login is
required which limits the number of parallel kubectl invocations.
2023-07-07 11:34:12 +00:00
Jakub Nyckowski 784e6197d2
Fix imports on non-linting files (#28752)
Our linter does not run on all files, so the incorrect sorting is not reported, but GCI keeps fixing these imports each time I run it, hence the PR.
2023-07-06 14:32:56 +00:00
Gus Luxton 8abbea6fec
tsh: Implement puttyconfig command to add saved PuTTY sessions to Windows registry (#19316)
* tsh: Implement puttyconfig command to add saved PuTTY sessions to Windows registry

* Addressed comments from code review

* Add support for leaf clusters

* Refactoring from code review

Also moved registry/hostname functions into external packages

* Address more feedback from code review

* Rebase following tsh/common changes

* Fix up putty_config_windows

* Reorder command

* Remove surplus comment

* Use a separate list instead of overloading the 'extra' key

* Address Tim's code review comments

* Address some of Zac's comments

* Refactor formatLocalCommandString to use text/template

* Refactor non-Windows logic into puttyhosts

* Fix subcommand name

* Fix test structure

* Add some more hostnames test cases

* Apply suggestions from code review

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

* Fix up

---------

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
2023-07-05 17:53:46 +00:00
rosstimothy 119dc7a3a3
Reduce login latency (#28499)
Reuse the root cluster auth client during the login process
to reduce latency.

Closes #26712.
Partially addresses #26712.
2023-07-05 15:51:56 +00:00
Jakub Nyckowski c29765b7d4
Add t.Parallel() to several tsh tests (#28470)
Added the `t.Parallel()` function call in each test function to enable parallel test execution. This should reduce the overall time it takes to run all these tests by enabling them to run concurrently.
2023-07-03 16:51:42 +00:00
Marco André Dinis e043ac07ea
AWS OIDC - DeployService: configure IAM (#28088)
* auto configure deployservice iam

* review pt1

* review pt2
2023-06-30 18:35:29 +00:00
rosstimothy 20559218ad
Fix tsh windows builds (#28357)
#24864 added a dependency of lib/web into tsh which broke windows
tsh builds because lib/web transiently depends on lib/srv which
has linux specific code. This shuffles around a few things so
that lib/web is no longer importing lib/srv at all by:

- Indirectly using the srv.SessionController to apply session
control for web ssh sessions

- Moving the common reversetunnel interfaces into
reversetunnelclient since lib/reversetunnel imports
lib/srv/forward which imports lib/srv.

- Directly converting mysql client errors in the connection
tester instead of calling a common function.
2023-06-30 17:12:12 +00:00
Steven Martin 2019e0d680
Update tsh scp command description to match ssh node commands (#28465) 2023-06-29 14:43:49 +00:00
Steven Martin 3a8a2e107c
use teleport.sh instead of dashboard.goteleport.com for license retrieval (#28421) 2023-06-28 15:10:22 +00:00
Hugo Shaka 3bc6497bcd
Hide wait subcommands (#28031) 2023-06-28 13:11:45 +00:00
Noah Stride 2e47bf740d
Machine ID: Configuration migration (#27468)
* Introduce new tbot output configuration

* Remove code that will be included in future test refactor PR

* Add config version header

* Fix TestInitSymlink

* Add support for `standard` database type

* Set CA type

* `make fix-imports`

* More closely mimic original database output behaviour

* Make output of additional TLS files for application output optional

* Spell compatability properly

* Add test for config marshalling

* Fix cluster field yaml name

* Fix YAML marshalling/unmarshalling

* Fix sidecar invocation of tbot

* Add WrapDestination helper function to protect wrappedDestination

* Apply changes to sidecar

* Spell Marshalling the way the linter insists

* Fix some logging

* Tidy mutex usage on outputRenewalCache

* Fix ssh_host generation

* TBot Config V2 migration support

* Fix misspelling

* Get rid of `destinationWrapper`

* Single l in Unmarshaling

* Fix operator sidecar tbot

* Add UnmarshalYAML for SSHHostOutput

* Fix migration for removed destinationWrapper

* Use updated KubernetesCluster field name

* Add real world test case for migration

* Add additional migration tests

* Use `KubernetesCluster` instead of `ClusterName` for clarity

* Add additional "real-world" migrations from customer feedback

* Rename `Subtype` -> `Format` for `DatabaseOutput`

* Rename Subtype -> Format for DatabaseOutput

* Remove a very british "u" from Behaviour

* Add godoc for interfacemethods

* Fix double dot in comment

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

* Use const for database formats

* Reuse constant type string in Stringer

* Add godoc comment explaining behaviour if no destination found

* Inject executablePathGetter rather than using package level variable

* Use correct case in error

* Add warning for destination reuse

* Try to improve confusing log message

* Remove 'u' from behaviour

* Emit error when v2 config possibly being migrated as v1

* Fix imports

* Ensure they dont overwrite original config

* Remove redundant check

---------

Co-authored-by: Michael Wilson <mike@mdwn.dev>
2023-06-28 09:10:47 +00:00
Noah Stride ab2279634d
Machine ID: New configuration format (#27152)
* Introduce new tbot output configuration

* Remove code that will be included in future test refactor PR

* Add config version header

* Fix TestInitSymlink

* Add support for `standard` database type

* Set CA type

* `make fix-imports`

* More closely mimic original database output behaviour

* Make output of additional TLS files for application output optional

* Spell compatability properly

* Add test for config marshalling

* Fix cluster field yaml name

* Fix YAML marshalling/unmarshalling

* Fix sidecar invocation of tbot

* Add WrapDestination helper function to protect wrappedDestination

* Apply changes to sidecar

* Spell Marshalling the way the linter insists

* Fix some logging

* Tidy mutex usage on outputRenewalCache

* Fix ssh_host generation

* Get rid of `destinationWrapper`

* Single l in Unmarshaling

* Fix operator sidecar tbot

* Add UnmarshalYAML for SSHHostOutput

* Use `KubernetesCluster` instead of `ClusterName` for clarity

* Rename `Subtype` -> `Format` for `DatabaseOutput`

* Remove a very british "u" from Behaviour

* Add godoc for interfacemethods

* Fix double dot in comment

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

* Use const for database formats

* Reuse constant type string in Stringer

* Add godoc comment explaining behaviour if no destination found

* Inject executablePathGetter rather than using package level variable

* Use correct case in error

* Add warning for destination reuse

* Try to improve confusing log message

* Remove 'u' from behaviour

---------

Co-authored-by: Michael Wilson <mike@mdwn.dev>
2023-06-27 08:03:38 +00:00
Alan Parra d83146422a
Use the long-form --config flag in shell example (#28232) 2023-06-26 14:39:16 +00:00
Brian Joerger c8647a7508
Don't add keys to agent during headless login. (#27960) 2023-06-23 21:03:47 +00:00
Alan Parra 44960a89af
Warn about clamshell-related touch ID unavailability (#28175) 2023-06-23 16:45:59 +00:00
Marco André Dinis 48a113bb93
InstallScripts: pin teleport version using ServerVersion (#28149)
* InstallScripts: pin teleport version using ServerVersion

When Automatic Upgrades are enabled and the current installation is an
enterprise build, it will install teleport using:
- stable/cloud repo channel (yum, apt)
- pin the version to the one present at:
  https://updates.releases.teleport.dev/v1/stable/cloud/version

* improve comments
2023-06-23 15:45:36 +00:00
rosstimothy 2593843c6f
Support for benchmarking web sessions (#24864)
Adds `tsh bench web ssh` to allow benchmarking ssh sessions that are
created via the web api. To prevent import cycles between `lib/web`
and `lib/client` the cookie implementation in `lib/web/cookie.go`
was moved into its own package `lib/web/session`. There is curerntly
no support for SSO users - adding a local server to handle the login
was out of scope and can be added in the future.
2023-06-23 15:08:06 +00:00
Alex McGrath e2b76bb04f
Add option to allow for host users not to be deleted (#26892)
* Add option to allow for host users not to be deleted

This adds a new role option called create_host_users_mode which allows
for it to be configured to not delete users when a session ends. The
old `create_host_user` option will be deprecated with this.

If the deprecated option is set, the new mode option will default to
dropping users as is the current behavior.

* add generated protos

* use combined output for commands, dont set CreateHostUser

* fix tests

* ci fixes

* add godocs to HostUserMode constants, fix tests

* remain -> keep

* Use an enum instead of a string

* fix merge errors

* Add tests & resolve comments

* Resolve issues

* fmt
2023-06-23 13:35:57 +00:00
Krzysztof Skrzętnicki e5b95051f4
Add CLI options for OpenSearch autodiscovery config. (#27941) 2023-06-22 13:19:52 +00:00
Steven Martin d6205f50b7
update message on empty tsh ls results (#28095)
* update message on empty tsh ls results

* Update message to have no docs

* update verbiage

Co-authored-by: Paul Gottschling <paul.gottschling@goteleport.com>

---------

Co-authored-by: Paul Gottschling <paul.gottschling@goteleport.com>
2023-06-21 21:29:42 +00:00
Alex McGrath 0760bc9776
Allow setting max_session_ttl from clusterauth preferences (#26824)
Document `default_session_ttl` in the reference.
2023-06-21 10:39:34 +00:00
Alan Parra ec8594f96d
fix: Ignore staticcheck false positive on darwin (#28038) 2023-06-19 18:42:10 +00:00
Krzysztof Skrzętnicki 57609fd6bd
Fix invalid command example. (#27943) 2023-06-16 21:01:08 +00:00
Noah Stride 60a325aa7c
Device Trust: tsh privilege elevation for TPM enrollment (#27833)
* Start fleshing out UAC elevation

* Use `runas` and ShellExecuteW to open a child process with elevated privileges

* Add tsh command to re-execute

* Add method to be called in the elevated child process

* Ugly, but working, credential activation in UAC dialogued child

* Add TODO

* Add some further notes/explanation on windows.ShellExecute

* Change error message to match function name

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

* Improve comment

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

* Use `trace.BadParameter` instead of `Errorf`

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

* Use `tpm-activate-credential` instead of `activate-credential`

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

* Remove spurious newline

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

* Move towards more production ready elevated process

* Add stubs for darwin/other

* Use path in state dir for cred activation results

* Fix stub return values

* Fix test missing context.Context pass

* Add additional message when cred activation completes

* Use ShellExecuteExW to get handle to process to wait on

* Improve comment in windowsexec

* Minor stylistic changes from review

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

* Minor adjustments to error handling and logging

* Use `windows` over `syscall`

* Leverage `mkwinsyscall`'s error handling

* Missing param in test

* Always show error, not just when `-d` is provided

* Remove unnecessary trace.Wrap(err)

* Restore cf.Debug check

* Explicitly ignore return values from `FPrintln`

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

* Simplify code

* Add null check to `info.hProcess`

* Minor format changes from review

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

---------

Co-authored-by: Alan Parra <alan.parra@goteleport.com>
Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
2023-06-16 17:35:03 +00:00
Krzysztof Skrzętnicki 1b69fbcbed
OpenSearch AWS autodiscovery (#27537)
* OpenSearch AWS autodiscovery

* Normalize description, check err.

* Fix tests.
2023-06-16 12:56:53 +00:00
Noah Stride 4151218576
Add Machine ID tip when tctl auth sign is used (#27804)
* Add prompt to machine id page when using `tctl auth sign` for a user credential

* Use FPrintf with stderr instead of `log.Info`

* Move newline

* Remove emoji from message in case it breaks terminals
2023-06-16 10:39:50 +00:00
rosstimothy c78743c59b
Ensure SSH_SESSION_WEBPROXY_ADDR is set for all sessions (#27842)
Fixes a discrepancy in overwriting the environment value with the
address observed for the Web UI for sessions not originating from
the Web UI. All sessions will now use `tc.WebProxyAddr` as the
default value and *only* update if an override is provided.

`TestIntegrations/EnvironmentVars` was updated to ensure that the
expected environment variables are present in both interactive and
non-interactive sessions.
2023-06-14 19:47:32 +00:00
Brian Joerger e43ef74f36
Add skip-confirm flag for headless approval. (#27823) 2023-06-14 19:08:26 +00:00
STeve (Xin) Huang e677aadb9f
Fix an issue ALPN handshake test does not respect "HTTPS_PROXY" (#27583)
* Fix an issue ALPN handshake test does not respect "HTTPS_PROXY"

* address review comment

* remove simplehttsproxy

* Add context to IsALPNConnUpgradeRequired in ten thousand places

* add goc and dial with context
2023-06-13 15:30:48 +00:00
STeve (Xin) Huang 66f5b5510c
Fix an issue kube local proxy requirement is wrong in separate port mode (#27634)
* Fix an issue kube local proxy requirement is wrong in separate port mode

* move kube local proxy requirement check to api/profile
2023-06-12 13:49:09 +00:00
rosstimothy 553eb02bdf
Fix moderated session presence checking (#25988)
* Fix moderated session presence checking

Addresses all of the issues that were preventing presence checking during
moderated sessions from working as described in
[#18092](https://github.com/gravitational/teleport/issues/18092#issuecomment-1540900859).

Closes #18092

* make presence test clearer

* fix presence checking on the web ui

* Refactor web socket message handling

A single message processing loop handles retrieving the envelope
and passing it off to individual message handlers. This allows all
messages to be processed outside of `Read` which was dependent on
the terminal being active to process any messages.

The webauthn challenge response was also moved from a raw message
to a webauthn message. By sending it as a raw message it made
presence checking fail because the response has a `t` in it which
caused the session to be killed during moderated sessions.

* enforce mfa ceremony when joining and cluster wide mfa is enabled

* fix conflicts with master

* moderated tests

* Add moderated session tests for the UI

* Add moderated session integration test

* fix lints

* clean up presence test

* refactor envelope handling

* fix build

* fix: revert test debug timeout

* fix: use local context in tests

* simplify closing streams

* generalize waitForOutput to work with an io.Reader

* fix error handling in stream close

* unexport PresenceOptions

* Improve waitForOutput to match against output in successive reads
2023-06-08 20:27:13 +00:00
Nic Klaassen 21e38dc125
Enable use of user traits in label expressions (#27138)
* enable user traits in label expressions

* move accessChecker methods to access_checker.go
2023-06-08 06:21:11 +00:00
Brian Joerger ca1c4869ef
Use tcp listener file descriptor to assign listeners to test server without collisions. (#27515) 2023-06-07 22:17:18 +00:00
Brian Joerger 207c9136ab
Test tool/tsh/common in CI (#27579)
* Change tsh test directory referenced in makefile.

Fix proxy template test case.

* Fix TestWriteSSHConfig.

---------

Co-authored-by: Steven Martin <steven@goteleport.com>
2023-06-07 19:02:10 +00:00
Steven Martin 488bd91263
use proxy port in openssh config (#27536)
* use proxy port in openssh config

* update test record
2023-06-07 14:28:27 +00:00
Brian Joerger b7fed8ae72
Fix an unintended interaction between and Proxy Templates where the environment variable is prioritized over the template. (#27492) 2023-06-06 22:58:51 +00:00
Brian Joerger 193abfdf2c
Only fallback to SSH_TELEPORT_ env variables for proxy, user, and cluster name when used with headless. (#27057) 2023-06-06 19:53:45 +00:00
Sakshyam Shah 796b2d29a0
device trust marshalers (#24963)
* feat: device resource in tctl get all

* check for device resource but ignore in favour of enterprise resource migration

* add firstStart indicator in auth service config. Tests

* remove device bootstrap from this PR

* multiple updates:
- remove resource marshaler, this will be added to e repo instead
- remove device resource checks in oss (not needed as resource marshaler now added to e). tests removed

* move device marshalers to service package

* run fix-imports, fix test

* remove device case from itemsFromResource
2023-06-06 17:29:49 +00:00
Gabriel Corado a200271ac5
Support authenticating with AWS IAM role for MongoDB Atlas (#26439)
* feat: support authenticating with AWS IAM for MongoDB Atlas

* chore(lint): fix errors

* test(tsh): add missing database field

* refactor(mongodb): check for error on each authenticator branch

* refactor(mongodb): update log messages and atlas check

* refactor(auth): use IsRoleARN helper instead of IsARN

* chore(db): remove unused line

* chore(mongodb): split authenticator func

* refactor(db): rename get atlas token function

* tests(db): reuse already existent auth property

* chore(mongodb): add docs reference

* refactor(db): support role chaining

* feat(types): "require" iam role for atlas users

* refactor(db): use external id only on the first session

* refactor(services): add new database matcher for regular users and aws

* chore(db): rename functions to be more assertive

* chore(types): fix lint

* test(db): remove duplicated test

The test being removed here is covered by `TestMongoDBAtlas`
(lib/srv/db/auth_test.go).
2023-06-06 14:57:27 +00:00
Noah Stride cb39f79500
Machine ID stability: separate bot identity and impersonated identity renewal (#24267)
* Start breaking apart bot renewal loops

* Refactor initial bot identity fetching

* Tidy up some log messages

* Add renewal loop for bot identity

* Tidy up logging

* Add channel broadcaster so multiple can listen

* Fix compilation

* Ensure template instructions include join-method

* Fail harder for template failure to render

* More graceful failure to describe identity

* support partial renewals of bot identity

* Move methods to helper functions to avoid potential state confusion

* Simplify how template renderers access the bot

* Simplify bot mock in tbot/config tests

* Add integration test for whole bot

* Further tidying of test

* Fix operator sidecar bot invocations

* Fix anonymous telemetry testing

* Ensure we always return the unlock

* Nicer error message

* Use better naming for provider/organise impersonated_identity file

* Ensure impersonated client closed on failure

* Close testclient after initialize complete

* Fix tests in main package

* Missing license header

* Allow join method to be omitted for `tbot init`

* Use correct limit in log messages for bot identity renewal

* Propagate new identity before persisting it to disk

* Move warning about renewal interval

* document unsubscribe

* Support SIGHUP again
2023-06-06 10:53:25 +00:00
Brian Joerger 70c5ce7e8c
Add tsh e2e tests with various security features enabled (#26862)
* * Refactor tool/tsh to enable tsh e2e tests outside of the tsh package.

* Add tool/teleport/testenv to enable easier e2e tests from outside
  packages.

* Skip all flaky test checks when * is provided.
2023-06-06 01:25:09 +00:00