Commit graph

1229 commits

Author SHA1 Message Date
STeve (Xin) Huang 286b8108b1
AWS Athena ODBC driver support for App Access (#19649) 2023-01-10 18:24:49 +00:00
Grzegorz Zdunek 584e96efe0
Report Connect usage events (#19564) 2023-01-10 18:17:21 +01:00
Hugo Shaka 44f57bf346
Add hidden cli command: wait-no-resolve (#19277)
Part of https://github.com/gravitational/teleport/pull/18274

This commit introduces a new hidden `wait` CLI subcommand:

- `teleport wait no-resolve <domain-name>` resolves a domain name and exits only when no IPs are resolved. This CLI command should be used in the Helm chart, as an init-container, to block proxies from rolling out until all auth pods have been successfully rolled-out.

- `teleport wait duration 30s` has the same behaviour as `sleep 30`. Due to image hardening we won't have `sleep` available, but waiting 30 seconds in a preStop hook is required to ensure a 100% seamless pod rollout on kube-proxy-based clusters.
2023-01-10 16:46:00 +00:00
Gavin Frazar ef43b4cef9
azure mysql and postgresql flex server discovery (#19759)
* Move GCP cloud clients into a separate interface
* Add azure mysql/postgresql flex server support
* Add teleport db configure create support for azure postgres/mysql flex servers
* discover both single and flexi server with 'mysql' and 'postgres' db types.
* go doc gcp interface
* Add is_flexi_server to database Azure config
2023-01-09 18:48:08 +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
Tiago Silva 40861809a6
Add RoleV6 resource type (#19324)
This PR includes a new Role resource version that is compatible with V5 spec.

The new resource introduces the `kubernetes_resources` definition that allows operators to limit the Kubernetes resources that each member can access. The `kubernetes_resources` entries must follow the following format: `{"kind":"<kind>", "namespace":"<namespace>","name":"<pod>"}`. Currently, it only supports objects of `kind` `pod`. Valid examples `<namespace>/<name>:
- `*/*`: matches all pods in all namespaces.
- `default/*`: matches all pods in the `default` namespace.
- `*/nginx-*`: matches every pod prefixed with `nginx-` in every namespace.

For older resource versions - V5, V4, V3 - `kubernetes_resources` is automatically populated with `{"kind":"pod","namespace":"*","name":"*"}` to keep compatibility. For the newest version, it's mandatory to define its value otherwise access to pods will be denied.

Part of #18434
2023-01-05 09:58:12 +00:00
Jakub Nyckowski d68cb9377b
Switch golang.org/x/crypto to gravitational fork (#19579)
* Switch golang.org/x/crypto to gravitational fork

* Update golden files

* Add comment to go.mod

* Update api module to use crypto fork.

* Move x/crypto to replaced section in dependabot.yml
2023-01-04 19:30:58 +00:00
Anton Miniailo d7f304f164
Fix flaky tsh test 'TestList' (#19843) 2023-01-04 18:04:58 +00:00
Anton Miniailo 10dee1a24b
Fix listing all nodes in tsh (#19796)
* Fix listing all nodes in tsh

Usage of channels was flipped, we tried to write to collecting channel,
but nobody was reading from it, so we blocked forever. Now using simpler
version with mutex for synchronization, and doing it for db listings as
well for consistency.
2023-01-03 22:58:57 +00:00
Steven Martin 331989dadf
Add in allows ignoring missing DB CLIs like mysql which not all users have (#19762) 2023-01-02 11:01:34 +00:00
Forrest Marshall ecef3465b6 instance heartbeats 2022-12-30 12:09:11 -08: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
Zac Bergquist cfb40186e1
tctl: add edit command (#18826)
This command allows you to modify a resource in place by opening
the resource YAML in your text editor.

The editor is selected by checking the following, in order of
precedence:

- the TELEPORT_EDITOR environment variable
- the VISUAL environment variable
- the EDITOR environment variable
- defaulting to 'vi'

We also prevent renaming resources with this command.
See gravitational/webapps#1465 where we do the same for the web UI.
2022-12-29 17:30:14 -07:00
Tiago Silva c3fe7c092f
Update Kubernetes Dependencies (#19695)
This PR replaces the following PRs opened by dependabot:
- #19678 
- #19677 

It also bumps:

- Bump k8s.io/api from v0.25.4 to v0.26.0
- Bump k8s.io/apiextensions-apiserver from v0.25.4 to v0.26.0
- Bump k8s.io/apimachinery from v0.25.4 to v0.26.0
- Bump k8s.io/apiserver from v0.25.4 to v0.26.0
- Bump k8s.io/cli-runtime from v0.25.4 to v0.26.0
- Bump k8s.io/kubectl from v0.25.4 to v0.26.0
- Bump k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed to v0.0.0-20221128185143-99ec85e7a448
- Bump sigs.k8s.io/controller-runtime from v0.13.1 to v0.14.1
2022-12-29 22:49:22 +00:00
Steven Martin 8fe2a74d02
Make Kubernetes capitalization consistent across cli (#19650) 2022-12-27 16:11:11 +00:00
Jakub Nyckowski 98d8a30959
Add t.Parallel() to tsh tests (#19595)
Run tsh tests in parallel.
2022-12-23 20:28:15 +00:00
Steven Martin 9afffee6ed
include Kubernetes in tsh join description (#19646) 2022-12-23 15:00:38 -03:00
STeve (Xin) Huang 39cee50cc9
Fix Too many requests error in github actions test (#19606) 2022-12-23 03:47:02 +00:00
Russell Jones 431d6e486e Added documentation for Access Requests TTLs.
Added documentation for Access Requests TTLs.

Co-authored-by: Paul Gottschling <paul.gottschling@goteleport.com>
2022-12-22 14:52:26 -08:00
Vitor Enes 87f706d0ec
Track active migrations in Prometheus and tctl top (#19520)
This commit adds a new Prometheus gauge `teleport_migrations` that
tracks for each migration if it is active (1) or not (0).

This gauge is then leveraged in `tctl top` to show a set of active
migrations.
2022-12-22 19:37:44 +00:00
Vitor Enes 693b164897
[buddy] Error if TTL in tctl auth sign is too long (#19563) 2022-12-22 18:46:43 +00:00
Krzysztof Skrzętnicki 71b19fa61d
Implement teleport app start --cloud=... flag. (#19331) 2022-12-22 11:02:19 +01:00
Marco André Dinis adcdc2459f
Add DatabaseService heartbeat (#19570)
n the context of Teleport Discover, we must be able to known if there's any DatabaseService available to proxy a given Database resource.
If there's none available, we will offer a script for the user to run and install a DatabaseService which proxies the desired Database resource.

By DatabaseService, we mean the process that Teleport binary manages when the `teleport.yaml` config has the following section:
```yaml
db_service:
  enabled: "yes"
```

To accomplish this we are creating a new resource: DatabaseService.
The UI will fetch all DatabaseServices and check if there's any ResourceMatcher that matches the DatabaseLabels.

Previous PRs created the DatabaseService resource and its CRUD methods.

This PR adds an heartbeat for DatabaseServices similar to what we have for Databases.
There's also a new command to list DatabaseServices using `tctl`:
```
$ tctl get db_service --format text
Name                                 Resource Matchers                      
------------------------------------ -------------------------------------- 
a6065ee9-d5ee-4555-8d47-94a78625277b (Labels: <all databases>)              
d4e13f2b-0a55-4e0a-b363-bacfb1a11294 (Labels: env=[prod],aws-tag=[xyz abc]) 
```


Test using Teleport Cloud
```
dinis@lenix ~/p/cloudagents> tctl get db_services
kind: db_service
metadata:
  expires: "2022-12-21T18:05:10Z"
  id: 1671645310983808522
  name: 2a28d394-900c-42ea-a120-eed918e4526b
spec:
  resources:
  - labels:
      aws-tag:
      - xyz
      - abc
      env: prod
version: v1
dinis@lenix ~/p/cloudagents> tctl status
Cluster  marcoacme.cloud.gravitational.io                                        
Version  12.0.0-dev 
```

Part of #19032
Related #19363 #19469
2022-12-22 09:19:02 +01:00
rosstimothy 3845f5b000
Fix TestExportingTraces race (#19592) 2022-12-21 23:12:29 +00:00
rosstimothy 579a453db2
Allow custom trace exporter for tsh (#19405)
* Allow custom trace exporter for tsh

Trace forwarding via `tsh --trace` only works to date if Auth is
configured with the `tracing_service` enabled. In all other scenarios
the traces are still forwarded to Auth but are silently dropped.
This makes it difficult to capture valuable traces from customers
with latency issues as they are first required to setup a Telemetry
backend and enable tracing in their cluster.

A new `--trace-exporter` flag is added to `tsh` to make it possible
to direct traces from `tsh` to a file or local instance of jaeger
without hacing to modify their Teleport cluster. The url must follow
the same semantics as the config file equivalent.

One important caveat is that **only** the `tsh` spans will be captured.
Any corresponding `teleport` spans are exported acording to the
`tracing_service`. While this only paints half the picture, it is
still a good indicator of where `tsh` may be experiencing latency.

An example usage to send traces to local files:

```bash
tsh --trace --trace-exporter=file:///some/path/traces ssh user@foo
```
2022-12-21 18:40:52 +00:00
Alan Parra 82e6fb9269
Wire device authentication into tsh (#19436)
Wire device authentication into `tsh`, so it attempts to acquire device
certificates after user login. This affects direct logins (`tsh login`),
indirect logins (RetryWithRelogin) and Connect.

If authentication fails (non-Enterprise cluster, device not enrolled, etc) `tsh`
proceeds as usual, but the final user certificate won't contain device
extensions.

gravitational/teleport.e#514
2022-12-20 20:53:45 +00:00
rosstimothy 66b65dd2d7
Reduce latency of tsh ls -R (#19438)
* Reduce latency of `tsh ls -R`

Listing nodes across clusters was done one cluster at a time. To
improve latency the same mechanism used by `tsh db ls -R` was copied
to ensure listing happens in parallel with an upper limit.
2022-12-16 22:17:12 +00:00
rosstimothy 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
Jakub Nyckowski 9c80f3802e
Enable nolintlint linter (#19406)
* Enable nolintlint linter

* Fix nolint comments in the api package

* Fix RDP client comment

* Address review comment

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

* Allow unused for nolintlint linter

* Remove redundant casting

* Add comment on why allowed unused is enabled

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

Co-authored-by: Alan Parra <alan.parra@goteleport.com>
2022-12-16 21:13:58 +00:00
Steven Martin e1ebc332f8
spell fixes (#19419) 2022-12-16 19:01:28 +00:00
Tiago Silva 129ae1d058
Set SNI when tsh login --format kubernetes is invoked (#19422)
Fixes missing Server Name Identifier when `tsh login --format kubernetes` is invoked against a cluster with `ProxyListenerMode=multiplex`.

Fixes #19312
2022-12-16 15:36:28 +00:00
Russell Jones 7895fddc57 Added the ability to supply Access Request TTLs
Added the ability to specify two CLI flags for Access Requests:
"--request-ttl" and "--session-ttl".

Updated "CreateAccessRequest" to adhere to the following rules.

If an Access Request does not have a TTL set (expiration time
types.AccessRequest resource itself), a default of 1 hour is used. Next,
the request value is truncated by the lifetime of the certificate,
requested expiration, and then strictest session TTL on all roles
requested.

Similar logic is followed for the expiration time of the elevated
certificate that will be issued if the Access Request is approved. First
the requested value is truncated by the lifetime of the certificate,
requested expiration, and then strictest session TTL on all roles
requested.

The output of "tsh requests ls" and "tctl requests ls" has been updated
to display the TTL values.
2022-12-14 15:18:33 -08:00
Steven Martin 69693f80e3
Use Teleport proxy,user references instead of SSH specific (#19339)
* Change to use Teleport proxy and user instead of just SSH proxy

* Update play command include SSH, Kubernetes and App
2022-12-13 16:22:09 -06:00
Krzysztof Skrzętnicki dd67a49ab5
Azure CLI access (#18675) 2022-12-12 19:34:53 +00:00
STeve (Xin) Huang 43529b2653
AWS Redshift Serverless auto-discovery (#18974) 2022-12-09 21:23:56 +00:00
Alan Parra d5e329e9ea
Add tsh device debug commands (#19166)
Add `tsh device collect` and `tsh device keyget`, which are useful to debug
device trust functionality.

gravitational/teleport.e#514
2022-12-09 10:38:52 -03:00
Alan Parra 29166a56b7
Add the tsh device enroll command (#19108)
Wire the device enrollment ceremony, implemented by lib/devicetrust/enroll, to
`tsh`.

gravitational/teleport.e#514
2022-12-07 19:46:39 +00:00
Christopher Cooper 9c2192ebb6
Prepare sql server kinit authorization (#18299) 2022-12-06 22:55:20 +00:00
Matheus f48d7f3c4f
Add recovery codes flag to modules and web config (#19046)
* Add recovery codes feature to modules and web config
* Add EnableRecoveryCodes to Modules interface
2022-12-06 18:07:33 +00:00
Hugo Shaka 4f89756d8b
Add --apply-on-starup flag (#19009) 2022-12-06 15:50:52 +00:00
Jakub Nyckowski 9379243390
Use pre-generated RSA keys in tests (#18750)
Many of our tests (db package, I'm looking at you) generate many RSA keys. This has two main side effects; makes our tests slow and flaky as CPU usage spikes in random moments when the tests are run in parallel.
This change pre-generates RSA keys at the beginning of each test module and reuse them in randomized order to reduce the situation that one key has been used multiple times in one test.
I had to move a few files to avoid circular dependencies.
2022-12-05 19:33:49 +00:00
Marco André Dinis 8bdcd197f1
Add separation between keys when exporting CAs (#18562)
Adding a new line was sometimes not enough to separate the keys.

This was causing our tests to sometimes fail.
2022-12-05 11:11:59 +00:00
Hugo Shaka f0dd7d7d85
Kubernetes joinMethod (#18659)
This commit adds a new joinMethod as described in https://github.com/gravitational/teleport/pull/17905

This method allow pods running in the same Kubernetes cluster than the auth servers to join the Teleport cluster. It relies on Kubernetes tokens to establish trust. The goal is to be able to deploy proxies and auths separately and join them in a single cluser.

Pre Kubernetes 1.20, the tokens are static, long-lived, not bound to pods. We support them for compatibility reasons. Starting with Kubernetes 1.20, tokens are bound to pods (and starting with 1.21 they can be mounted through projected volumes). Starting with 1.21 we should only accept bound tokens. The chart will ensure tokens are properly mounted with projected volumes so we can benefit from the 1h to 10min token lifetime.
2022-12-02 20:30:52 +00:00
Vitor Enes a566bd8018
Ensure tctl windows_desktops ls produces expected output (#18779)
This commit ensures that `tctl desktops ls --format json|yaml` outputs a
list of `windows_desktop` resources. Note that `tctl desktops ls`
displays additional information that is only present in the
`windows_desktop_service`.

With `tctl windows_desktops ls --format json` now we get something like the
following:
```json
[
    {
        "kind": "windows_desktop",
        "version": "v3",
        "metadata": {
            ...
        },
        "spec": {
            ...
        }
    },
    ...
]
```

`tctl windows_desktops ls --format text` now also displays the same information
as `tctl get windows_desktop --format text` (removing all the info about the
`windows_desktop_service`):

```bash
❯ tctl get windows_desktop --format text 
Name                        Address           AD Domain   Labels 
--------------------------- ----------------- ----------- ------ 
EC2AMAZ-QME01PL-example-com 172.31.4.209:3389 example.com        

❯ tctl windows_desktops ls             
Name                        Address           AD Domain   Labels 
--------------------------- ----------------- ----------- ------ 
EC2AMAZ-QME01PL-example-com 172.31.4.209:3389 example.com      
```
2022-12-02 18:25:57 +00:00
Brian Joerger a3bd4650d0
Provide proxy address when beginning a node session (#18579) 2022-12-02 01:56:22 +00:00
STeve (Xin) Huang f2cf36a450
AWS Redshift Serverless engine support (#18651) 2022-12-01 15:36:48 +00:00
Sam Freiberg 0389b484b3
Securely delete OTP QR code (#18752) 2022-11-29 22:08:55 +00:00
Vitor Enes 5a4e67027c
Improve tsh play JSON & YAML output (#18768)
Before this commit, events in the output of `tsh play --format=yaml` were
separated by a newline. This commit ensures that these events are now
separated by `---`, allowing the command output to play well with `yq`.

For consistency, the output of `tsh play --format=yaml <session-id>`
now mirrors what we get e.g. with `tctl nodes ls --format=yaml`.
The same applies to `tsh play --format json`.
2022-11-28 19:36:04 +00:00
Vitor Enes 3031147920
Add tctl windows_desktops as the default and keep tctl desktops as an alias (#18769)
Before this commit, users would `tctl get windows_desktop/<name>` and
`tctl desktops ls`. For consistency, `tctl windows_desktops ls` is now
the default but `tctl desktops ls` is kept as an alias for backwards
compatibility.
2022-11-28 17:57:14 +00:00
Gabriel Corado fa15a7c4c4
Azure SQL Server auto discovery (#17745) 2022-11-28 15:02:49 +00:00