Commit Graph
35 Commits
Author SHA1 Message Date
Krzysztof Skrzętnicki 1a184bfbe5 Pass parent context to prompt.Confirmation() in identityfile. (#20685) 2023-01-26 11:09:31 +00:00
Krzysztof Skrzętnicki af5716a9a7 Fix two issues with Oracle MySQL client on Windows. (#20397)
* Add `--defaults-extra-file` as `~/.my.cnf` is not read on Windows.

* Escape `\` as `\\` in paths saved to the config file.
2023-01-24 09:36:47 +00:00
STeve (Xin) Huang b901aced00 Fix "tsh db connect" with "mariadb" when proxy is in seperate port mode (#20353) 2023-01-18 21:04:16 +00:00
Brian Joerger 488af75797 Client store generalization (#19420)
- Add a generalized client store made up of a key, profile, and trusted certs store. Each sub store can support different backends (~/.tsh, identity_file, in-memory). 
- Replace custom identity file handling with in-memory client store.
- Fix issues with trusted certs handling.
2023-01-06 01:34:04 +00: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
Jakub Nyckowski 0ee91f6c37 Enable GCI linter (#17894) 2022-10-28 20:20:28 +00:00
Gavin FrazarandMarek Smoliński ab91963d58 db access denied error message improvement (#16228)
* Fix matchers not being printed in err message

* Add helpful message when access is denied to db connect

* Add test for converting command errors

* Simplify error message when access to db is denied

* Update lib/client/db/dbcmd/dbcmd_test.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Remove unnecessary cmd.Run in test

* Fix import order

* Add full error to message

* Fix formatting of github suggestion

* Add troubleshooting link

* Update troubleshooting link to use subheading

Co-authored-by: Marek Smoliński <marek@goteleport.com>
2022-10-26 12:13:09 -07:00
Gavin Frazar a6c7107ebd handle postgres GSSEncRequest startup message (#17614)
* Recognize GSSEncRequest as postgres proto

* Respond to GSSEncRequest with 'N' for 'not supported' in postgres engine

* Add test for GSSEncRequest to postgres via proxy

* Save gssencmode=disable in .pg_service.conf and test it

* Check for repeated startup encryption request

* Refactor postgres startup test code into its own test

* Test covers all code paths in the proxy startup handler

* Make postgres proxy tests run in parallel

* Reduced test execution time from 15 seconds to 4.5 seconds.
* Ran with race detector and all tests passed.

* Make sure we read at least one byte

* Fix lint

* Fix lint

* Change err to bad parameter

* Update test
2022-10-25 02:35:02 +00:00
Marek Smoliński 7aa224e430 Add Cassandra/Scylla database support (#15895) 2022-10-10 12:37:51 +02:00
Krzysztof Skrzętnicki af7cd0239d Elasticsearch: alternative clients (#16670) 2022-09-29 17:53:49 +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
STeve (Xin) Huang d58740e513 Fix issue "tsh db env" returns error when TLS routing enabled (#16252) 2022-09-16 13:03:44 +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
Brian Joerger 3a5a285883 Generalize private keys in tsh (PIV integration) (#15334)
Primary Changes:
 - Remove reliance on Private Key PEM:
 - Update native and keygen packages to return PrivateKey instead of PEM key
 - Add new PrivateKey interface which implements crypto.Signer
 - Replace PEM encoded private key usage where possible
 - Replace calls to tls.(Load)X509KeyPair with keys.(Load)X509KeyPair in
client packages

Minor Changes:
 - Remove unused agent.AddedKey return from LoadKey
 - Simplify sshutils and removed unused code paths
 - Add ecdsa and ed25519 key support
2022-08-25 23:26:44 +00:00
STeve (Xin) Huang 9b7f023c1f Show proper error message when "tsh db env/config" are not supported (#14971) 2022-08-22 15:56:20 +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
STeve (Xin) Huang cf88c0a283 Capture stderr from "tsh db connect" and reformat redis error (#13843) 2022-07-05 21:25:43 +00:00
Rafał Cieślak a7760a4f71 Teleport Connect: Add SetGatewayTargetSubresourceName RPC (#13476)
* clusters.CreateGateway: Trim spaces when building a CLI command

If cliCommand.Env is empty, the returned command has an empty space at
the front.

* Do not pass TargetSubresourceName when fetching certs for gateway

Since we want to be able to freely specify the db name after the gateway
creation, let's not pass the db name when creating the gateway to show
the intent more clearly.

* Make CLICommand a method on Gateway rather than a field

* Extract getting cluster by resource URI to Storage
2022-06-27 13:43:48 +00:00
STeve (Xin) Huang 188354f95e Remove lib/srv/db/common import from tsh (#13866) 2022-06-25 13:51:58 +00:00
STeve (Xin) Huang 8cb7522aab Mongo clients with serverSelectionTimeoutMS set to 5000 (#13408) 2022-06-24 18:43:18 +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
Jakub NyckowskiandMarek Smoliński 9c046930ff Snowflake integration (#12564)
Add Snowflake integration.

Co-authored-by: Marek Smoliński <marek@goteleport.com>
2022-06-06 17:49:38 +00:00
Jakub Nyckowski b699eee50b Never use --tlsUseSystemCA and --tlsCAFile together with mongosh (#12361)
`mongosh` doesn't support `--tlsUseSystemCA` and `--tlsCAFile` combination passed together and fails CA validation with error when the required CA is not in the system store 
```
MongoServerSelectionError: unable to verify the first certificate
```
This change makes those flags mutually exclusive.
2022-05-02 18:36:44 +00:00
Rafał Cieślak 60f59725a9 Generate DB CLI commands for Teleterm from tsh daemon (#11835)
* Extract dbcmd.go into a new package under lib/client/db/dbcmd

* Use dbcmd to generate CliCommand for gateways

* Return relative db command from tsh daemon

* Add WithTolarateMissingCLIClient func to dbcmd
2022-04-14 08:29:26 +00:00
STeve (Xin) Huang fcd1916e9d Quote postgres connection string for printing to terminals (#11843) 2022-04-11 13:42:33 -04:00
Roman Tkachenko 97c0b5cb83 Add auth'd tunnel mode to tsh proxy db command (#11720) 2022-04-07 18:33:39 +00:00
Marek Smoliński fbd5a2aafd Fix tsh tctl do not load all CAS (#9357) 2022-01-31 13:35:15 +01:00
Jakub Nyckowski bae67b3c95 Add support for MariaDB (#9409)
Add support for MariaDB client and update documentation.
2022-01-10 20:12:31 -05:00
STeve Huang 4e3f795e8f Add --cluster flag to all tsh db subcommands, Add "--diag_addr" flag to teleport db/app start (#9220)
* add diag to teleport db/app start

* db --cluster flag supports

* add some ut and fix issue ~/.tsh get removed during test

* working mongodb

* fix logout

* fix ut

* code review comment

* fix mysql
2021-12-09 11:24:39 -05:00
Roman Tkachenko 9bf88bef01 URL-encode Postgres username in connection string (#8771) 2021-11-01 08:40:06 -07:00
Roman Tkachenko 36998cf566 Add CockroachDB support (#8505) 2021-10-12 14:30:59 -07:00
Roman Tkachenko 6b9726f961 Add MongoDB database access support (#7213) 2021-06-21 22:54:05 -07:00
Roman Tkachenko d67e11ff2d Adding postgres_public_addr and mysql_public_addr (#6426) 2021-04-21 19:52:52 -07:00
Roman Tkachenko 81e1102250 Add MySQL support for database access (#5453) 2021-02-10 11:08:13 -08:00
Roman Tkachenko f7e6838ee5 Refactor postgres service file handling, add db config command (#5319) 2021-01-21 15:21:17 -08:00