Commit Graph
23 Commits
Author SHA1 Message Date
Zac Bergquist f3c107b8c0 Modernize lib/client, lib/service, and lib/services (#55978) 2025-06-23 01:31:21 +00:00
Lisa Kim a2e401650b Partial revert of CSRF auth related removals (#53367)
* Partial revert of CSRF auth related removals

Required to support backwards compatibility of the enterprise
plugin endpoint.

* Remove CSRF checking in header

* Address CR

* Inline helper funcs
2025-04-01 20:32:04 +00:00
Lisa Kim d5409cb481 Create v2 web api endpoints and required related changes (#50472) 2025-01-09 19:58:52 +00:00
rosstimothy 60aaa6dc1a Convert lib/client to use slog (#50498) 2024-12-23 18:46:43 +00:00
fheinecke b178b8b732 Updated Teleport codebase to AGPL3 license (#35259)
Signed-off-by: Fred Heinecke <fred.heinecke@goteleport.com>
2023-12-01 17:48:14 +00:00
rosstimothy 1c3188a38a Add a dedicated client to communicate with the Proxy SSH server (#22629)
A new `api/client/proxy/Client` has been added to interact with
the SSH and gRPC servers that the Proxy serves on its SSH port.
The client will first try connecting to the gRPC server and if
that fails it will fall back to the SSH server.

Much of the SSH functionality mimics the existing behavior of the
`ProxyClient` in `lib/client`. This is the first part of phasing
out that client in favor of the new client. There will be a follow
up PR that migrates `lib/client` to make use of the new client instead.

Part of #19812
2023-03-15 13:41:56 +00:00
rosstimothy fa3bb9ac59 Ensure that the webclient closes connections (#22832)
The `http.Client.Transport` created in `newWebClient` wraps a
chain of `http.RoundTripper` over an underlying `http.Transport`.
Since we cannot guarantee that each `http.RoundTipper` has a
`CloseIdleConnections` method the usage of
`defer clt.CloseIdleConnections()` does not guarantee that the http
connections created during Find/Ping/etc are closed.

To prevent leaking connections implementations of `http.RoundTripper`
have added a `CloseIdleConnections` method added that forwards the
request on to the wrapped interface. The `otelhttp.Transport` does
not implement this method either so care has been taken to wrap it
in a `http.RoundTripper` which will call the root transport in
`enforceCloseIdleConnections`. An upstream issue has been filed
with otelhttp: https://github.com/open-telemetry/opentelemetry-go-contrib/issues/3543
to get the method added to their `Transport` implementation.

This wasn't noticed prior to upgrading to go1.20 becuase prior to
[this](https://github.com/golang/go/commit/4e7e7ae1406c70d9cc0809ec11105a55a60a0b70)
commit the `ReadHeaderTimeout` set on the Proxy web api http.Server
would cause the connection to appear idle and get terminated by the
server.

`TestWebClientClosesIdleConnections` was added to capture the leak
in connections as reported in #22757 and prevent any regressions.
2023-03-10 15:21:16 +00:00
Vitor Enes f32a27ca17 Optimize PostJSONWithFallback (#20077)
This commit optimizes `PostJSONWithFallback` by not requiring it to
parse the endpoint (to determine if the host is loopback) if HTTP
fallback is not allowed in the first place.
2023-01-12 13:58:11 +00:00
Vitor Enes d72ac18247 Set extra proxy headers in all tsh HTTP requests (#19766)
Before this commit, the `tsh` HTTP requests that had the extra headers
were those that did not use `roundtrip`.
This commit leverages `http.RoundTripper.RoundTrip` to ensure that all
requests have the the extra headers.
2023-01-11 10:29:05 +00:00
Jakub Nyckowski 0ee91f6c37 Enable GCI linter (#17894) 2022-10-28 20:20:28 +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
rosstimothy 1973fcee24 Span improvements (#15388)
* Add spans to TeleportClient/ProxyClient/NodeSession

* Improve dialer tracing

* Alter default http client span name to include path

* propagate tracing options in NewClientConn
2022-08-18 21:29:03 +00:00
rosstimothy 80d6bff4e5 Add auto instrumentation to http and grpc clients and servers (#12231)
Leverage otelhttp to generate spans for http clients and http handlers.
Additionally add spans for grpc clients and servers by using the
otelgrpc interceptors. This is step one in implementation of RFD 65.
Until further work is done, the spans generated will be a no-op
until the tracing provider is initialized.
2022-05-03 15:55:31 -04:00
Andrew Burke e3a8fb7a0f NO_PROXY port support + special case for proxying via localhost (#11403)
This change updates NO_PROXY handling to allow blocking specific host:port combinations, rather than just the host. It also adds a special case for downgrading requests to plain HTTP when --insecure is true and the request goes through a plain HTTP proxy at localhost (i.e. HTTP_PROXY=http://localhost).
2022-04-04 14:23:50 -07:00
Andrew Burke 4543bfd98d Respect HTTP_PROXY/HTTPS_PROXY (#10209)
This change allows tsh to use HTTP proxies when HTTP_PROXY/HTTPS_PROXY is set in the environment.
2022-03-23 19:58:19 +00:00
Trent Clarke e1b2a267a9 Allow login over plain http in restricted situations (#7835)
This patch will allow the web api to (optionally) fall back from HTTPS
to HTTP under very particular circumstances:

  1. The appropriate `insecure` flag was set, and
  2. The target host is the loopback

If both conditions are met, this patch will allow the WebAPI client to
fall back to plain HTTP when attempting to login to the auth server.
2021-09-17 19:47:03 +10:00
Lisa Kim 7a7502bd2f Allow deleting/listing MFA devices with recovery tokens (#8197)
- Implemented `DeleteMFADeviceSynce`, which takes in a token 
  that allows users to delete devices during the recovery process
- Refactored `GetMFADevices` to take in recovery token
- Pulled out deleting MFA device (from stream version) into helper func to be re-used
- Added delete MFA web handler
2021-09-14 13:28:22 -07:00
Russell Jones 064038a6d3 Propagate cancelation context. 2018-10-12 17:42:37 -07:00
Russell Jones 6439f7f973 Support configurable cipher suites. 2018-07-23 10:29:28 -07:00
Russell Jones 87010f5239 Revendor github.com/gravitational/roundtrip and enable sanitizer on it. 2018-06-02 00:38:46 +00:00
Russell Jones 5d5c3de588 Updated TLS ciphersuites and updated SSH ciphers, KEX, and MAC
algorithms in forwarding server.
2018-05-25 21:29:33 +00:00
Russell Jones 2f70866e5a Added TrustedCluster resource. 2017-03-09 13:49:44 -08:00
Ev Kontsevoy 225a9a4d4c Moved HTTP client code from lib/web into lib/client
The purpose of this commit was to remove the lib/client dependency of
lib/web.

lib/client must be dependency-free in order to be reusable.

Next step: make the web UI use the same client code as the CLI. This
will remove a ton of duplicate code making Teleport audit surface area
much smaller.
2017-02-02 18:48:50 -08:00