Commit Graph
81 Commits
Author SHA1 Message Date
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
rosstimothy c2fc9a9375 Add idle connection timeouts to http clients and servers (#22885)
Sets `http.Server.IdleTimeout` and `http.Client.IdleConnTimeout`
on clients and servers which didn't have them set. A default of
360s was chosen to be on par with the default of an NLB without
being identical.

This was added as another safety measure to prevent leaking any
idle connections indefinitely as seen in #22757.

`apidefaults.DefaultDialTimeout` was also renamed to
`apidefaults.DefaultIOTimeout` to better reflect its usage.
2023-03-10 16:47:06 +00:00
Andrew Burke 4b21199c7d Allow DialProxy to use TLS (#22439)
This change adds support for HTTPS proxies (i.e. `HTTPS_PROXY=https://...`).
2023-03-10 00:05:17 +00:00
Anton Miniailo 3633c6181e Add secure client IP propagation throughout teleport (#21080) 2023-02-28 20:38:12 +00:00
STeve (Xin) Huang 2115f58fec Align AWS assume-role request duration with cert expiration (#21670)
* Limit AWS access AssumeRole duration

* add info header

* add UT

* minor refactor

* beef up user message
2023-02-16 14:57:12 +00:00
24fad0bd0d Use test IP addresses for auth_proxy_test. (#21565)
* Use test IP addresses for auth_proxy_test.

The auth_proxy_test file now uses IP addresses from the block `TEST-NET-3`
as specified in https://www.rfc-editor.org/rfc/rfc5735#section-3. Previously,
it was using `0.0.0.0` IP addresses. This has a chance of actually hitting
locally running services depending on the test runner setup, making the tests
non-deterministic. The hope here is that this change will avoid the spurious
test failures seen in CI.

* Update lib/srv/alpnproxy/auth/auth_proxy_test.go

Co-authored-by: Jakub Nyckowski <jakub.nyckowski@goteleport.com>

* Update lib/srv/alpnproxy/auth/auth_proxy_test.go

Co-authored-by: Jakub Nyckowski <jakub.nyckowski@goteleport.com>

* Update lib/srv/alpnproxy/auth/auth_proxy_test.go

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

* Add in comments about the 203.0.113.0/24 IP range.

---------

Co-authored-by: Jakub Nyckowski <jakub.nyckowski@goteleport.com>
Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2023-02-09 20:08:41 +00:00
Tiago Silva eff2996ad7 Add tsh request search --kind=pod support (#21107)
* add tsh request search pod

* add unit tests

* fill with default values
2023-02-08 14:01:41 +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
STeve (Xin) Huang 315f731978 Fix AWS app access for Java SDK v1 (#20142)
* Fix AWS app access for Java SDK v1

* revert --keystore flag
2023-02-02 14:43:51 +00:00
David Boslee cc36d290a1 Add metrics to track connection ingress (#19734)
* Add metrics to track connection ingress

* Add connection unwrapping

* Add license

* Remove debug logging

* Add ingress reporter tests

* Remove circular dependency

* Fix import formatting

* Missing defer

* Fix spelling of accepted

* Add _total suffix to counters

* Add godocs and fix nits

* Add test for http conn state reporter

* Use loop to unwrap netConnGetters

* Test meterics after http conn closed

* Ensure conns implement conn getter interface
2023-02-01 23:45:34 +00:00
STeve (Xin) Huang 2111f51441 Support assumed roles for "tsh proxy aws" (#20568)
* Support assumed roles for "tsh proxy aws"

* fix typo for RenameHeader

* add error handler

* review comments

* enhance bad parameter

* fix typo

* Forbit requests by assumed role in endpoint url mode.

* fix host check
2023-01-30 21:21:43 +00:00
Tiago Silva dfb353a49c This PR introduces a new ALPN protocol extension forwards proxy connections to a gRPC server with mTLS authentication. (#20808)
Proxy already has a `gRPC` server when using the `teleport-proxy-grpc` ALPN protocol. Still, that server does not impose mTLS auth since it's used by nodes when joining the cluster with dynamic joining methods.

Since we require that the user identity is available in the handler, this PR introduces a new gRPC server that imposes mTLS under the ALPN protocol `teleport-proxy-gprc-mtls`.

Part of #20324
Related to #19573
2023-01-30 15:04:46 +00:00
Marek Smoliński 978fd03a22 Don't use the KubeSNIPrefix SNI TLS Routing Prefix (#20277)
* Don't use the KubeSNIPrefix SNI TLS Routing Prefix

* update ut

* update

* update

* Update

* update
2023-01-30 10:15:18 +00:00
Anton Miniailo 8bbe8fad63 Change signing cert format from PEM to DER for signed PROXY headers (#20146)
That way we can send less data over the connection.
2023-01-13 02:36:09 +00:00
Trent Clarke 777c15450e Fixes code scanning issue 231 (#20119)
Fixes Code Scanning Alert #231 (logging of sensitive information). 

See: https://github.com/gravitational/teleport/security/code-scanning/231
2023-01-12 08:28:33 +00:00
Krzysztof Skrzętnicki e053cba973 GCP CLI support: tsh and tctl changes (#19790) 2023-01-11 16:33:38 +00:00
rosstimothy 54b8fce42b Multiplex Proxy SSH port (#19813) 2023-01-06 11:54:05 -05:00
Gavin Frazar 5bb0ef15db add dynamodb database access (#18843)
* Add a new db engine
* Add tests for new engine
* Update tsh db subcommands
* Refactor error message and suggestions for unsupported tsh commands
* Add dynamodb to test plan
* Add AWS external ID to db config and update protos
2022-12-30 18:22:30 +00:00
Marek Smoliński 18c5d9979a ALPN Proxy change log level for remote client errors (#19478) 2022-12-29 14:05:39 +01:00
Anton Miniailo a039ce1cf9 Add secure IP propagation from teleport proxy to auth server via ALPN (#19008)
* Add secure IP propagation from proxy to auth server when using ALPN

We're using PROXY protocol extensions called TLVs to send
signed JWT and proxy's certificate to the auth server. Auth
validates JWT using provided signing certificate and host CA
to make sure that IP information comes from our internal proxy.
2022-12-23 22:12:42 +00:00
3f52d028fb Dependency updates (#19329)
* Bump go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp

Bumps [go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp](https://github.com/open-telemetry/opentelemetry-go-contrib) from 0.36.4 to 0.37.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go-contrib/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go-contrib/compare/zpages/v0.36.4...zpages/v0.37.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump k8s.io/apiserver from 0.25.4 to 0.26.0

Bumps [k8s.io/apiserver](https://github.com/kubernetes/apiserver) from 0.25.4 to 0.26.0.
- [Release notes](https://github.com/kubernetes/apiserver/releases)
- [Commits](https://github.com/kubernetes/apiserver/compare/v0.25.4...v0.26.0)

---
updated-dependencies:
- dependency-name: k8s.io/apiserver
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump cloud.google.com/go/storage from 1.28.0 to 1.28.1

Bumps [cloud.google.com/go/storage](https://github.com/googleapis/google-cloud-go) from 1.28.0 to 1.28.1.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-cloud-go/compare/pubsub/v1.28.0...storage/v1.28.1)

---
updated-dependencies:
- dependency-name: cloud.google.com/go/storage
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump github.com/schollz/progressbar/v3 from 3.12.1 to 3.12.2

Bumps [github.com/schollz/progressbar/v3](https://github.com/schollz/progressbar) from 3.12.1 to 3.12.2.
- [Release notes](https://github.com/schollz/progressbar/releases)
- [Commits](https://github.com/schollz/progressbar/compare/v3.12.1...v3.12.2)

---
updated-dependencies:
- dependency-name: github.com/schollz/progressbar/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump cloud.google.com/go/iam from 0.7.0 to 0.8.0

Bumps [cloud.google.com/go/iam](https://github.com/googleapis/google-cloud-go) from 0.7.0 to 0.8.0.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-cloud-go/compare/v0.7.0...v0.8.0)

---
updated-dependencies:
- dependency-name: cloud.google.com/go/iam
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump golang.org/x/text from 0.4.0 to 0.5.0

Bumps [golang.org/x/text](https://github.com/golang/text) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.4.0...v0.5.0)

---
updated-dependencies:
- dependency-name: golang.org/x/text
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>
2022-12-16 21:53:25 +00:00
Steven Martin e1ebc332f8 spell fixes (#19419) 2022-12-16 19:01:28 +00:00
Edoardo Spadolini 0597c7d425 Use a blank-ish tls.Config to hit the web listener (#19411) 2022-12-16 09:35:18 +00:00
Edoardo Spadolini 028d809e75 Fix ALPNConnUpgradeDialer when not --insecure (#19398) 2022-12-15 17:44:57 +00:00
STeve (Xin) Huang 72d27ec899 Fix an issue tsh throws assertion error on REDIS_REPLY_STATUS for Redis 7 (#19364) 2022-12-15 14:26:02 +00:00
Krzysztof Skrzętnicki dd67a49ab5 Azure CLI access (#18675) 2022-12-12 19:34:53 +00:00
Zac Bergquist bfbdc2f81a BUGFIX | Teleport ALPN Proxy doesn't respect HTTP CONNECT Proxy (#18993) 2022-12-03 16:20:22 +00:00
Rafał Cieślak 59a96be624 Connect: Check db cert before using it for local proxy (#18740) 2022-11-29 10:11:57 +00:00
Gavin FrazarandRyan Clark 5e1b4528fd Add mutex for certs in local proxy (#18278)
* Add mutex for certs in local proxy

* Update lib/srv/alpnproxy/local_proxy.go

Co-authored-by: Ryan Clark <ryan.clark@goteleport.com>

* Update lib/srv/alpnproxy/local_proxy.go

Co-authored-by: Ryan Clark <ryan.clark@goteleport.com>

* Update lib/srv/alpnproxy/local_proxy.go

Co-authored-by: Ryan Clark <ryan.clark@goteleport.com>

* Move cert checking out of middleware into local proxy

* Configure a logger for local proxy

* Fixup imports

* Add tests for local proxy

* test for data race
* test for cert checking

* Update integration test for local proxy

* Mark err assert fns as helpers

Co-authored-by: Ryan Clark <ryan.clark@goteleport.com>
2022-11-18 00:07:46 +00:00
Gavin Frazar e20173f024 Close local proxy conn if middleware errors (#18242)
* Close connection on middleware error after accepting connection in local proxy

* add comment
2022-11-16 17:15:44 +00:00
Michael Wilson fb3a3362a4 Proritize HTTP/1.1 over HTTP/2. (#17886)
Due to a bug in Chrome, secure websockets in Teleport work intermittently on
the Chrome browser when using HTTP/2. Prioritizing HTTP/1.1 fixes this issue,
though the reasons for this are not 100% clear. When or if
https://bugs.chromium.org/p/chromium/issues/detail?id=1379017 is resolved, we
should be able to revert this. When https://github.com/golang/go/issues/49918
is implemented, we may be able to revert this if enabling HTTP/2 websockets
fixes the issue on our end.
2022-11-01 15:38:50 +00:00
Marek Smoliński d92969e417 Align KubeTeleportProxyALPNPrefix migration comments v12-v13 (#17913) 2022-10-31 13:25:43 +00:00
Jakub Nyckowski 0ee91f6c37 Enable GCI linter (#17894) 2022-10-28 20:20:28 +00:00
Marek Smoliński 8becc1fa85 Align KubeTeleportProxyALPNPrefix migration comments (#15900) 2022-10-27 09:10:53 +00:00
Michael Wilson c98722b116 Ensure that PingConn conform to io.Reader (#17443)
Implementations of io.Reader should return io.EOF directly when the end of
the stream is reached, because callers will compare the error using ==.
2022-10-18 17:45:22 +00:00
Marek Smoliński 7aa224e430 Add Cassandra/Scylla database support (#15895) 2022-10-10 12:37:51 +02:00
Gavin Frazar ba7df65a0c support proxy db tunnel mfa access (#16958)
* Add local proxy middleware for db cert checking

* Use tls conversion util instead of inline

* Add middleware to local proxy config

* Add middleware configuration in tsh

* Use route to database check and set defaults func

* Dont trigger normal db login flow if using local proxy tunnel

* Split out adding client creds into helper func for testing

* Add integration test for local proxy tunnel db cert middleware

* Add unit test for local proxy middleware

* Update comment

* Make middleware on new conn block

* godoc

* Make any cert check error trigger cert renewal in local proxy middleware

* Move dbcertchecker into lib/client

* Remove unneeded mutex in local proxy and unused func in lib/utils

* Make local proxy middleware integration test more robust

* Print message before mfa prompt in proxy tunnel

* Add before prompt option to test

* Remove unneeded comment

* Change local proxy messages to be more clear

* Pass local proxy opts by reference

* Pass certs in opts instead of cert/key file path

This is so we can check if the error is recoverable while preparing
local proxy options. A tunneled local proxy can ignore the error because
it does not rely on cert files - it can just renew its certs if
necessary.

* Move db route checking back to tsh

* Fix lint err

* Fix typo and print the hint to same writer as the mfa prompt
2022-10-07 21:29:51 +00:00
Zac Bergquist 1a62376b78 Fix uses of require in goroutines (#16953)
The require checks from testify call (*testing.T).Fail, which should
only be called from the test goroutine.
2022-10-05 19:14:30 +00:00
Brian Joerger ce20b20753 PIV login enforcement (#15874)
Add private key policy enforcement.

  - Add private key policy cert extensions and enforcement.

  - Add private key policy settings and attestation logic.

  - Wire attestation request through login endpoints.

  - Store attestation data for reissue requests.

  - Add private key policy discovery and logic.

  - Relogin on hardware key policy errors.

  - Include integration with Teleport Connect.
2022-09-30 23:27:48 +00:00
Alan Parra a75fcc21d8 Update golangci-lint to 1.49.0 (#16507)
Update metalinter, fix a few lint warnings and replace deprecated linters.

`deadcode`, `structcheck` and `varcheck` are abandoned and now replaced by [`unused`][1].

Since 1.19, `go fmt` reformats godocs according to https://go.dev/doc/comment. I've done a bulk-reformatting of the codebase to keep the linter happy. Backporting is mostly harmless (the exception being `lib/services/role_test.go`, that for some reason breaks the _old_ linter using the new format).

[1]: https://golangci-lint.run/usage/linters/

* Bump golangci-lint version
* Replace abandoned linters
* Fix bodyclose on lib/auth/github.com
* Fix bodyclose on lib/kube/proxy/streamproto/proto_test.go
* Fix bodyclose on lib/srv/alpnproxy/proxy_test.go
* Fix bodyclose on lib/web/conn_upgrade_test.go
* Silence staticcheck on lib/kube/proxy/forwarder_test.go
* Silence staticcheck on lib/utils/certs_test.go
* Address BuildNameToCertificate deprecation warnings
* Run `go fmt ./...`
* Run `go fmt ./...` on api/
* Ignore formatting in role_test.go
* Remove redundant initializers in lib/srv/uacc/
* Update e/
2022-09-19 22:38:59 +00:00
44b89c75c0 Elasticsearch support (#15768)
Co-authored-by: Anton Miniailo <anton@goteleport.com>
Co-authored-by: Marek Smoliński <marek@goteleport.com>
2022-09-05 18:58:21 +02:00
STeve (Xin) Huang 5a855826ad fix flaky TestProxyMakeConnectionHandler (#16114) 2022-09-05 13:28:30 +00:00
Gabriel Corado ea02952f53 Improve TestPingConnection/ConcurrentReads timeout handling (#16101) 2022-09-02 21:58:52 +00:00
STeve (Xin) Huang 8394f4fb48 ALPN connection upgrade for MySQL behind ALB (#15669) 2022-09-01 16:05:03 +00:00
Gabriel Corado ea71d4e03c Change TestPingConnection/ConcurrentReads assertion. (#15969) 2022-08-30 19:48:51 +00:00
Gabriel Corado 9a90255aa5 Fix ALPN ping connection compilation and test flakiness. (#15878) 2022-08-27 01:04:31 +00:00
Gabriel Corado a3a65e863b TLS routing ping for database protocols (#14887) 2022-08-26 16:42:23 +00:00
STeve (Xin) Huang fac43c5925 Fix an issue tsh aws s3 fails when using path with special characters (#15784) 2022-08-24 18:33:32 +00:00
Roman Tkachenko 38b8bb4307 Add support for proxying TCP apps (#13455)
Add support for proxying tcp apps
2022-07-26 19:01:39 +00:00
Brian Joerger 45c977aea8 Replace ssh proxy execution with crypto/ssh call (#14222) 2022-07-15 00:59:27 +00:00