Commit Graph
3916 Commits
Author SHA1 Message Date
Zac Bergquist b1d4d608b2 auditlog: fix panic during concurrent streams of the same session (#15361)
The code attempts to wait on an existing download if one is already
in progress rather than starting a concurrent download of the same
session. If this code path runs, we incorrectly defer a call to a
nil function, triggering a panic.

This bug was introduced in #7360.
2022-08-12 14:47:54 +00:00
Vitor Enes 1afb7d5832 Use the absolute path of the teleport binary in node join script (#15466) 2022-08-12 13:18:06 +00:00
Noah StrideandPaul Gottschling 7c904714e9 Machine ID support for Logins trait (#15117)
* Support user traits in impersonated role certificates

* Add param to tctl bots add for specifying logins

* Update comment on desiredAccessInfoForRoleRequest to be mroe accurate

* Update docs for --logins support with Machine ID

* Rearrange bot tests and name them more in-line with standards

* Add test coverage for Server.createBot

* Test role impersonation preserves user traits

* pass traits directly into desiredAccessInfoForRoleRequests

* Drop underscores from test names

* Remove unnecessary initialization of traits

* Address PR comments

* Update docs/pages/machine-id/getting-started.mdx

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

* Update docs/pages/machine-id/getting-started.mdx

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

* Update docs/pages/machine-id/getting-started.mdx

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

Co-authored-by: Paul Gottschling <paul.gottschling@goteleport.com>
2022-08-12 12:06:38 +00:00
Tiago Silva 9b2a781d6e Fix TLS usage across multiple protocols (#15339)
Fix TLS usage across multiple protocols like SPDY used in `kube exec` or WebSockets for moderated sessions that require HTTP/1.1 as the initial protocol while other requests like get/edit/delete rely on HTTP/2 protocol.

The same `*tls.Config` was reused for mixed protocol, causing several issues including a data race while manipulating `*tls.Config.NextProtos` without any lock.

This commit clones the `*tls.Config` per request to prevent mixups between connection protocols.

Fixes #15076
2022-08-12 11:34:35 +00:00
Joel 92883f4a65 Fix race condition to sessions map in K8S proxy (#15238) 2022-08-11 23:11:13 +00:00
Brian Joerger b19836abe7 Update TestForward (#15321) 2022-08-11 16:57:43 +00:00
Noah Stride e65b926791 Remove deprecated GenerateUserCerts HTTP endpoint (#15392) 2022-08-11 10:29:52 +00:00
Alan Parra 2d66b86033 Add better handling for common libfido2 errors (#15323)
Improve the error message for libfido2 error 60 (UV blocked) and automatically
retry error 63 (UV invalid).

libfido2 error 63 happens with some frequency with Yubikey Bio. The biometric
sensor is a bit finicky, so if the finger is a bit off it tends to happen.

Fixes #13900.

* Simulate libfido2 errors 60 and 63
* Add better handling for common libfido2 errors
2022-08-10 18:53:56 +00:00
Ryan Clark 29175e57d3 Use a getter/setter for reading the token value from the config (#14080) 2022-08-10 08:50:21 +00:00
rosstimothy c469a34994 Move prometheus collectors from utils to metrics (#15288) 2022-08-09 17:35:19 +00:00
NajiObeid 7833dc63cb Naji/11867 manual resource joining (#13505)
* improve tsh configure messaging

* missing param

* improve cli output

* remove unnecessary change

* address pr comments

* address pr comments
2022-08-09 15:42:17 +00:00
NajiObeid 787395395a Add config setting for proxy peering public addr (#14905)
* peer proxy public addr config

* address pr comments

* address pr comments

* address pr comments
2022-08-09 15:16:22 +00:00
Edward Dowling be1438aecd tsh: tctl: Add basic recordings ls functionality (#12763) 2022-08-09 11:22:14 +00:00
Joel 469e12412d Add support for variable playback speed for Desktop Access recordings (#15124) 2022-08-08 21:37:12 +00:00
Zac Bergquist d1c6b0618e Fix lint warnings (#15312)
Mostly duplicated imports and redundant types in struct literals.
2022-08-08 20:20:29 +00:00
Zac Bergquist fc05eaf305 desktop access: send full websocket messages to the browser (#15220)
Websockets are a message-based protocol, but our combination of
an io.Writer wrapper and io.Copy means some TDP messages may
get broken up and emitted as separate message events in the browser.

Our UI assumes that each 'message' event is a single TDP message,
so we make sure that each TDP message we send corresponds to a
single WriteMessage call.
2022-08-08 17:55:24 +00:00
Jakub Nyckowski 19d6207919 Docs fixes in BPF module (#15287) 2022-08-08 17:28:18 +00:00
Marco André Dinis 117d7d2d40 Add Suggested Labels to Provision Tokens (#15114)
For Teleport Discover, the user will be able to test connecting to a
resource right after adding it.

The flow should look like this:
- User selects the resource type - in this case Server/Nodes
- WebUI generates a new Token
- WebUI shows the `sudo bash .../<token>/install.sh` to the user
- When the user runs this command, and assuming everything works out,
  the WebUI should be able to receive the Server/Node that was
  generated from that specific Token.

To achieve this, here's a more detailed flow, which this PR implements
- User selects the resource type - in this case Server/Nodes
- WebUI generates a new Token
  This generates a Provision Token which contains a RefResourceID
  WebUI receives back that ID
- WebUI shows the `sudo bash .../<token>/install.sh` to the user
  This generates a script which includes setting the labels as part of
  the `teleport configure` command:
  `$ teleport configure ... --labels teleport.internal/resource-id=<refResourceID> ...`
- User runs the provided command on the target host
- WebUI should be able to query the Servers/Nodes which contain that
  specific `<resource-id>` and allow the user to connect to it.

Demo:
![image](https://user-images.githubusercontent.com/689271/182440692-97c75ae0-1e14-4f76-b9ff-d41060c73ed0.png)
2022-08-08 17:06:41 +00:00
David Boslee 40ade0bbc8 Attempt to connect to additional peer proxies on failure (#14954)
* Previously additional peer proxies were only attempted if the stream
failed to be created. Now any failure for example a missing reverse
tunnel will also attempt additional peer proxies.

* Shuffle the order in which proxy connections are used.
2022-08-08 15:42:10 +00:00
Noah Stride f8a870be29 Adjust Machine ID generated ssh cert path to align with convention (#15199)
* tbot migrate to key-cert.pub from sshcert

* Update golden files

* Explain len(data) == 0

* Switch `WrapWithMessage` to `Wrap`
2022-08-08 08:46:26 +00:00
Isaiah Becker-Mayer 241c3affd2 UnixPath and WindowsPath (#14267) 2022-08-06 03:39:05 +00:00
Marek Smoliński c5f1ec9b8c Try to fix flaky TestProxyClientDisconnectDueToIdleConnection UT (#15241) 2022-08-05 20:01:45 +02:00
Lisa Kim 13cc52f70d Add passwordless login capability to Connect (#14759) 2022-08-05 17:11:28 +00:00
Zac Bergquist f47313ce6c desktop access: try using system DNS resolver first (#15180)
Prior to this change, we assumed that the best way to resolve
auto-discovered desktops would be to make a DNS query of the
configured LDAP server, since the Linux box running Teleport
would likely not be domain joined and may have separate DNS
configuration.

It turns out to be pretty common to deploy dedicated LDAP servers
behind a VIP or other frontend, in which case we fail to resolve
the desktop's IP even though the system resolver would have worked
just fine.

Instead, make a standard DNS query using the system's default
settings first, and fall back to the LDAP server only if that
query fails.

Fixes #15154
2022-08-05 16:17:51 +00:00
Zac BergquistandEdoardo Spadolini 1b4bf8d7eb Fix data race on shutdown (#15075)
Updates #14143

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2022-08-05 15:32:01 +00:00
Tobiasz Heller 57d572dcc5 Fix missing cluster name on session.upload via Upload Completer (#15120) 2022-08-05 13:56:38 +02:00
Marco André Dinis 61c39a9e2b Detect M1/M2 ARM CPUs when using the install script (#15195) 2022-08-05 07:47:01 +00:00
Yassine Bounekhla c431630897 Add teleport install systemd command (#15012) 2022-08-05 01:40:38 +00:00
rosstimothy 0cb248ddd3 Trace ssh sessions (#14966)
Adds a wrapper around `ssh.Session` which injects tracing context
in a similar manner to the `ssh.Client` wrapper. All usages of
`ssh.Session` have now been replaced and have the appropriate
`context.Context` passed along

Part of #12241
2022-08-04 22:14:37 +00:00
361ea8ef3f Windows Desktop Directory Sharing (#13630)
* `IRP_MJ_CREATE` (#12665)

* `IRP_MJ_QUERY_INFORMATION` (#12717)

* `IRP_MJ_CLOSE` (#12729)

* Refactor rdpdr client (#12750)

* Adding logic for `FILE_SUPERSEDE` (#12829)

* Improve `process_irp_create` (#12830)

* adds return statements that got lost in a merge

* `IRP_MJ_DIRECTORY_CONTROL` (#12870)

* `FileFullDirectoryInformation` (#12908)

* Improve `ClientDriveQueryDirectoryResponse.encode()` (#12912)

* `IRP_MJ_QUERY_VOLUME_INFORMATION` (#13071)

* Fix Shared Directory Request handling when feature is disabled (#13439)

* IRP_MJ_READ, IRP_MJ_WRITE, and IRP_MJ_SET_INFORMATION (#13995)

* Adds constants for sizing calculations (#14051)

Co-authored-by: Łukasz Kozłowski <lukasz.kozlowski@goteleport.com>
Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
2022-08-04 21:50:02 +00:00
Forrest Marshall 142333e509 fix peer addr for in-memory control stream 2022-08-04 09:43:31 -07:00
Tiago Silva 037daad083 Introduce dedicated server type for Kubernetes resources (#14389)
## What

First part of the Kubernetes [Discovery RFD](https://github.com/gravitational/teleport/pull/13376/) to introduce a Kubernetes server per cluster. 

This PR introduces a separate Kubernetes server that uses the already introduced `KubernetesClusterV3`. 

## Compatibility

In previous versions, Kubernetes Clusters were part of regular `ServerV2` resource and this refactoring deprecates the `ServerV2` usage but keeps them for compatibility with previous version.

Everything is backward compatible, so v10 kubernetes agents and trusted clusters can connect fine.

## Next steps

Once this is merged, a new PR will introduce dynamic registration for Kubernetes Clusters discovered through EKS Discovery.
2022-08-04 14:21:11 +00:00
Tobiasz Heller 5485498775 Add custom unmarshal for second_type factor (#15197) 2022-08-04 13:54:02 +02:00
Edoardo Spadolini 54616acce4 Actually use the cache for snowflake sessions (#15085) 2022-08-04 06:35:57 +00:00
STeve (Xin) Huang c596dd7d9b AWS session audit log (#13288) 2022-08-03 19:44:54 +00:00
Edoardo Spadolini 78cab266a2 Don't reset eventID to 0 when out of events in the Postgres backend (#15160) 2022-08-03 17:41:34 +00:00
Joel ebb6682018 Add handshake timeout to RDP connections (#15074) 2022-08-03 15:06:14 +00:00
Alan Parra ca476c4861 Fix the behavior of tsh mfa add --allow-passwordless (#15013)
The `--allow-passwordless` flag was ignored when set, which makes tsh do
non-passwordless registrations. This causes all sorts of confusing behavior.

I'm taking the chance to also add some additional logging to webauthncli.

* Correctly use the value of --allow-passwordless
* Add additional logging to wancli
2022-08-02 19:30:45 +00:00
Noah Stride 071bb116bc Skip cache during CreateBot RPC (#14899)
* Skip cache during CreateBot RPC

* Adjust calls to use .Service rather than .Identity

* Switch to CreateRole from UpsertRole
2022-08-02 13:39:48 +00:00
rosstimothy e499d0961e Tag forwarded spans with custom attributes (#14706)
* Tag forwarded spans with custom attributes

Adds a `teleport.forwarded.for` attribute to a resource or 
all spans that are forwarded to the auth server. This allows 
consumers of the spans to identify where the spans are coming 
from and take possible action. In some scenarios it may
be desirable to drop forwarded spans along the collection 
process, by tagging them we can provide a way for those 
consumers to identify them. It also allows for potentially 
identifying a malicious user that may be trying to spam the 
telemetry backend with spans.

Part of #12241
2022-08-02 12:38:23 +00:00
Matheus 10af7c58ca Fix TestTokenGeneration flakiness (#15090)
Move `proxy.authPack` outside of test loop
2022-08-01 18:32:53 +00:00
925351e5be [OSS-fuzz] Fix FuzzMongoRead (#14807)
Co-authored-by: Marek Smoliński <marek@goteleport.com>
Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
2022-08-01 15:21:11 +00:00
Noah Stride af5e2517de Proxy Protocol support for Proxy SSH listener (#14712)
* Add additional debug logging for instantiation of ssh server conn

* Rough out introducing mux to ssh listener

* Catch errors from multiplexer serve

* Adapt multiplexer to support ProxyHelloSignature

* Adjust logging for ssh conn creation

* Adjust tests to use semantically correct assert/require helpers

* Address PR comments

* Check Client addr is properly propagated in mux test
2022-08-01 14:18:34 +00:00
Marco André Dinis a60d1c0f43 Download mTLS files from Web (#14526)
In the context of Teleport Discover we are trying to ease the usage of Teleport for the user's first interaction.

When adding a new database resource the user must, among other things, generate the mTLS files
Examples:
https://goteleport.com/docs/database-access/guides/postgres-self-hosted/#step-25-create-a-certificatekey-pair
https://goteleport.com/docs/database-access/guides/mysql-self-hosted/#step-24-create-a-certificatekey-pair

This PR aims to reduce this friction: the user should be able to setup the resource without prior setup of local tools (`tsh login`)
We're doing this by providing an endpoint that will return those exact files


Demo
```shell
marco@lenix ~/p/downloadmtls> curl --silent --insecure 'https://127.0.0.1.nip.io:3080/v1/webapi/sites/lenix/sign' --dat
a '{"hostname":"discover.example.com", "ttl":"9999h", "format": "db"}' --header 'Authorization: Bearer 308bf3dd3019ddc4
2cff44a48e028480' --header 'Content-Type: application/json' -OJ
marco@lenix ~/p/downloadmtls> tar -xvf teleport_mTLS_discover.example.com.tar.gz
server.key
server.crt
server.cas
marco@lenix ~/p/downloadmtls> head -1 server.*
==> server.cas <==
-----BEGIN CERTIFICATE-----

==> server.crt <==
-----BEGIN CERTIFICATE-----

==> server.key <==
-----BEGIN RSA PRIVATE KEY-----
```

Fixes https://github.com/gravitational/teleport/issues/14049
2022-08-01 10:14:18 +01:00
Marco André Dinis 89f4d5476a Create and List Connection Diagnostics (#14781)
In Teleport Discover, we want to improve the UX of adding a resource.
We'll suggest users to test accessing a resource, and give them immediate feedback using the UI.

Note: we'll add this feature to Server Access, later one we'll add other resources.

After adding a server resource, the user will be presented with a command to test the connection:
`tsh ssh --test-id=123 user@host`

Running that command will provide the user feedback right in the UI of whether or not it worked.
If not, a short message will be displayed describing why it didn't work and how the user can solve the problem.

---

To achieve this we'll need a couple of changes:
1. new resource that stores the result of trying to connect to a given resource, so that the UI can ask for it
2. change `tsh ssh` to receive the `--test-id` flag and write the result to a record of this new resource

This PR addresses 1 - new resource.

A new resource is created:
```
Connection Diagnostics
- success (bool)
- message (string)
```

Two new rpc methods:
- create connection diagnostics
- read connection diagnostics

One new HTTP Endpoint:
- read connection diagnostics

Related to
https://github.com/gravitational/teleport/issues/13957
2022-08-01 08:49:35 +01:00
Edward Dowling 3e8634cfec Fix chan_shutdown_read issue (#14736) 2022-07-29 18:47:39 +00:00
Edoardo Spadolini 12d2ced3d2 Implicit cache fixes (#14986)
* GetCertAuthority cache bypass fixes

* Bypass the cache for GetUser in WithUserLock

It's is used in places that want the latest version (like registration)

* Actually check the backend in GenerateHostCerts

* Fix windows desktop event parsing and caching

* GetWebSession and GetWebToken shouldn't be cached

Very little would hit those directly, and *auth.ServerWithRoles bypasses
the cache anyway.
2022-07-29 18:18:41 +00:00
Lisa Kim 3a3a0cf8a7 Return nil on success for web UI file tranfers (#15021)
When we download, we write the file contents with the 
`http.ResponseWriter` which is also used to write our 
replies, so it was also writing our success replies.

fixes https://github.com/gravitational/teleport/issues/14557
2022-07-29 17:47:35 +00:00
Tiago Silva 40abd14635 Kubernetes Secret storage for Agent's Identity (#13942)
This MR introduces Kubernetes Secret storage for Teleport Kubernetes Agent state.

When running Teleport Agent inside a Kubernetes cluster where TELEPORT_REPLICA_NAME and KUBE_NAMESPACE exist, the agent will store identities and states in a Kubernetes Secret instead of local storage.

Otherwise, if the above environment variables are not present or not in Kubernetes, the agent persists state in SQLite.

Notes:

Fresh installs will enable the Kubernetes Secret Storage by default.
If PV storage is configured, the agent will store its identity in a Secret and use the PV for non-identity objects.
If the operator is upgrading from an existing release that didn't support Secret storage, the Helm chart will convert the objects to enable Kube Secret Storage. If the current object is a Deployment, the Helm chart installs a new Statefulset side by side and will trigger a Helm hook that is responsible for deleting the Deployment once Statefulset pods are healthy. Otherwise, if upgrading from a Statefulset the agent will read the credentials stored in PV and move them into Kube Secret.

Implementation of #12958
Related to #5585
2022-07-29 13:21:51 +00:00
Noah Stride 3a853cdfd0 Self signed certificates tsh TTL fixes (#14985)
* start work on self signed tsh fixes

* fix go sum

* Adjust error formatting

* Complete less explicit error checks last

* Adjust PR feedback

* Further PR review

* Support darwin and linux certificate errors
2022-07-28 20:43:40 +00:00