Commit graph

992 commits

Author SHA1 Message Date
Forrest Marshall 31f258fec9 inventory control stream & certs 2022-06-15 22:26:24 -07:00
STeve (Xin) Huang 85016a9a3e
MemoryDB support (#13069) 2022-06-14 19:09:31 +00:00
Brian Joerger b5472d41ec
Convert GenerateToken to gRPC. (#9024) 2022-06-14 17:43:39 +00:00
Krzysztof Skrzętnicki 7f8a2e6e7b
Adjust tctl sso commands to new teams_to_roles field. (#13463) 2022-06-14 10:10:27 +00:00
rosstimothy e5c745f331
Add manual tracing instrumentation to tsh (#13204)
Create spans for all public facing TeleportClient,
ProxyClient, and NodeClient methods. This makes
correlating spans easier to reason about when
looking at `tsh` traces. As a result of creating
spans, some additional context propagation is
required as well to ensure that spans are linked
properly.

This also removes the unused `quiet` argument from
`ConnectToCluster`. It's usage was not consistent
by existing callers, and it was ignored, so in order
to avoid confusion in future calls, it was removed.

#12241
2022-06-11 15:34:40 +00:00
Alan Parra 0ecf31de0e
Restore terminal state on interrupt or exit (#13382)
Fixes an issue with ContextReader on `bash` where abandoned password reads cause
the terminal to remain "locked" even after `tsh` exits. This happens on
interrupts but also on regular exit if the user picks a security key in the dual
security key/OTP login prompt.

Doesn't seem to affect shells like `zsh` or `fish`.

Repro steps:

```shell
$ bash

# repro #1
$ ./tsh login --proxy=example.com
> Enter password for Teleport user llama: <CTRL-C>
# shell is now locked

# repro #2
# (Use an account with security key and OTP MFA.)
$ ./tsh login --proxy=example.com
> Enter password for Teleport user llama: <enters password>
> Tap any security key or enter a code from a OTP device <taps security key>
# shell is now locked
```

* Restore terminal state on interrupt or exit
* Notify prompt on tsh exit
* Review: context.WithTimeout and Notify on os.Exit
2022-06-10 14:44:18 -03:00
Nic Klaassen b1da3b3054
Make tsh ssh --request the default (#13326) 2022-06-10 17:14:29 +00:00
Nic Klaassen 27a1f1c3d6
Prune roles for Resource Access Requests (#13323) 2022-06-10 16:50:55 +00:00
Przemko Robakowski 951aff47ed
IP-based validation for SSH (#13243)
This change adds IP-based validation for SSH certificates.
There's new option in role definition:

kind: role
metadata:
  name: dev
spec:
  options:
    pin_source_ip: true
When that is set to true client IP must be the same when generating certificates and using them. It uses source_address critical option that should be supported by both teleport and sshd and only applies to certificates we send to user (like in tsh login), we don't pin IP in certificates issued for web UI as they can't leak.
This change also omits machine ID (it uses different code path) - it will be added in separate PR.

Most of the lines changed are from regenerating types.proto, change itself is not that big

Relates #11719
2022-06-08 22:49:37 +00:00
Alan Parra 65438e6e44
Explicitly confirm or rollback Touch ID registrations (#13220)
Change the Touch ID registration interface so `tsh` explicitly confirms or
rollbacks MFA registrations.

Before resident keys, MFA keys from U2F or WebAuthn only truly existed
server-side, but with resident keys/passwordless some cleanup is necessary if
the server-side registration goes awry.

The PR also changes Touch ID authentication so that newer keys are preferred,
which allows re-registration to be used as sort of a self-healing mechanism.

#9160

* Read creation time from Keychain entries
* Explicitly confirm or rollback Touch ID registrations
2022-06-08 20:17:35 +00:00
Andrew Burke 870ac4ca9b
tsh list resources accross proxies and clusters (#12934)
This change adds the --all/-R flag to tsh ls, tsh apps ls, tsh db ls, and tsh kube ls, which lets tsh list resources from across all clusters and logged in proxies.
2022-06-08 18:42:25 +00:00
Brian Joerger 2717c1d2e0
Security fixes (#13298)
* Add CSRF mitigations

This commit includes two fixes:

1. Enforce an application/json Content-Type server-side.
2. When checking the bearer token, verify that the user
   associated with the token matches the user associated
   with the cookie.

* Fix TEL-Q122-13: Access Requests Denial Of Service Via Request Reason (#125) (#127)

* Ignore input when data flow is off in TermManager

When data flow is disabled in TermManager (at the beginning or when TermManager.Off was called) we should ignore all input we receive (currently we buffer it)

* Agent forwarding socket security fix.

Co-authored-by: Lisa Kim <lisa@goteleport.com>
Co-authored-by: Joel <jwejdenstal@icloud.com>
Co-authored-by: Przemko Robakowski <przemko@przemko-robakowski.pl>
2022-06-08 18:12:45 +00:00
Jakub Nyckowski ec6d110f21
Fix tctl Database CA compatibility with v9 cluster (#13177) 2022-06-08 17:45:02 +00:00
Jeff Pihach abe58746df
Update install.sh to use new 'teleport node configure' command (#13127)
* Update install.sh to use new 'teleport node configure' command
2022-06-08 17:20:50 +00:00
Alex McGrath 581efdc60f
Add support for automatic user provisioning (#11830)
* Add support for automatic user provisioning

* Add UID parker to reexec

* Add a `teleport park` subcommand that does nothing

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2022-06-08 12:24:13 +00:00
Brian Joerger 9cc58cca44
gRPC conversions - SSO Auth Connectors (#13073) 2022-06-08 01:45:06 +00:00
Gavin Frazar 0cf23de3b3
Add short flag -c for --cluster in tsh (#13044) 2022-06-07 23:01:43 +00:00
Justinas Stankevičius 61d5718080
Fix help string for "tctl version" (#12827)
`tctl version`, just as `tsh version`,
prints out the version of the binary itself,
not the version of the cluster it's connected to.

The cluster version can be discovered by running
`tctl status`.
2022-06-07 15:32:29 +00:00
Roman Tkachenko ec512bafa4
Implement proxy templates (#12848) 2022-06-07 00:06:52 +00:00
Nic Klaassen faae2f8a5c
Fix resource kinds for search (#13142) 2022-06-06 18:34:08 +00:00
Jakub Nyckowski 9c046930ff
Snowflake integration (#12564)
Add Snowflake integration.

Co-authored-by: Marek Smoliński <marek@goteleport.com>
2022-06-06 17:49:38 +00:00
Marco André Dinis 306d011151
Deprecate ca_signature_algo config (#13033)
After the merge of https://github.com/gravitational/teleport/pull/12674 we no longer use the following configuration:
```yaml
teleport:
    ca_signature_algo: "rsa-sha2-512"
```
As we now rely upon the `x/crypto` package to choose the signing algorithm (it defaults to `rsa-sha2-512`)

**Demo**
If we set `ca_signature_algo` (the value is irrelevant) and start `teleport` we get:
```shell
root@marco:/workspace# teleport start --debug
2022-06-02T09:33:58Z WARN             ca_signing_algo config option is deprecated and will be ignored, we'll always default to rsa-sha2-512. config/configuration.go:348
2022-06-02T09:33:58Z INFO             Generating new host UUID: b001159a-10e0-49a7-b4dc-61c73fbe9e42. service/service.go:726
...
```

Fixes #12905
2022-06-06 16:18:15 +01:00
Nic Klaassen 7f440d7d3e
implement tsh ssh --request (#13051) 2022-06-03 23:07:59 +00:00
Alan Parra 9ca045bacd
Expand --mfa-mode and disable stdin hijack by default (#13134)
Avoid "input swallowing" bugs by disabling stdin hijacking by default.

Only `tsh login` is allowed to hijack stdin, as it is expected to exit right
after authentication. Any MFA authentication attempts resulting from
non-`tsh login` invocations default to the user's strongest auth method.

Defaulting to the strongest auth method can cause problems in constrained
environments for users that have both Webauthn and OTP registered. For example,
someone using `tsh` under WSL (Windows Subsystem for Linux) or a remote machine
could be locked into Webauthn MFA, which they can't use because their
environment lacks USB access or they don't have physical access to it. In order
to solve this problem I've slightly modified the meaning of the `--mfa-mode`
flag so `otp` can be specified.

The `TELEPORT_MFA_MODE` environment variable may be set to avoid constant flag
passing.

Fixes #12675 and #13021.

* Expand --mfa-mode and disable stdin hijack by default
* Use TELEPORT_ instead of TSH_ for FIDO2 env var
* Use t.Setenv in tests
2022-06-03 22:13:50 +00:00
STeve (Xin) Huang 7a23fe80f9
Implement "tsh proxy aws" (#10025) 2022-06-03 19:14:34 +00:00
Alex McGrath 1b81a0418c
Add join-method flag to teleport node configure (#13097)
* Add `join-method` flag to `teleport node configure`

This will be used by EC2 auto discovery for generating configs after
installation

* Document join_params in reference/config.mdx
2022-06-03 16:52:03 +00:00
rosstimothy 25ec2c8a39
Add client side circuit breaker to auth clients (#10282)
* Add client side circuit breaker to auth clients

In order to apply back pressure we can utilize a circuit breaker that
monitors error responses from auth server. When tripped it will prevent
all outbound requests to auth for a period of time. This can also help
prevent a potential thundering heard when auth is in an unhealthy state.
By default the circuit breaker will only be tripped if 90% of the
requests made in the monitoring interval fail.
2022-06-03 11:55:56 -04:00
Grzegorz Zdunek 3a33de41a6
Enable info level logging for Connect in non-debug mode (#13027) 2022-06-03 11:24:18 +02:00
Nic Klaassen 4d76910b59
nicer ResourceID strings (#13093) 2022-06-03 01:33:11 +00:00
Nic Klaassen 814664ab66
[Search-based access requests] Enforce resource access restrictions (#12651) 2022-06-03 00:04:44 +00:00
Håkon Solbjørg 6f73b82935
fix(teleport/db-create): Use --proxy instead of --auth-server in example command (#12834)
`teleport db create` uses --proxy and not --auth-server.

See this example (some output removed for brevity):
```
$ tctl tokens add --type=db,node
*snip*
Or, generate the configuration and start a Teleport agent using it:

> teleport db configure create \
   --token=... \
   --ca-pin=... \
   --auth-server=my-server.example.org \
   --output file:///etc/teleport.yaml

> teleport start -c /etc/teleport.yaml

$ teleport db configure create \
>    --token=... \
>    --ca-pin=... \
>    --auth-server=my-server.example.org \
>    --output file:///tmp/foo.yml
teleport: error: unknown long flag '--auth-server'
```

Co-authored-by: Roman Tkachenko <roman@goteleport.com>
2022-06-02 22:46:39 +00:00
rosstimothy c3736c7c70
Span forwarding (#12980)
* Span forwarding

Modifies the auth grpc server to implement the OTLP Collector
RegisterTraceServiceServer API (https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/collector/trace/v1/trace_service.proto).
This allows the auth server to receive spans from other services
like `tsh`, `tctl`, and `tbot`. Any spans received by the auth
server will be forwarded to the exporter configured via the
`tracing_service` if it is enabled. All received spans will be
dropped in the event that the`tracing_service` disabled. By
forwarding spans to the auth server, `tsh` doesn't need to
be provided with any of the telemetry backend information
to have its spans exported.

Adds a new `--trace` flag to `tsh` to enable collecting and
forwarding spans to the auth server. When set, the tracing
provider is initialized with a sampling rate of 1.0 to force
all spans to be recorded. Teleport respects the sampling rate
from remote spans, which means that when `--trace` is set, all
spans from `tsh` and any downstream Teleport services will be
recorded and exported regardless of the sampling rate that each
Teleport service is configured with.
2022-06-02 09:28:30 -04:00
Krzysztof Skrzętnicki 50c1de548a
Expose Config in SSOConfigureCommand (#13060) 2022-06-02 10:52:12 +02:00
Noah Stride 7e73d1a501
Convert GetDomainName and GetClusterCACert to gRPC (#12937)
* convert GetDomainNAme endpoint to gRPC

* migrate GetClusterCACert from http to grpc

* fix tests failing due to switch to gRPC transport

* Correct mispelt json tag

* remove `GetLocalClusterName` and `UpsertLocalClusterName` which are unused

* remove unused prefix constant from presence
2022-06-01 22:53:42 +00:00
Jeff Pihach ee255fa5de
Add new teleport node configure command (#13032)
* Add new 'teleport node configure' command to output a config that has all services but ssh disabled.
2022-06-01 20:56:10 +00:00
Andrew LeFevre 02f409b273
add labels to output of 'tsh kube ls' (#12753)
Fixes #11203.
2022-06-01 17:52:44 +00:00
Noah Stride 8b346ef06b
Refactor tbot (#12855)
* start refactoring tbot to have a core struct

* refactor tbot into lib/

* move `tbot` subpackages to `lib/tbot`

* remove mutex pointer

* move `tshwrap` to `lib/` from `/tool/tbot/`

* move new template ssh client render test to lib/

* address pr feedback

* add request changed
2022-06-01 17:15:26 +00:00
Noah Stride 18558b88e9
thread context.Context from tctl Run() to subcommands (#13029) 2022-06-01 12:49:59 +01:00
STeve (Xin) Huang 50dcd493df
Manage ElastiCache Users (#12709) 2022-06-01 01:10:56 +00:00
Tim Buckley b170837040
Fix broken version check in tbot's tshwrap (#13034)
`tshwrap` performs a tsh version check to ensure it has the
functionality we need. Unfortunately, during a final refactoring
before merging, we changed the function signature of `capture()` to
require an explicit path to a `tsh` binary but in a way that was
unfortunately not caught by the compiler. The previous syntax meant
we just tried to execute the first argument, i.e. `version`, which
is never what we want.

This PR correctly passes the tsh path to `capture()` to fix the
version check.
2022-05-31 18:23:15 +00:00
Brian Joerger 26bad238fa
OIDC multiple redirect URLs (#12054) 2022-05-31 17:52:04 +00:00
Alan Parra 8302d467d1
Improved touch ID availability and diagnostics (#12963)
Since #12794 we now build `tsh` binaries with touch ID capabilities. This calls
for a more sophisticated mechanism to determine if touch ID functions should be
enabled, as compile-time support only is not enough.

I've added the following checks, on top of compile-time / `touchid` build tag:

Binary is signed
Binary has entitlements
Machine is touch ID capable
Machine has a Secure Enclave
Put together this give us a much better proxy on whether to enable touch ID.

I've also added the `tsh touchid diag` command, mentioned in the Passwordless
macOS RFD (see
https://github.com/gravitational/teleport/blob/master/rfd/0054-passwordless-macos.md#tsh-support-commands).

#9160

* Improved touch ID availability and diagnostics
* Add the `tsh touchid diag` command
* Set min macOS version to 10.12 (macOS Sierra)
2022-05-31 17:10:06 +00:00
Noah Stride e1cd9e16cd
Demonstrate usage of golden for tbot template generation tests. (#12898) 2022-05-31 10:50:41 +00:00
Tiago Silva f984976dfb
Add cluster flag to tsh kube login/ls commands (#12748)
"--cluster" can be used to switch teleport cluster context

Fixes #10024
2022-05-28 12:46:47 +01:00
Tim Buckley 17dbc2d287
Re-add kinds config field to tbot with a deprecation warning (#12933)
* Re-add `kinds` config field with a deprecation warning

This re-adds the `kinds` config field with a deprecation warning. We
removed the field in #11596 but due to strict YAML parsing this
causes existing otherwise compatible configs to error out.

* Update tool/tbot/config/config_destination.go

Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com>

* Use standardized deprecation comment formatting

Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com>
2022-05-27 21:26:19 +00:00
Tim Buckley e8cfe5df6d
Fix missing SSH HostCA in tbot impersonated identities (#12932)
This fixes a bug where the SSH HostCA is missing in impersonated
identities. We only include it in primary identities via the
server-side `includeHostCA` flag which can't be directly set by
clients. Without this CA, impersonated identities can't successfully
connect to the auth server via an SSH tunnel, so database requests
fail when using IoT joining.

We fix this by instead copying SSH CAs from the primary identity.
2022-05-27 19:22:32 +00:00
Tim Buckley 8f36b9ca8f
Add tbot proxy and tbot db wrapper commands (#12687)
* Extend support for identity files in tsh

This enhances support for identity files in tsh, which previously only
worked for regular SSH access. The largest blocker for support is that
tsh uses profiles for all non-SSH resource access, and profiles have a
direct mapping to some on-disk resources. This patch works around this
in a few ways:
 * Virtual profiles: When an identity file is specified with `-i`, we
   use it to create an in-memory virtual profile using the cert as the
   root identity _and_ for every `RouteToDatabase` (and in the future,
   app) field contained in the cert.
 * Virtual profile paths: Certain profile operations require paths to
   valid certificates and other resources on disk, which may not exist
   inside the identity file.

   As the driving use-case for this change is integration with Machine
   ID, we can "cheat" and pass the correct paths to tsh via
   environment variables. A cooperating wrapper in `tbot` will execute
   `tsh` with appropriate flags and environment variables, which
   override tsh's usual certifiate paths. This allows commands like
   `tsh db connect ...` to work as expected.
 * Key stores: previously we used a `noLocalKeyStore{}` with which all
   lookups fail. This patch replaces it with an in-memory keystore if
   a client key is available.
 * Profile status: lastly, we add a new `StatusCurrentWithIdentity()`
   function to load virtual profiles where supported. Some commands
   are not supported in this PR (like `tsh app ...`), but others
   don't make sense to support (like cert reissuing).

   We might consider merging everything into the traditional
   `StatusCurrent()` when adding app support.

App access is still broken and will be addressed in a later change.

Partially fixes #11770

* Fix failing lint

* Add `tbot proxy` and `tbot db` wrapper commands

This adds new wrapper commands that leverage tsh for proxy and
database access.

It also adds a new `tshwrap` helper package which contains utilities
for locating the tsh executable, checking its version, and loading
all necessary data (certificates, destinations, etc) that will need
to be passed to tsh for wrapped commands to function.

* Fix failing unit test due to incorrect default IsVirtual profile flag

* Combine `StatusCurrentWithIdentity()` into `StatusCurrent()`

Additionally, log a warning when environment variable paths aren't
found.

* Fix virtual profile flag always being true

* Update lib/client/api.go

Co-authored-by: Krzysztof Skrzętnicki <krzysztof.skrzetnicki@goteleport.com>

* Address review feedback

* Use `tbot proxy` in generated `ssh_config`

* Add tests for mockable parts of our tsh integration

* Fix lints

* Clarify docstrings in CLIConf

* Tweak comment for clarity; fix typo in `onProxyCommand`

* Add missing copyright header

* Fix failing unit test and pass destination to `Describe()`

This fixes a failing unit test by making the description for
`ssh_config` match its behavior in practice. This necessitated
passing the destination to all templates, unfortunately.

* Add a few extra tests

* Apply suggestions from code review

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

* Address another batch of review comments

* Comment tweaks

* Refactor tshwrap to remove the Runner interface.

* Apply suggestions from code review

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

* Address review comments

Co-authored-by: Krzysztof Skrzętnicki <krzysztof.skrzetnicki@goteleport.com>
Co-authored-by: Alan Parra <alan.parra@goteleport.com>
2022-05-27 18:25:36 +00:00
Jeff Pihach 8d4005b0a7
Add --node-labels support to teleport configure (#12878)
* Added node labels support to the configure command.

* added test for new config node labels flag.

* improve flag messaging for node-labels

* Fail with a help message if an invalid node label is provided to the configure command.

* Use = as a delimeter for label key=value instead of a : to be consistent with existing CLI commands.

* update tests to different label format.

* Wrap any returned error from the label parsing.
2022-05-27 17:08:51 +00:00
Krzysztof Skrzętnicki 9377f7c681
New commands: tctl sso test, tctl sso configure for GitHub (#12783)
* Implement `tctl sso` commands for GitHub auth.

* Mark RFDs as implemented.
2022-05-26 23:26:35 +00:00
Andrew LeFevre e18cbe5d19
Exit with an error if the auth server is too old (#12797)
If the auth server's major version is less than the connecting Teleport
agent, the agent will now log an error and exit to avoid cryptic errors like
in #11161. '--skip-version-check' flag was added so users can override this
behavior if they wish.

Fixes #11854.
2022-05-26 20:32:43 +00:00