Commit Graph
793 Commits
Author SHA1 Message Date
Forrest da5945e7fc preserve explicit local auth disable (#15454) 2023-02-24 03:23:31 +00:00
matheus 50f2796207 Add isDashboard to web config object (#20830)
* Add isDashboard to web config

* Update config.js with the new field

* Remove debug log

* Remove debug log (2)

* Improve godocs

* Remove debug log(3)

* Improve godoc

* Improve godocs

* Update godoc

* Update comment

* Improve comments/godocs and rename method
2023-02-23 19:03:51 +00:00
d89879c2f5 Add gRPC service definition for Plugin resources (#21750)
* Add plugin exchange service

* Add Plugin methods to auth

* Add gRPC-layer methods for Plugin

* Add RBAC presets for Plugin

* Test GetPlugin()/NoSecrets access

* Make error assertions more correct in role test

* Deny setting credentials if user can not read them

* gofmt

* Apply minor suggestions from code review

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>

* Move dependency into an existing block in go.mod

* Improve error messages for failed type assertions

* DRY WithSecrets access checks for Plugins

* Run new tests in parallel

* Improve error assertions in auth_with_roles_test

* TestGetPluginWithSecrets: split cases to subtests

* Clean up test servers and clients

* Add proto for plugin service

* Remove Plugin methods from auth service

Moved to a dedicated service

* Remove plugin-related auth methods

Moved to a dedicated service in Enterprise

* Remove CreatePlugin test from auth_with_roles_test

Moved to a dedicated service in Enterprise

* Pass "backend getter" to local plugins service

This pattern is used in Enterprise to set up secondary services
before auth (and backend) are created.

* Rename InitialCredentials to BootstrapCredentials

* Add plugins service to genproto.sh

* Reformat generated proto

* Remove obsolete PluginExchangeService

The equivalent of this is now in Enterprise

* Add kube service to genproto.sh; regenerate

* Add ListPlugins to plugin backend service

* Reimplement GetPlugins on top of ListPlugins

This is a "convenience" implementation for the backend service layer.

* Replace GetPlugins with ListPlugins in gRPC schema

* Fix ListKubernetesResources unit test

* Simplify plugin pagination key to just the name

* Use existing constant for page size

* Make dummy clients return errors instead of panic

* Remove obsolete field

* Ensure go.mod is valid for corresponding e changes

* Fix passing mutex ref

* Move teleport-plugins import to e_imports

* Revert oauth change in go.mod

* Use limit+1 to look-ahead when paginating plugins

* Test plugin pagination with pageSize > numPlugins

* Add descriptive messages to gRPC dummy clients

* Plugin: add RW for editor; remove secrets from gRPC

* Make message more descriptive for dummy gRPC conn

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>
2023-02-23 14:32:41 +00:00
Hugo Shaka 8cec3828db operator: reconcile Users with standard Teleport reconciler (#21512)
* operator: reconcile Users through Teleport reconciler

* fixup! operator: reconcile Users through Teleport reconciler
2023-02-23 14:15:05 +00:00
Michael Wilson 9527b6518c User group API and cache. (#21956)
The user group has been added to the API and to the cache.
2023-02-22 18:45:11 +00:00
Edoardo Spadolini 317833b9f2 Add new reporting license flag (#21928)
* Partially revert 09633dd47f

* Hide old features from String, add comments

* Add new reporting license flag

* Add testing

* add comment to LicenseV3/LicenseSpecV3

* Less ambiguous name for the new field

* Elaborate more on the unused flags
2023-02-22 15:43:58 +00:00
Michael Wilsonandrosstimothy 2249d1cc17 SAML IdP sessions added to the API and cache. (#21937)
* SAML IdP sessions added to the API and cache.

SAML IdP sessions have now been added to the API and to the cache.

* Update lib/auth/sessions.go

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

* Revert changes to types.proto.

* Fix missing session ID, misnamed variable, gRPC update.

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2023-02-21 17:26:10 +00:00
rosstimothy 920261cd1f Add DatabaseService KeepAlive type (#22042)
The DatabaseService was using the KeepAlive_Database type instead
of a new dedicated type. This caused the keepalive to fail because
the backend key that was created didn't actually exist which results
in #21454.

This adds the appropriate KeepAlive type and uses it in the appropriate
places.

Fixes #21454
2023-02-21 14:55:06 +00:00
rosstimothy 9440763235 Implement transport client (#21947)
Provides a client that can be used to connect to and interact with
the transport service in `lib/srv/transport`. The client abstracts
the fact that a gRPC stream is being used for the `net.Conn` created
by `DialCluster` and `DialHost`.

This also moves `lib/utils/grpc/stream` to `api/utils/grpc/stream`
so that the client and server can make use of the same stream
abstractions.

Part of #19812
2023-02-21 14:38:57 +00:00
dependabot[bot] c0b2263456 Bump golang.org/x/net from 0.6.0 to 0.7.0 in /api (#22010)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.6.0 to 0.7.0.
- [Release notes](https://github.com/golang/net/releases)
- [Commits](https://github.com/golang/net/compare/v0.6.0...v0.7.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-17 20:30:26 +00:00
0db64bbabe Fix Moderated session on leave pause action. (#21366)
* Fix Moderated session on leave pause action.

* Unpause when moderator rejoins session with onLeave=pause

This commite fixes a case when the moderator rejoins a paused session
but Teleport didn't resume the operations and the session was still
locked to everyone.

* Fix panic when re-joining SSH session.

* Update lib/kube/proxy/sess.go

Co-authored-by: Noah Stride <noah.stride@goteleport.com>

* Update lib/kube/proxy/sess.go

Co-authored-by: Noah Stride <noah.stride@goteleport.com>

* Fix typo

Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>

---------

Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>
Co-authored-by: Noah Stride <noah.stride@goteleport.com>
2023-02-17 14:11:59 +00:00
Noah StrideandAlan Parra f3ba5750a8 Make tctl nodes add / tctl tokens add use CreateToken RPC (#21189)
* Start removing generateToken

* Refactor `tokens add` to use `CreateToken` RPC

* Correct deprecation version

* Remove calls to GenerateToken

* Start tests for token crud

* Allow user role rules to be provided wth CreateUserAndRole helper

* Add TestCreateToken to tls_test

* Add TestUpsertToken

* Add GetTokens test

* Add TestGetToken

* Add test for DeleteToken RPC

* Dedupe error assertions

* Add support for emitting trusted cluster token creation events to Create/UpsertToken

* Fix imports

* Change parameter order to appease linter

* Fix broken token expiry test

* Fix token expiry time for TestAuth_RegisterUsingToken

* Remove unnecessary cleanup

* Apply suggestions from code review

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

* Change test comment from deprecation notice

* `make gprc` after code review changes

* Update lib/auth/tls_test.go

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

* Update lib/auth/tls_test.go

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

* Update lib/auth/tls_test.go

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

* Update lib/auth/tls_test.go

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

* Rename tests

* Update lib/auth/tls_test.go

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

* More test cases for GetTokens

* Improve message on duplicate token

---------

Co-authored-by: Alan Parra <alan.parra@goteleport.com>
2023-02-16 09:36:55 +00:00
Jakub NyckowskiandEdoardo Spadolini cd584fdc70 Make NewlyAdded backport friendly. (#21446)
Current implementation of NewlyAdded() requires to keep different implementation on production branches. New implementation will allow to keep the same source code to be identical on all branches.

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2023-02-14 19:57:08 +00:00
Michael Wilson 4b570a55de Add SAML query functions to auth preferences. (#21692)
* Add SAML query functions to auth preferences and role.

Getter functions have been made for the new IdP configuration fields in the
AuthPreferences and RoleOptions.

* Remove role query, as we can access this in the  object.

* Make sure the IdP options section won't hit any nil pointer errors.
2023-02-14 17:31:43 +00:00
Michael WilsonandRoman Tkachenko 383ad7a5de SAML IdP session objects. (#21521)
* SAML IdP session objects.

The upcoming SAML IdP feature requires session storage in the backend. To
support that, the `WebSession` that has been adapted for app sessions and
Snowflake sessions has been adapted for SAML IdP sessions.

The SAML IdP will be encoding the session structure as JSON and packing it
into the new `data` field within the web session.

* Update api/types/session.go

Co-authored-by: Roman Tkachenko <roman@goteleport.com>

* Use specific structure instead of a JSON blob.

* Update the create SAML session request.

* Make SAML session a pointer.

* Add in link to crewjam/saml object.

---------

Co-authored-by: Roman Tkachenko <roman@goteleport.com>
2023-02-13 19:52:33 +00:00
Alan Parra 8c84d0a766 Add device lock support (#21667)
* Add Device to LocketTarget proto

* Refactor LockTarget.Match

* Test lib/srv.ComputeLockTargets

* Test lib/services.LockTargetsFromTLSIdentity

* Test device lock during cert issuance

* Add device lock targets where applicable

* Add --device to `tctl lock`

* Fix godocs (unrelated)

* Review: Drop redundant comments
2023-02-13 14:46:11 +00:00
Edoardo Spadolini f622510dd0 Make UsageSessionStart report TCP app access separately (#21606)
* Make UsageSessionStart more selective and granular for app access

* Allow generic "app" kind for app.session.start

app.session.start is consistently emitted, just not consistently stored

* Avoid singling out aws app access

* Use the same check as app access
2023-02-13 10:13:18 +00:00
Gavin Frazar 5c752c4df8 Fixup teleport db configure create (#20968)
* add missing flags
* fix config generation bugs
* always wrap generated strings value in quotes
* parse and check generated config
* update tests for db agent config gen
2023-02-11 00:54:07 +00:00
f1bec29e58 Batched Dependabot updates (#21634)
* Bump golang.org/x/term from 0.4.0 to 0.5.0

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

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

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

* Bump go.opentelemetry.io/otel/exporters/otlp/otlptrace

Bumps [go.opentelemetry.io/otel/exporters/otlp/otlptrace](https://github.com/open-telemetry/opentelemetry-go) from 1.12.0 to 1.13.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.12.0...v1.13.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlptrace
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

* Bump go.opentelemetry.io/otel/sdk from 1.12.0 to 1.13.0 in /api

Bumps [go.opentelemetry.io/otel/sdk](https://github.com/open-telemetry/opentelemetry-go) from 1.12.0 to 1.13.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.12.0...v1.13.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/sdk
  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.7.0 to 0.8.0

Bumps [golang.org/x/mod](https://github.com/golang/mod) from 0.7.0 to 0.8.0.
- [Release notes](https://github.com/golang/mod/releases)
- [Commits](https://github.com/golang/mod/compare/v0.7.0...v0.8.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 sigs.k8s.io/controller-runtime from 0.14.3 to 0.14.4

Bumps [sigs.k8s.io/controller-runtime](https://github.com/kubernetes-sigs/controller-runtime) from 0.14.3 to 0.14.4.
- [Release notes](https://github.com/kubernetes-sigs/controller-runtime/releases)
- [Changelog](https://github.com/kubernetes-sigs/controller-runtime/blob/master/RELEASE.md)
- [Commits](https://github.com/kubernetes-sigs/controller-runtime/compare/v0.14.3...v0.14.4)

---
updated-dependencies:
- dependency-name: sigs.k8s.io/controller-runtime
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* Bump go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc

Bumps [go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc](https://github.com/open-telemetry/opentelemetry-go-contrib) from 0.38.0 to 0.39.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.38.0...zpages/v0.39.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

* Bump go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc

Bumps [go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc](https://github.com/open-telemetry/opentelemetry-go-contrib) from 0.38.0 to 0.39.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.38.0...zpages/v0.39.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

* Bump google.golang.org/grpc from 1.52.3 to 1.53.0

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.52.3 to 1.53.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.52.3...v1.53.0)

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

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

* Bump google.golang.org/grpc from 1.52.3 to 1.53.0 in /api

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.52.3 to 1.53.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.52.3...v1.53.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  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 from 1.44.195 to 1.44.198

Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.195 to 1.44.198.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.195...v1.44.198)

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

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

* Bump go.opentelemetry.io/otel/exporters/otlp/otlptrace in /api

Bumps [go.opentelemetry.io/otel/exporters/otlp/otlptrace](https://github.com/open-telemetry/opentelemetry-go) from 1.12.0 to 1.13.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.12.0...v1.13.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlptrace
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

* update golang.org/x/net golang.org/x/sys and go.opentelemetry.io/otel/exporters

* update x/text tracehttp fake-gcs-server go/iam x/oauth2 go/kms

---------

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-02-10 20:52:11 +00:00
Joel 2402509f33 Update dependencies blocked by the now-updated firestore version in Teleport + nits (#21653)
* update dep blocked by firestore

* range syntax

* bumpgenproto locally too, due to it being required

* sorry, what

* please

* tidy up
2023-02-10 18:14:08 +00:00
Michael Wilsonandrosstimothy 70833b6b3f Initial user group object. (#20848)
* Initial group object.

The group object has been added to support the Okta appaccess integration
feature. Please see https://github.com/gravitational/teleport.e/pull/609
for more information.

The local service for handling backend management of the group objects has
been added as well. This will be expanded upon in a later PR.

* Rename group to usergroup.

* Linting fixes.

* Remove unnecessary functions.

* Add user groups to test parse shortcut.

* Apply suggestions from code review

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

* Update lib/services/local/usergroup_test.go

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

* Fix AsResources in usergroup.

* Apply suggestions from code review

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

* Update lib/services/local/usergroup.go

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

* Fix return in usergroup service.

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2023-02-10 16:21:17 +00:00
Noah Stride 0181993047 Allow the creation and usage of expiryless ProvisionTokens (#21133)
* Allow the creation and usage of expiryless tokens

* Tidy up loose ends

* Fix imports

* Add tests for changes to expiryless behaviour

* Use new RPCs for new expiryless behaviour

* Add tests for new RPCs

* Remove unused import

* Recreate behaviour for tokens expiring in past

* Missing NoError check int ests

* Correctly americanize behavior
2023-02-10 13:45:36 +00:00
Michael WilsonandEdoardo Spadolini d29cc6e797 Extract entity ID when creating SAML service provider. (#21375)
* Extract entity ID when creating SAML service provider.

The entity ID will be parsed from the entity descriptor metadata when the
service provider's entity descriptor is set. The motivation of this PR is to
do the following:

* Extract the entity ID from the entity descriptor during the creation of the
  SAML IdP service provider.
* Prevent the creation of service providers in the backend that have an
  entity ID that does not match the entity ID represented in the entity
  descriptor.
* When reading or listing service providers, prevent the parsing of every
  entity descriptor during the listing.

The goal here is to make it performant to look up entity descriptors by their
entity ID without incurring the cost of parsing every single entity descriptor
to determine the entity ID.

* Feedback, eliminating the parsing from the object, pushing parsing verification into the local service.

* Fix up tests, e_imports.

* Fix comment in types.proto.

* Remove dead comment.

* Deduplicate entity ID in update as well.

* Small refactor to move parse out of lock.

* Remove XML parsing from type, fix grpcserver test, fix locking boundaries.

* Tim's and Edoardo's feedback.

* Fix cache test.

* Update lib/services/local/saml_idp_service_provider.go

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

* Expanding the comments on the EntityID field.

---------

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2023-02-09 21:06:41 +00:00
Michelle Bergquist 8dfa07559b capture custom role creation in prehog (#21123)
* add e2e role creation events

* add role name

* reset proto

* cleartext default role names

* constant
2023-02-09 19:23:29 +00:00
Alan Parra 511dc199d8 Skip device authz when issuing App or Windows certs (#21344)
* Test device authorization during cert issuance

* Skip device validation when issuing App or Windows certs

* Add an early check for GenerateUserSingleUseCerts
2023-02-09 19:19:25 +00:00
dependabot[bot] d5d6e1e138 Bump go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp (#21513)
Bumps [go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp](https://github.com/open-telemetry/opentelemetry-go-contrib) from 0.38.0 to 0.39.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.38.0...zpages/v0.39.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-09 15:16:42 +00:00
Alan Parra c5bc3a4e0f Rename protoEqual and add a big warning (#21491)
Rename `protoEqual` to `protoKnownFieldsEqual` and add a warning about
its usage.

Manually ignoring `XXX_` fields in full comparisons runs the risk of
ignoring unknown fields, which in itself is a strong hint that we are
running outdated code. The recommended practice for scenarios where full
equality is not desirable is to code it as such, comparing the fields
that matter.

`proto.Equal` should be preferred in most scenarios.
2023-02-08 20:57:18 +00:00
Gavin Frazar bd5e9cd6a2 Add field to user cert request (#21197)
* Identify the "requester" of the cert request
2023-02-08 17:40:39 +00:00
Andrew Burke 732594f191 Add Azure join method (#20019) 2023-02-08 17:21:11 +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
Justinas Stankevičius 49dca5a706 Add service for "plugin" resources (#21210)
* Add Plugins service

* Add tests for local plugins service

* Remove validation calls from service

These are already invoked by MarshalPlugin

* Separate concerns of local Plugins service

Credentials will be exchanged by the auth server,
so there is no need to have proto.CreatePluginsRequest
in the service layer.

Proto types will be reintroduced in a later PR
covering the auth server changes.

* Rename method to better reflect purpose

* Run GCI
2023-02-07 15:34:20 +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
Roman Tkachenko ea5f334821 Fix operator build (#21362) 2023-02-07 01:15:55 +00:00
Tiago Silva 4d09eea9b0 Add gRPC Kubernetes Service (#21103)
This PR introduces a gRPC service to retrieve the pods available using the `search_as_roles` configured in the user's roles.

This gRPC service receives a TLS identity and manipulates it to access the Teleport Kubernetes Proxy and retrieve the pods available for a hypothetical user that has the `search_as_roles` defined for its roles.
The response does not leak the certificate nor the pod details other than `name`, `namespace` and `labels`.

```mermaid
sequenceDiagram
    participant User as User
    participant gRPC as grpc Server
    participant Auth as Auth Server
    participant KubeProxy as Kube Proxy
    participant KubeSVC as Kube Service
    User->>+gRPC: ListKubeResources(cluster,namespace)
    Note left of gRPC: Includes search_as_roles <br/> and preview_as_roles <br/>into identity!
    gRPC-->>+Auth: Sign cert with ProcessKubeCSR
    Auth-->>-gRPC: Signed certificate
    gRPC->>+KubeProxy: list pods "v1.../namespaces/{namespace}/pods"
    KubeProxy-->>+KubeSVC: list pods "v1.../namespaces/{namespace}/pods"
    KubeSVC-->>-KubeProxy: filtered response
    Note left of KubeSVC: Applies Pod RBAC filtering!
    KubeProxy-->>-gRPC: response
    gRPC->>-User:Return name, namespace and labels
```

Part of #21107 and #19573
2023-02-06 22:45:31 +00:00
Edoardo Spadolini 86df3aa981 Loop over the CA type list in collections (#21292)
* Loop over the CA type list in collections

Also adds a NewlyAdded method to CertAuthType to indicate the CA types
that have been added in the current major version, so that we can
ignore any related BadParameter error when handling those kinds of CAs
with potentially older versions of Teleport.

* Mention NewlyAdded in the CertAuthType description
2023-02-06 17:50:43 +00:00
Lisa Kim c7a11477ee [Web:Discover] Report events (#20581)
* Define event types

* Define event names for each flow

* Report events upon start, exiting, and next steps

* Update json property name change

* Emit user skipped event

* Emit error events

* Handle unloading event for 'completed' step

* Move updating event state into hook

* Finish emitting events for desktop

* Address CR: rename DiscoverDesktop to DiscoverResources

* Various changes:

- address CR: remove use of ref
- diagnostic traces can also be a success, only emit event on failed traces
- add mysql to discover events
- consistent naming on exit prompt

* Update and add new event names

* Update tests

* Emit events for unimplemented flows (apps and other dbs)

* Redo emitting events for test connection

Send event for EACH test connection failure or success.
If a user does not do any testing, send a skipped event.
2023-02-03 19:30:56 +00:00
STeve (Xin) Huang 704a514742 AWS IAM role matching for database users (#20610)
* Add database user matching logic for databases require AWS IAM role

* Fix UT

* fix lint/typo

* fix typo in error message

* reduce bool return
2023-02-03 18:33:56 +00:00
Marco André Dinis 97b2a33ff8 Add RBAC labels for Database Services access (#21093)
* Add RBAC labels for Databas Services access

This PR adds a new set of Labels that controls access to the
DatabaseService resource.

We changed the `RoleSet.checkAccess` to allow for checks in Resources
without Labels.
However adding complexity to this function is something that can bit us
in the future.
So, this PR reverts that change and adds a new set of labels.
Those labels will control whether the RoleSet has access to
DatabaseServices.

Given that this is a new condition that we add to the default `editor`
role, we had to create a migration/backfill for the roles that don't
have them.
This allow us to migrate the roles created previously and add this new
allow condition.

* remove preset for remote proxy and database labels

* Remove db_service_labels wildcard from editor preset role

* Fix early exit logic
2023-02-03 17:58:27 +00:00
42cb80c3e4 Adding in a new SAML IdP certificate authority. (#21159)
* Adding in a new SAML IdP certificate authority.

A new SAML IdP certificate authority has been added. It has been added to
initialization, the cache, and the certificate can be rotated.

* Update lib/services/authority.go

Co-authored-by: Sam Freiberg <sfreiberg@goteleport.com>

* Update api/types/trust.go

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

* Only validate private key if it's present.

---------

Co-authored-by: Sam Freiberg <sfreiberg@goteleport.com>
Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2023-02-03 15:56:56 +00:00
Vitor Enes c77810ad6c go mod tidy in api/ (#21202) 2023-02-03 15:23:08 +00:00
Rafał Cieślak 3ac5a0aedb Refactor prehog & teleterm protos to match project conventions (#20810)
* Adjust go_package of lib/prehog Go protobufs

This makes them follow the pattern set out by api/proto and proto.

* Adjust go_package of lib/teleterm Go protobufs

* Use single buf.gen.yaml to generate JS protos

This also entailed changing the location of lib/teleterm protos and changing
the value of their package specifier to match the conventions in other parts
of the codebase. This is a breaking change but that is fine for Connect
as the protos are used locally only and each build ships with matching
protobufs.

* Make web/packages/teleterm use protobufs from gen-proto-js

We used to copy protobufs over to web/packages/teleterm/src/services/tshd
since webapps used to be in a separate repo.

This is no longer the case, so we can just make teleterm use protobufs
from gen-proto-js.

* Move prehog & teleterm protos into proto/teleport/lib

* Generate JS protos to gen/proto/js

* Move lib/teleterm Go protobufs to gen/proto/go

* Move lib/prehog Go protobufs to gen/proto/go

* Rename lib/teleterm proto package

* Re-enable linter rules for teleterm & prehog

* Update prehogv1 path in usagereporter_test.go

* Use except instead of ignore_only to allow Google API-style responses

* Add UNARY_RPC to api/proto & proto

* Ignore gen/ when running addlicense

* buf-js.gen.yaml: Remove comment about lack of go_package for JS

* Move prehog protos to proto/prehog/v1alpha

* Adjust prehog's go_package to match proto package
2023-02-03 14:47:06 +00:00
Michael Wilsonandrosstimothy 7d40f37cb1 SAML IdP service provider APIs (#20992)
* SAML IdP service provider APIs

The SAML IdP service provider's associated APIs have been implemented. This
will support the use of Teleport as a SAML IdP by allowing Teleport users to
add service providers through the API.

* Correct permissions.

* Update lib/auth/grpcserver_test.go

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2023-02-03 14:09:33 +00:00
Justinas StankevičiusandEdoardo Spadolini 6213ccf42d Add Plugin resource schema, methods (#20990)
* Add Plugin resource schema, methods

* Improve shebang of genproto.sh

Execute using bash, no matter where it actually lives

* Use Metadata.Expiry()

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

* Remove field reservations from PluginStatusCode

* Add plugin (un)marshaling

* Snake case fields of Plugin (and children)

* Ensure timestamp fields on Plugin are always UTC

https://github.com/gogo/protobuf/issues/519

* Rename credentials according to proto conventions

* Fold check for nil settings into the type switch

* Remove extraneous field checks

These are set in setStaticFields()

* Add missing godocs

---------

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2023-02-03 11:04:53 +00:00
Marco André Dinis 18bb8cf728 Discover: add flow events (#20925)
* Discover: add flow events

* improve comments and test description
2023-02-02 15:54:22 +00:00
Michael Wilson 7c4bba7414 Add IdP options to role and auth preferences. (#20999)
* Add IdP options to role and auth preferences.

Both role and auth preferences have IdP options added to them. At the auth
preferences level, if the SAML IdP option is set to false, the IdP will be
disabled globally. At the role level, it will control which roles allow
access to the IdP.

* Make SAML access by default.

* Fix tests.

* Fix config test.
2023-02-01 18:45:49 +00:00
e1673dec70 Batched Dependabot updates (#21043)
* Bump go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc

Bumps [go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc](https://github.com/open-telemetry/opentelemetry-go-contrib) from 0.37.0 to 0.38.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.37.0...zpages/v0.38.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc
  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 from 1.44.189 to 1.44.191

Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.189 to 1.44.191.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.189...v1.44.191)

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

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

* Bump sigs.k8s.io/controller-tools from 0.11.1 to 0.11.2

Bumps [sigs.k8s.io/controller-tools](https://github.com/kubernetes-sigs/controller-tools) from 0.11.1 to 0.11.2.
- [Release notes](https://github.com/kubernetes-sigs/controller-tools/releases)
- [Changelog](https://github.com/kubernetes-sigs/controller-tools/blob/master/RELEASE.md)
- [Commits](https://github.com/kubernetes-sigs/controller-tools/compare/v0.11.1...v0.11.2)

---
updated-dependencies:
- dependency-name: sigs.k8s.io/controller-tools
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* Bump github.com/aws/aws-sdk-go-v2/service/ec2 from 1.80.1 to 1.83.0

Bumps [github.com/aws/aws-sdk-go-v2/service/ec2](https://github.com/aws/aws-sdk-go-v2) from 1.80.1 to 1.83.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.80.1...service/ec2/v1.83.0)

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

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

* Bump go.opentelemetry.io/otel/sdk from 1.11.2 to 1.12.0 in /api

Bumps [go.opentelemetry.io/otel/sdk](https://github.com/open-telemetry/opentelemetry-go) from 1.11.2 to 1.12.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.11.2...v1.12.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/sdk
  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.10.0 to 1.13.0

Bumps [cloud.google.com/go/container](https://github.com/googleapis/google-cloud-go) from 1.10.0 to 1.13.0.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/documentai/CHANGES.md)
- [Commits](https://github.com/googleapis/google-cloud-go/compare/asset/v1.10.0...pubsub/v1.13.0)

---
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>

* Revert "Bump cloud.google.com/go/container from 1.10.0 to 1.13.0"

This reverts commit 8987cba9a0aa8bd26743dabee99f8336637e35be.

* go mod tidy

* bring back coreos/pkg

* add container to ingores deps

* Bumps go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp from 0.37.0 to 0.38.0

* Bumps go.opentelemetry.io/otel/exporters/otlp/otlptrace from 1.11.2 to 1.12.0

* Bumps go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc from 1.11.2 to 1.12.0

* Bump go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp from 1.11.2 to 1.12.0

* Bump go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tobiasz Heller <tobiasz.heller@goteleport.com>
2023-02-01 17:06:45 +00:00
Marco André Dinis 799219f07a Update grpc-generated files (#21056)
In a previous PR some grpc-generated files were not included in the
commit.
This PR is the result of running `make grpc`.
2023-02-01 10:46:21 +00:00
26a623b5be Batched Dependabot updates (#20903)
* Bump google.golang.org/grpc from 1.52.1 to 1.52.3

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.52.1 to 1.52.3.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.52.1...v1.52.3)

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

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

* Bump github.com/aws/aws-sdk-go from 1.44.186 to 1.44.189

Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.186 to 1.44.189.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.186...v1.44.189)

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

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

* Bump sigs.k8s.io/controller-runtime from 0.14.1 to 0.14.2

Bumps [sigs.k8s.io/controller-runtime](https://github.com/kubernetes-sigs/controller-runtime) from 0.14.1 to 0.14.2.
- [Release notes](https://github.com/kubernetes-sigs/controller-runtime/releases)
- [Changelog](https://github.com/kubernetes-sigs/controller-runtime/blob/master/RELEASE.md)
- [Commits](https://github.com/kubernetes-sigs/controller-runtime/compare/v0.14.1...v0.14.2)

---
updated-dependencies:
- dependency-name: sigs.k8s.io/controller-runtime
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* Bump github.com/aws/aws-sdk-go-v2/config from 1.18.9 to 1.18.10

Bumps [github.com/aws/aws-sdk-go-v2/config](https://github.com/aws/aws-sdk-go-v2) from 1.18.9 to 1.18.10.
- [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/config/v1.18.9...config/v1.18.10)

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

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

* Bump github.com/bufbuild/connect-go from 1.4.1 to 1.5.0

Bumps [github.com/bufbuild/connect-go](https://github.com/bufbuild/connect-go) from 1.4.1 to 1.5.0.
- [Release notes](https://github.com/bufbuild/connect-go/releases)
- [Commits](https://github.com/bufbuild/connect-go/compare/v1.4.1...v1.5.0)

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

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

* Bump github.com/snowflakedb/gosnowflake from 1.6.16 to 1.6.17

Bumps [github.com/snowflakedb/gosnowflake](https://github.com/snowflakedb/gosnowflake) from 1.6.16 to 1.6.17.
- [Release notes](https://github.com/snowflakedb/gosnowflake/releases)
- [Changelog](https://github.com/snowflakedb/gosnowflake/blob/master/release.go)
- [Commits](https://github.com/snowflakedb/gosnowflake/compare/v1.6.16...v1.6.17)

---
updated-dependencies:
- dependency-name: github.com/snowflakedb/gosnowflake
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* Bump github.com/Azure/azure-sdk-for-go/sdk/azidentity

Bumps [github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://github.com/Azure/azure-sdk-for-go) from 1.2.0 to 1.2.1.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/release.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/v1.2...sdk/azidentity/v1.2.1)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azidentity
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* Bump github.com/go-webauthn/webauthn from 0.5.0 to 0.7.0

Bumps [github.com/go-webauthn/webauthn](https://github.com/go-webauthn/webauthn) from 0.5.0 to 0.7.0.
- [Release notes](https://github.com/go-webauthn/webauthn/releases)
- [Commits](https://github.com/go-webauthn/webauthn/compare/v0.5.0...v0.7.0)

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

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

* Bump google.golang.org/grpc from 1.52.1 to 1.52.3 in /api

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.52.1 to 1.52.3.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.52.1...v1.52.3)

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

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

* Revert "Bump github.com/go-webauthn/webauthn from 0.5.0 to 0.7.0"

This reverts commit 5cb883d540e37b21c457b2f00886798ef734845f.

* add go-webauthn to dependabot skip

* bring back coreos/pkg

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tobiasz Heller <tobiasz.heller@goteleport.com>
Co-authored-by: Tobiasz Heller <14020794+tobiaszheller@users.noreply.github.com>
Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2023-01-31 20:26:29 +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
Michael Wilsonandrosstimothy 0caf51d6b6 Initial SAML IdP service provider object. (#20774)
* Initial SAML IdP service provider object.

The SAML IdP service provider object has been added to support the use of
Teleport as a SAML identity provider. Please see
https://github.com/gravitational/teleport.e/pull/668 for more information.

The local service for handling backend management of the SAML IdP
service provider objects has been added as well. This will be expanded upon
in a later PR.

* Fix imports.

* Copy paste error.

* Update api/types/saml_idp_service_provider.go

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

* Update api/types/saml_idp_service_provider.go

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

* Update lib/services/local/saml_idp_service_provider.go

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

* Use errAssertionFunc, paginate service provider resources.

* Marco's and Tim's feedback.

* Update proto comments.

* Update NewSAMLIdPServiceProvider comment.

* Fix linting, test issues.

* Remove unnecessary functions already given by ResourceHeader.

* Apply suggestions from code review

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

* Fixes, removal of explict getter for service provider.

* Remove unnecessary functions.

* Update api/types/saml_idp_service_provider.go

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

* Linting fix.

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2023-01-30 20:04:21 +00:00