Commit Graph
5517 Commits
Author SHA1 Message Date
rosstimothy f51d94d3eb Remove reversetunnel.RemoteSite alias (#28758)
The alias can be safely removed now that
https://github.com/gravitational/teleport.e/pull/1761 migrated `e`
to use reversetunnelclient.RemoteSite. The `e` ref was already
bumped in https://github.com/gravitational/teleport/pull/28745
to include the change so only the removal of the alias is needed.
2023-07-06 17:01:56 +00:00
Tiago Silva e06fc88e98 Extend Teleport RBAC to support Kubernetes Verbs (#27096)
* Extend Teleport RBAC to suport Kubernetes Verbs

This PR extends Teleport per-Resource RBAC to support Kubernetes verbs
restriction. With this change it's possible to restrict certain actions
allowed by the underlying `kubernetes_users` and `kubernetes_resources`.

Supported verbs:
- `get`
- `create`
- `update`
- `patch`
- `delete`
- `list`
- `watch`
- `deletecollection`

Fixes #27095

* address timr's comments

* assign wildcard to verbs for role <7

* address marco's reviews
2023-07-06 15:39:11 +00:00
Jakub Nyckowski 784e6197d2 Fix imports on non-linting files (#28752)
Our linter does not run on all files, so the incorrect sorting is not reported, but GCI keeps fixing these imports each time I run it, hence the PR.
2023-07-06 14:32:56 +00:00
Noah Stride 5306331d17 Machine ID: GCP Delegated Joining support (#28663)
* Add GCP joining support to tbot

* Comment SPAG

* Fix imports

* Actually fix imports
2023-07-06 14:16:53 +00:00
Tiago SilvaandJakub Nyckowski c5ac4b40e9 Support GCP joining when google claim is not present (#28651)
Teleport assumes that the `google` claim is present in the identity token that the Teleport service shares with Auth server. This is valid for VMs but it's not valid for GKE clusters using Workload identity and other GCP services. Teleport requests the identity token with `format=full` to receive this enhanced token.

Example of an identity token with a `google` claim:

```json
{
   "iss": "[TOKEN_ISSUER]",
   "iat": [ISSUED_TIME],
   "exp": [EXPIRED_TIME],
   "aud": "[AUDIENCE]",
   "sub": "[SUBJECT]",
   "azp": "[AUTHORIZED_PARTY]",
   "google": {
    "compute_engine": {
      "project_id": "[PROJECT_ID]",
      "project_number": [PROJECT_NUMBER],
      "zone": "[ZONE]",
      "instance_id": "[INSTANCE_ID]",
      "instance_name": "[INSTANCE_NAME]",
      "instance_creation_timestamp": [CREATION_TIMESTAMP],
      "instance_confidentiality": [INSTANCE_CONFIDENTIALITY],
    }
  }
}
```

The problem arises when one tries to use GCP joining for a Teleport service running on a GKE pod. When inside a pod with a binding between the Kubernetes Service account and the Google IAM Service Account, Google's metadata service token does not include the `google` claim. so it fails to join the cluster because of the unknown `project_id`.

To bypass this limitation, this PR extracts the `project_id` from the Google Service Account Email claim
`<service_account_name>@<project_id>.iam.gserviceaccount.com`. We use regex to extract the `project_id` and ensure the email follows the specified format above. Tests were introduced to validate the email.

Fixes #28636

Co-authored-by: Jakub Nyckowski <jakub.nyckowski@goteleport.com>
2023-07-06 12:20:22 +00:00
rosstimothy 336b89158b Fix TestNodeAccess (#28729)
#28499 missed adding the augmented device certificates retrieved from
DeviceLogin to the local agent which causes TestNodeAccess to fail.
This was not caught in #28499 because TestNodeAccess is in `e` and
tests from `e` are not run on `oss` PRs.
2023-07-05 21:44:23 +00:00
rosstimothy a91ad82708 Firestore backend improvements (#28473)
* Test concurrent compare and swaps

The backend test suite was not validating that simultaneous CAS
operations result in only one attempt succeeding. The test now
runs multiple concurrent CAS operations and ensures that only a
single operation succeeds. This shortcoming with the test allowed
the Firestore backend to pass the compliance test while not perfoming
CAS in an atomic manner.

* Firestore backend improvements

1) CAS now utilizes a transaction to ensure the operation is atomic

The original implementation did not use transactions which violated
the atomic guarantees of the CAS operation. The backend compliance
test was able to catch this when it was updated to run concurrent
CAS opertations.

2) Update is limited to updating a value

The original implementation of Update was actually doing a get and
then upsert. However, there are no guarantees that prevent a delete
from occurring between get and upsert, which means Update would
upsert the value instead of failing. Instead of get and then upsert
we now update the document using the (firestore.DocumentRef) Update
method.

3) Watching items from the collection filters out any audit events

If Teleport is configured to use the same collection for backend state
and audit events the collection watcher ends up consuming all audit
events as empty backend items. To avoid this the watcher is now filtering
out any collections which have an empty key since it is not possible
for backend resources to be written without a key this will only
exclude audit events which have a different schema.

4) SearchEvents now filters out backend resources

Similar to above, the Firestore events implementation now excludes
any documents which have an empty session id to prevent backend
resources from getting included in queries for audit events if the
collection is being shared.

* speed up backend test suite

* conditionally delete expired items on get

* fix: cleanup tests
2023-07-05 21:16:29 +00:00
7e6b941dcd Batched Dependabot updates (#28584)
* Bump google.golang.org/protobuf from 1.30.0 to 1.31.0 in /api

Bumps google.golang.org/protobuf from 1.30.0 to 1.31.0.

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

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

* Bump github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue

Bumps [github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue](https://github.com/aws/aws-sdk-go-v2) from 1.10.25 to 1.10.30.
- [Release notes](https://github.com/aws/aws-sdk-go-v2/releases)
- [Changelog](https://github.com/aws/aws-sdk-go-v2/blob/main/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-go-v2/compare/feature/dynamodb/attributevalue/v1.10.25...feature/dynamodb/attributevalue/v1.10.30)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* Bump github.com/sashabaranov/go-openai from 1.10.1 to 1.12.0

Bumps [github.com/sashabaranov/go-openai](https://github.com/sashabaranov/go-openai) from 1.10.1 to 1.12.0.
- [Release notes](https://github.com/sashabaranov/go-openai/releases)
- [Commits](https://github.com/sashabaranov/go-openai/compare/v1.10.1...v1.12.0)

---
updated-dependencies:
- dependency-name: github.com/sashabaranov/go-openai
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

* Bump cloud.google.com/go/container from 1.21.0 to 1.22.1

Bumps [cloud.google.com/go/container](https://github.com/googleapis/google-cloud-go) from 1.21.0 to 1.22.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.21.0...pubsub/v1.22.1)

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

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

* Bump github.com/google/go-attestation

Bumps [github.com/google/go-attestation](https://github.com/google/go-attestation) from 0.4.4-0.20220404204839-8820d49b18d9 to 0.5.0.
- [Release notes](https://github.com/google/go-attestation/releases)
- [Commits](https://github.com/google/go-attestation/commits/v0.5.0)

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

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

* Bump github.com/aws/aws-sdk-go-v2/service/glue from 1.51.0 to 1.53.0

Bumps [github.com/aws/aws-sdk-go-v2/service/glue](https://github.com/aws/aws-sdk-go-v2) from 1.51.0 to 1.53.0.
- [Release notes](https://github.com/aws/aws-sdk-go-v2/releases)
- [Changelog](https://github.com/aws/aws-sdk-go-v2/blob/main/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-go-v2/compare/service/ec2/v1.51.0...service/ec2/v1.53.0)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go-v2/service/glue
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

* Bump google.golang.org/protobuf from 1.30.0 to 1.31.0

Bumps google.golang.org/protobuf from 1.30.0 to 1.31.0.

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

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

* Bump github.com/alicebob/miniredis/v2 from 2.30.2 to 2.30.4

Bumps [github.com/alicebob/miniredis/v2](https://github.com/alicebob/miniredis) from 2.30.2 to 2.30.4.
- [Release notes](https://github.com/alicebob/miniredis/releases)
- [Changelog](https://github.com/alicebob/miniredis/blob/master/CHANGELOG.md)
- [Commits](https://github.com/alicebob/miniredis/compare/v2.30.2...v2.30.4)

---
updated-dependencies:
- dependency-name: github.com/alicebob/miniredis/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* Bump github.com/prometheus/client_golang from 1.15.1 to 1.16.0

Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.15.1 to 1.16.0.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.15.1...v1.16.0)

---
updated-dependencies:
- dependency-name: github.com/prometheus/client_golang
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

* Bump github.com/sigstore/cosign/v2 in /integrations/kube-agent-updater

Bumps [github.com/sigstore/cosign/v2](https://github.com/sigstore/cosign) from 2.1.0 to 2.1.1.
- [Release notes](https://github.com/sigstore/cosign/releases)
- [Changelog](https://github.com/sigstore/cosign/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sigstore/cosign/compare/v2.1.0...v2.1.1)

---
updated-dependencies:
- dependency-name: github.com/sigstore/cosign/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* Bump golang.org/x/sys from 0.9.0 to 0.10.0

Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.9.0 to 0.10.0.
- [Commits](https://github.com/golang/sys/compare/v0.9.0...v0.10.0)

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

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

* Bump github.com/hashicorp/golang-lru/v2 from 2.0.2 to 2.0.4

Bumps [github.com/hashicorp/golang-lru/v2](https://github.com/hashicorp/golang-lru) from 2.0.2 to 2.0.4.
- [Release notes](https://github.com/hashicorp/golang-lru/releases)
- [Commits](https://github.com/hashicorp/golang-lru/compare/v2.0.2...v2.0.4)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/golang-lru/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* Bump golang.org/x/text from 0.10.0 to 0.11.0

Bumps [golang.org/x/text](https://github.com/golang/text) from 0.10.0 to 0.11.0.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.10.0...v0.11.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>

* Bump github.com/elastic/go-elasticsearch/v8 from 8.8.1 to 8.8.2

Bumps [github.com/elastic/go-elasticsearch/v8](https://github.com/elastic/go-elasticsearch) from 8.8.1 to 8.8.2.
- [Release notes](https://github.com/elastic/go-elasticsearch/releases)
- [Changelog](https://github.com/elastic/go-elasticsearch/blob/v8.8.2/CHANGELOG.md)
- [Commits](https://github.com/elastic/go-elasticsearch/compare/v8.8.1...v8.8.2)

---
updated-dependencies:
- dependency-name: github.com/elastic/go-elasticsearch/v8
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* Bump cloud.google.com/go/storage from 1.30.1 to 1.31.0

Bumps [cloud.google.com/go/storage](https://github.com/googleapis/google-cloud-go) from 1.30.1 to 1.31.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/pubsub/v1.30.1...pubsub/v1.31.0)

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

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

* Bump golang.org/x/mod in /integrations/kube-agent-updater

Bumps [golang.org/x/mod](https://github.com/golang/mod) from 0.11.0 to 0.12.0.
- [Commits](https://github.com/golang/mod/compare/v0.11.0...v0.12.0)

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

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

* Bump golang.org/x/net from 0.11.0 to 0.12.0 in /api

Bumps [golang.org/x/net](https://github.com/golang/net) from 0.11.0 to 0.12.0.
- [Commits](https://github.com/golang/net/compare/v0.11.0...v0.12.0)

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

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

* Bump golang.org/x/mod from 0.11.0 to 0.12.0 in /build.assets/tooling

Bumps [golang.org/x/mod](https://github.com/golang/mod) from 0.11.0 to 0.12.0.
- [Commits](https://github.com/golang/mod/compare/v0.11.0...v0.12.0)

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

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

* go mod tidy

* revert attestation and tpm updates

* fix: make grpc

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tim Ross <tim.ross@goteleport.com>
2023-07-05 21:15:42 +00:00
Gus LuxtonandZac Bergquist 8abbea6fec tsh: Implement puttyconfig command to add saved PuTTY sessions to Windows registry (#19316)
* tsh: Implement puttyconfig command to add saved PuTTY sessions to Windows registry

* Addressed comments from code review

* Add support for leaf clusters

* Refactoring from code review

Also moved registry/hostname functions into external packages

* Address more feedback from code review

* Rebase following tsh/common changes

* Fix up putty_config_windows

* Reorder command

* Remove surplus comment

* Use a separate list instead of overloading the 'extra' key

* Address Tim's code review comments

* Address some of Zac's comments

* Refactor formatLocalCommandString to use text/template

* Refactor non-Windows logic into puttyhosts

* Fix subcommand name

* Fix test structure

* Add some more hostnames test cases

* Apply suggestions from code review

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>

* Fix up

---------

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
2023-07-05 17:53:46 +00:00
rosstimothy 119dc7a3a3 Reduce login latency (#28499)
Reuse the root cluster auth client during the login process
to reduce latency.

Closes #26712.
Partially addresses #26712.
2023-07-05 15:51:56 +00:00
public-renovate-gha[bot] e6d8f2bc49 Update RDP Client (#28587)
Co-authored-by: public-renovate-gha[bot] <135069952+public-renovate-gha[bot]@users.noreply.github.com>
2023-07-05 15:04:59 +00:00
Rafał Cieślak 6547a0150f lib/teleterm: Remove misleading error log after LocalAgent.GetKey (#28662)
* lib/teleterm: Remove misleading error log after LocalAgent.GetKey

* Remove unnecesarry check
2023-07-05 12:05:53 +00:00
STeve (Xin) Huang 2cba82cb33 tsh db connect should prefer mongosh (#28539) 2023-07-04 19:47:30 +00:00
Marco André Dinis 37243f8fa4 Script to configure IAM for the DeployService (#28436)
* Script to configure IAM for the DeployService

* use any instead of interface{}

* fix test typo
2023-07-04 15:10:00 +00:00
Gabriel Corado a62b109b87 Move database validation to gRPC methods (#28619)
* refactor: move database validation to grpc

* test(local): update CRUD databases test
2023-07-04 13:39:17 +00:00
Gavin Frazar 4b8567068f improve startup with empty db or discovery config (#28552)
* log a warning when db/discovery service init is skipped but the service is enabled
* dont register discovery service event mapping when init is skipped to avoid log spam waiting on DiscoveryReady event
* fix godoc for DiscoveryReady event
2023-07-03 19:39:38 +00:00
Michelle Bergquist 79754a325d set onboarding survey on user preferences (#28530) 2023-07-03 17:43:06 +00:00
Michelle Bergquist 010076f356 Posthog event for onboarding questionnaire submit (#28328)
* update protos

* create Posthog event for onboarding questionnaire submit
2023-07-03 15:12:38 +00:00
JoelandJakub Nyckowski 490d9d6030 [Assist] Provide interactive updates during agent execution (#27893)
* send progress update messages during agent thoughts

* handle new output format

* define json tags for serialized fields

* use streaming api

* fan streaming from model loop

* fix streaming

* stream progress updates

* Update lib/assist/assist.go

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

* remove useless mute

* nits

* Update lib/ai/model/agent.go

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

* fix merge

* fix misc

* more misc fixes

* what

* what2

* weird eof errors?

* Fix tests UI integration

* Fix other tests

* Linter fixes

* Comment out token counting for assist streams to avoid race condition.

* Fix more tests

---------

Co-authored-by: Jakub Nyckowski <jakub.nyckowski@goteleport.com>
2023-07-03 14:48:06 +00:00
Michael Wilson 4382db5ec1 User groups in access requests will expand list of applications. (#28422)
* User groups in access requests will expand list of applications.

When requesting user groups in an access request, the applications associated
with the access request will now be expanded in the access request, requesting
both access to the group itself along with the associated applications.

* Don't duplicate apps if they're already being requested.

* Add clarifying comments to test, test equivalence against more fields.
2023-07-03 13:50:21 +00:00
Edoardo Spadolini 6e29864ae8 dynamodbbk: don't delete non-expired items on Get (#28519) 2023-07-03 09:28:51 +00:00
Grzegorz Zdunek 3c4ed44a09 Connect My Computer: check permissions before showing in the UI (#28346)
* Move CMC icon and setup document to common `ConnectMyComputer` directory

* Add permissions to show CMC

* Use `cluster.leaf` to check if a cluster is a root cluster

* Rename `isConnectMyComputerPermittedForRootCluster` to `canUseConnectMyComputer`

* Add licenses

* Rename `DocumentSetup` to `DocumentConnectMyComputerSetup`

* Check `cluster.leaf` flag to verify if the cluster is a root cluster

* Do not throw in `canUseConnectMyComputer`

* Add comments

* Use the same field name in a documentation comment

* Use relative import
2023-07-03 08:14:11 +00:00
Zac Bergquist 452da93615 Disable disk-based logger for web tests (#28518)
The web tests don't need disk-based session recording, and they
occaisonally fail due to a race with tempdir cleanup. Fix that
by disabling the disk-based recording.

Closes #13944
2023-06-30 21:11:05 +00:00
Hugo Shaka 303aada16a assist: add classification code (#28221) 2023-06-30 19:25:15 +00:00
Marco André Dinis e043ac07ea AWS OIDC - DeployService: configure IAM (#28088)
* auto configure deployservice iam

* review pt1

* review pt2
2023-06-30 18:35:29 +00:00
Lisa Kim 7fca7f14a9 Web related tweaks for access request user groups (#28455)
* Enable muting tooltip info icon

* Require user group field

* Update snapshot as a result of changing css for tooltip

* Fix user group setting for UI

* Address CR
2023-06-30 18:16:48 +00:00
rosstimothy 20559218ad Fix tsh windows builds (#28357)
#24864 added a dependency of lib/web into tsh which broke windows
tsh builds because lib/web transiently depends on lib/srv which
has linux specific code. This shuffles around a few things so
that lib/web is no longer importing lib/srv at all by:

- Indirectly using the srv.SessionController to apply session
control for web ssh sessions

- Moving the common reversetunnel interfaces into
reversetunnelclient since lib/reversetunnel imports
lib/srv/forward which imports lib/srv.

- Directly converting mysql client errors in the connection
tester instead of calling a common function.
2023-06-30 17:12:12 +00:00
Lisa Kim f6906f330e Discover: Add deployed method field to deploy service event (#28336)
* Define a  deployed_method field to discover deploy event

* Add deployed_method field to expected events

* Add deployed method type and define its field when emitting event from web UI

* Address CR and add another field

* Address CR
2023-06-29 23:36:28 +00:00
Hugo Shaka 698d2330b4 Assist: fix summary logic (#28487)
* Update command.go

* simplify export signature
2023-06-29 22:54:26 +00:00
Jakub Nyckowski 32b7671c2c Refactor websocket termination and stream handling (#28452)
* Refactor websocket termination and stream handling

Refactored websocket stream shutdown and error handling. Replaced `Close()` with `SendCloseMessage()` for better control over the websocket connection termination process. Added checks for the validity of channels to prevent reading from closed channels.
The commit also includes minor typo fixes.

* Remove unused completedC

* Remove unnecessary select blocks in terminal.go

The select blocks used in terminal.go for reading data from channels were unnecessary as we were just pulling from a single channel. Removed the select block and directly attempted to read from the channel. These changes increase code readability and integrity by removing unnecessary select blocks. In the command_test.go, an explanatory comment was added for clarity.

* Remove commented code

* Replace trace.NewAggregate with trace.Wrap as aggregation is not needed.
2023-06-29 19:45:46 +00:00
Tiago Silva a5df89e2f6 Extend Per Kube resource RBAC (#26244)
* Generalize Kubernetes Resource RBAC

This PR generalizes the work introduced by #19613 to other resources
existent in the Kubernetes API.

It allows restricting access to different Kubernetes resources using a
single `kubernetes_group`.

`kubernetes_resource.kind` supports `*` and the following resources:
  * Deployments
  * Statefulset
  * Secrets
  * Configmap
  * DaemonSet
  * Job
  * CronJob
  * Namespace
  * Services
  * Nodes
  * ReplicaSets
  * Roles
  * RoleBindings
  * ClusterRoles
  * ClusterRoleBindings
  * PersistentVolumes
  * PersistentVolumeClaims
  * Ingress
  * Certificates
  * ServiceAccounts

Part of #20811

* address zac's feedback
2023-06-29 17:08:52 +00:00
matheusandEdoardo Spadolini e2ed25c02e Emit default role editor changes (#28209)
* Add editor heartbeat ticker

* Emit all roles instead of only editor

* Revert "Emit all roles instead of only editor"

This reverts commit a29c9f3025.

* Revert "Add editor heartbeat ticker"

This reverts commit 78ee500084.

* (wip) emit event on user create/update/upsert/delete

* Add new event type

* Emit in separate goroutine

* Move EmitEditorChangeEvent to userevents package

* fix import order

* Add EditorChangeEvent to teleport.proto

* Remove new event from usageevents.proto

* Change empty string slice for nil

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

* Use slices.Contains

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

* use var to start string slice

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

* empty string slice -> nil

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

* Log telemetry err instead of returning on err

* Explictly set prevUser to nil on err

* Set prevUser to nil on err

* Update teleport.proto file

* Fix missing dependency

* Remove spawning new goroutine before submitting since it doesnt blocks the thread

* Dont emit event if reading from backend failed

---------

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2023-06-29 16:34:52 +00:00
Justinas Stankevičius 0a5e59ff24 Shut down embedding processor on graceful exit (#28356) 2023-06-29 16:22:21 +00:00
Ryan ClarkandMichelle Bergquist 3b9053faae Introduce user preferences (#28291)
* Add user preferences feature

* Add missing license header

* Fix the order of arguments to require.Equal

* Update lib/web/userpreferences.go

Co-authored-by: Michelle Bergquist <11967646+michellescripts@users.noreply.github.com>

* Add a `GetUserPreferencesResponse` message

* Remove unused logger

* Use .Put instead of .Create/.Update

* Add missing godoc

* trace.Wrap the happy path

---------

Co-authored-by: Michelle Bergquist <11967646+michellescripts@users.noreply.github.com>
2023-06-29 15:43:56 +00:00
Jakub Nyckowski 18a5327699 Remove most t.Log() from tests (#28453)
The t.Log() function calls have been removed from most tests. This is to keep our test logs cleaner and more focused on error messages. Logging every detail in tests makes it harder to spot actual errors and relevant information.
2023-06-29 15:14:09 +00:00
Tobiasz Heller c33b6041aa Replace xitongsys/parquet-go with segment-io lib (#28442) 2023-06-29 14:59:04 +00:00
Jakub Nyckowski c9bf80be65 Improve error handling and embedding prompts; fix typos (#28403)
* "Improve error handling and embedding prompts; fix typos"

This commit encompasses several changes. First, an error handling routine has been added in AssistContext.tsx to properly close a WebSocket connection and finish all results. The intent is to ensure that execution fails gracefully when a session doesn't end normally. In tool.go, user instructions have been made more explicit to ensure users check access to nodes before generating any commands. It warns them that not checking access will cause error. Also, some minor typos were corrected in agent.go and messages.go for better readability.

* "Refactor 'hosts' to 'nodes' in AI Tool Descriptions"

This commit refactors the language from 'host' terminology to 'node' terminology in the AI tool's generated responses as the LLM seems to be confused when generating queries with embeddings.

* Update expected test values in chat_test.go

The expected values in three different tests in chat_test.go have been updated. This change was required because the underlying algorithm has been adjusted and these modifications will keep the tests aligned with the current algorithm's behavior.
2023-06-29 14:41:39 +00:00
Tiago Silva ebecb59468 Replace graviational/oxy.Forwarder with httputil.ReverseProxy (#27761)
This PR replaces the usage of `gravitational/oxy.Forwarder` in our codebase with `httputil.ReverseProxy`.

`httputil.ReverseProxy` is part of Go's standard library and thus it is
 maintained by the Go team. Converting everything to use the std lib
 allows us to drop our `oxy` fork.

 There are some operational changes between the two versions:

 1. `httputil.ReverseProxy` handles WebSockets upgrades internally and
    reuses the `Transport` provided for the initial request. Thus, it does
    not require any special dialer or rewriter mechanisms for WebSockets only.

 2. `httputil.ReverseProxy` calls the `ErrorHandler` with the request
       after it was rewritten and after roundtrip was called. This was a
       problem because our `web.transport` deletes Teleport associated
       cookies and when the request failed, the request received by the
       `ErrorHandler` missed the cookies to generate a new session. This was
       fixed by cloning the request at `web.transport` round tripper.

 3. `httputil.ReverseProxy` uses std's `log.Logger`. `logrus` exposes a
       method `Writer` that allows it to be used with standard lib logger.

The API is similar to what our `oxy` fork has available.

Fixes #27412
2023-06-29 13:50:07 +00:00
Brian Joerger f7bd643652 * Enable headless authentication event watch. (#28234)
* Add WatchPendingHeadlessAuthentications rpc.
2023-06-28 18:03:53 +00:00
Noah Stride 0d3d88156b Machine ID: Add support for BotJoin analytics event (#28293)
* Add support for BotJoin analytics event

* `provision_token_name` -> `join_token_name`
2023-06-28 15:11:07 +00:00
Tobiasz Heller 3df7896643 Fix flaky athena tests (#28283) 2023-06-28 14:32:01 +00:00
STeve (Xin) Huang 3179bc3382 Teleport Proxy Behind ALB support for IP Pinning (#26623)
* Teleport Proxy Behind ALB support for IP Pinning

* move X-Forwarded-For handling to a middleware

* fix where middleware should be nil

* minor refactor based on review comments

* remove TODO and use contains

* use_x_forwarded_for -> trust_x_forwarded_for

* add NoopHTTPMiddleware
2023-06-28 13:09:24 +00:00
STeve (Xin) Huang b38f2b9293 Add omitempty to new ResourceMatcherAWS block for best backwards compat (#28371) 2023-06-28 12:59:45 +00:00
Tiago Silva 73cfb29a08 Support specifying assume_role_arn for Kube cluster matchers (#28282)
* Support specifiying `assume_role_arn` for Kube cluster matchers

This PR allows users to assume different AWS roles when interacting with
AWS EKS API. It allows users to proxy EKS clusters in different AWS
accounts using the same Teleport Kubernetes Service.

Example configuration:

```yaml

kubernetes_service:
  enabled: true
  resources:
  - labels:
      'a': 'b'
    aws:
      assume_role_arn: "arn:aws:iam::0987654321:role/KubeAccess"
      external_id: "0987654321"
  - labels:
      'c': 'd'
    aws:
      assume_role_arn: "arn:aws:iam::123456789012:role/KubeAccess"
      external_id: "123456789012"

```

* reuse eks token validation
2023-06-28 09:36:48 +00:00
Noah StrideandMichael Wilson 2e47bf740d Machine ID: Configuration migration (#27468)
* Introduce new tbot output configuration

* Remove code that will be included in future test refactor PR

* Add config version header

* Fix TestInitSymlink

* Add support for `standard` database type

* Set CA type

* `make fix-imports`

* More closely mimic original database output behaviour

* Make output of additional TLS files for application output optional

* Spell compatability properly

* Add test for config marshalling

* Fix cluster field yaml name

* Fix YAML marshalling/unmarshalling

* Fix sidecar invocation of tbot

* Add WrapDestination helper function to protect wrappedDestination

* Apply changes to sidecar

* Spell Marshalling the way the linter insists

* Fix some logging

* Tidy mutex usage on outputRenewalCache

* Fix ssh_host generation

* TBot Config V2 migration support

* Fix misspelling

* Get rid of `destinationWrapper`

* Single l in Unmarshaling

* Fix operator sidecar tbot

* Add UnmarshalYAML for SSHHostOutput

* Fix migration for removed destinationWrapper

* Use updated KubernetesCluster field name

* Add real world test case for migration

* Add additional migration tests

* Use `KubernetesCluster` instead of `ClusterName` for clarity

* Add additional "real-world" migrations from customer feedback

* Rename `Subtype` -> `Format` for `DatabaseOutput`

* Rename Subtype -> Format for DatabaseOutput

* Remove a very british "u" from Behaviour

* Add godoc for interfacemethods

* Fix double dot in comment

Co-authored-by: Michael Wilson <mike@mdwn.dev>

* Use const for database formats

* Reuse constant type string in Stringer

* Add godoc comment explaining behaviour if no destination found

* Inject executablePathGetter rather than using package level variable

* Use correct case in error

* Add warning for destination reuse

* Try to improve confusing log message

* Remove 'u' from behaviour

* Emit error when v2 config possibly being migrated as v1

* Fix imports

* Ensure they dont overwrite original config

* Remove redundant check

---------

Co-authored-by: Michael Wilson <mike@mdwn.dev>
2023-06-28 09:10:47 +00:00
Grzegorz ZdunekandZac Bergquist bcf6e8fd30 Connect My Computer: Add ACL (#28131)
* Add ACL to Connect

* Apply Zac's suggestions

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>

* Rename `convertToApiResourceAccess`

* Use `recorded_sessions` and `active_sessions` instead of `sessions` to avoid confusion.

Web has two fields for "sessions", and we should have too.

* Reserve "sessions" too

* Rename `ACL` to `acl`

---------

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
2023-06-28 07:34:06 +00:00
Jakub Nyckowski 2b0fb80733 [Assist] Include embeddings in the prompt (#28116)
* [Assist] Include embeddings in the prompt

* Add comments
GCI
Minor fixes

* Move stuff

* Fix tests

* Fix tests

* Fixes after rebase
Apply code review suggestions.

* Address review comments

* After rebase fix
2023-06-27 20:57:20 +00:00
Brian Joerger ea0a2933ac Add username to headless authentication backend key. (#28222) 2023-06-27 16:40:08 +00:00
Hugo ShakaandJakub Nyckowski d386c422eb ai: compute opportinistic summary of command execution (#28033)
* ai: compute opportinistic summary of command execution

* ai: add streaming summary back after rebase on new front-end

* Lint and fix tests pt.1

* reference nodes by name and add tests

* Lint, fix tests and address feedback

* Attempt to tame the stream close monster

* fixup! Attempt to tame the stream close monster

* [Assist] Do not close the WS after command execution (#28246)

* Revert "fixup! Attempt to tame the stream close monster"

This reverts commit 8537aa2163.

* Revert "Attempt to tame the stream close monster"

This reverts commit e0c861df40.

* Do not close the WS after command execution

* Fix tests and lint

* fixup! Fix tests and lint

* undo put web test command into constant

---------

Co-authored-by: Jakub Nyckowski <jakub.nyckowski@goteleport.com>
2023-06-27 16:14:03 +00:00
Noah StrideandEdoardo Spadolini ac9054cb6a Machine ID: Add usage event for bot creation (#28279)
* Add usage event for bot creation

* Update for latest protos from cloud

* Add BotName field to BotCreate event

* Update protos from cloud master

* import order

* Use `ClientUsername`

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

---------

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2023-06-27 14:29:01 +00:00