Commit Graph
370 Commits
Author SHA1 Message Date
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
Brian Joerger f7bd643652 * Enable headless authentication event watch. (#28234)
* Add WatchPendingHeadlessAuthentications rpc.
2023-06-28 18:03:53 +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
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
Alex McGrath 0760bc9776 Allow setting max_session_ttl from clusterauth preferences (#26824)
Document `default_session_ttl` in the reference.
2023-06-21 10:39:34 +00:00
Sakshyam Shah 1762c764ae feat: adds motd to the ui (#27813)
* feat: adds motd to the ui

* address review suggestions:
- update MOTD to Motd
- moved motd state to useLogin
- added behaviour tests

* add motd test to apiserver_test.go webconfig. update snapshot test to address motd warning

* git mv to update MOTD to Motd

* multiple fix:
- add unmount test
- remove motd title
- group states together in useLogin
- update arrow func to classic js func

* remove unused waitForElementToBeRemoved
2023-06-16 02:43:17 +00:00
Marek Smoliński c2db4f0c92 Set default limit for ListResourcesRequest (#27832) 2023-06-14 13:29:07 +00:00
STeve (Xin) Huang e677aadb9f Fix an issue ALPN handshake test does not respect "HTTPS_PROXY" (#27583)
* Fix an issue ALPN handshake test does not respect "HTTPS_PROXY"

* address review comment

* remove simplehttsproxy

* Add context to IsALPNConnUpgradeRequired in ten thousand places

* add goc and dial with context
2023-06-13 15:30:48 +00:00
Lisa Kim ad295055e3 Fix not being able to "login" with auth type set to sso but no connectors set yet (#27510)
* Delete ping service

* Move flags from web config instead of calling ping

* Clarify TODO comment
2023-06-07 19:44:43 +00:00
Tiago Silva 04774100cc Add endpoints to export AuditEvents as unstructured data (#27026)
This PR adds a new gRPC service `AuditLogService` that allows clients to
request audit log events as unstructured data. Data is returned as
`structpb.Struct` representation which is convertible to JSON.

Unstructured data allows clients to receive audit events without
prior knowledge of their proto wire representation if their end goal is to
export the events as JSON to an upstream service. It allows clients
whose version is older than Auth's version to receive events that their
proto version doesn't support. Exporters can continue operating without
losing events or having to upgrade them each time Auth is upgraded.

Part of https://github.com/gravitational/teleport-plugins/pull/821
Part of https://github.com/gravitational/teleport/issues/23388
2023-06-02 14:49:42 +00:00
Andrew Burke e7caae7cec Add ServerInfo and label API (#26112)
This change adds `ServerInfo` to the auth server gRPC API, as well as the `UpdateLabels`
message to the inventory control stream.
2023-05-31 23:35:33 +00:00
Jakub NyckowskiandRyan Clark 5a7751fd96 [Assist] Allow removing assist conversations (#26788)
* [Assist] Allow removing assist conversations

* Display landing page after the conversion is removed

* Improve styling and add a confirmation dialog

* Change the icon opacity to copy the main navigation

* Remove unused minus icon

* Add missing trace.wrap

---------

Co-authored-by: Ryan Clark <ryan.clark@goteleport.com>
2023-05-31 21:18:35 +00:00
Edoardo Spadolini 571477fe5a protobuf changes in preparation for buf breaking (#26792)
* Use WIRE_JSON in buf breaking

* Add some field reservations for backwards compat
2023-05-26 13:53:07 +00:00
Gavin Frazar 9ed945b67c update db and app service role permissions (#25247)
* app service KindApp read/write to read-only
* db service KindDatabase read/write to read-only
* fix DeleteAllSnowflakeSessions
* update snowflake session authz checks
* rework snowflake watcher logic
2023-05-17 21:15:38 +00:00
Forrest 1c8706d132 add upgrader to inventory hello (#26454) 2023-05-17 19:50:14 +00:00
Jakub NyckowskiandJoel Wejdenstål 5fddd75d0f Assist - Web endpoints (#26046)
* Assist - Web endpoints

* GCI

* proto rpc

* enforce endpoint checks

* disable in ui if disallowed by auth

* add comment

* unwrap stack

* Refactor code

---------

Co-authored-by: Joel Wejdenstål <jwejdenstal@icloud.com>
2023-05-13 05:00:44 +00:00
Jakub Nyckowski ae8f2fa929 Assist - Configuration and usage (#25953)
* Assist - Configuration and usage

* Add network config test

* Add config test

* Run GCI

* Address review comments
2023-05-11 01:56:55 +00:00
Nic Klaassen 2568bff9db fix: use errors.Is for all EOF comparisons (#26012)
This commit updates all `err == io.EOF` comparisons to use
`errors.Is(err, io.EOF)`. This is necessary when the error may have been
wrapped and fixes at least one current breakage (in `tsh request ls`).

`golang.org/x/tools/refactor/eg` was very handy for this, I used the
following template:

```go
package teleport
import (
	"errors"
	"io"
)
func before(err error) bool { return err == io.EOF }
func after(err error) bool  { return errors.Is(err, io.EOF) }
```
2023-05-10 19:27:39 +00:00
Michael Wilson 11fe042ccd Introduce inventory service counts. (#25755)
* Introduce inventory service counts.

Inventory service counts have been introduced. These will be useful when
trying to conditionally act on the presence of a particular service in a
Teleport cluster. In particular, these will be used to disable Okta's
access request reconciler when there are no Okta services connected to the
cluster.

* Rename to ConnectedServiceCounts, improve load to be more performant.

* Fix imports.

* Update GRPC.

* Expose a ConnectedServiceCount that looks for one particular service, don't populate the underlying map on read.
2023-05-09 18:20:30 +00:00
Jakub Nyckowski bc71a7993f Assist - API implementation (#25810)
* Assist - API implementation

* Add Assistant CRUD test

* Move assistant API to a separate file.

* Rename GRPC methods
Fix comments

* Address PR comments

* Update GRPC API - addressing code review comments

* Move assist API to a new GRPC service

* Add Assistant RBAC rules to this backport.

* Add missing license

* Update comment.
2023-05-09 17:32:54 +00:00
Anton Miniailo 2cfa9b5ab2 Add kube local proxy bound MFA sessions (#24527) 2023-05-05 04:55:56 +00:00
rosstimothy f9657ab662 Reuse auth connection for Okta client (#25622)
The Okta client was creating a separate connection to Auth in
`auth.NewClient` instead of reusing the gRPC connection of the
api client. Since this method is used by every Teleport instance
when establishing their initial connection to Auth it poses two
problems:
 1) Auth now has one additional connection per instance
 2) Proxies require an additional trasnport channel per tunnel

Fixes #25235
2023-05-04 16:43:47 +00:00
matheus 57690ee961 Add IsUsageBased to features and send it to web UI (#25465)
* Add IsUsageBased to features and send to web UI

* Update flag name

* Improve comment

* Add comments and improve field name

* Remove duplicated property
2023-05-04 14:57:48 +00:00
Michael Wilson 598e09f202 Support UI methods for user groups, label match user groups in API. (#25559)
* Support UI methods for user groups, label match user groups in API.

UI methods have been added to User Groups to support the enterprise Okta
service. This will allow groups to be queried and displayed on the new
access request page appropriately.

Additionally, after adding group labels to roles, the access checking was
not added to the appropriate user groups endpoints in auth_with_roles.
This has been added to ensure that users can only see the user groups they're
supposed to see when requesting access.

* UI lint issues.
2023-05-03 18:06:49 +00:00
Noah Stride 2604f4f461 Improve API client connection failure feedback (#25536)
* Improve connection failure feedback when using API client

* SPAG in comment

* Remove unnecessary line from API client docs
2023-05-03 15:40:19 +00:00
rosstimothy 8f23cd40ad Use web address when appropriate for a jump host (#25237)
* Use web address when appropriate for a jump hosts

Determines whether the jump host provided via `tsh ssh -J` is belongs
to the Proxy SSH or Web server to ensure when using jump hosts that
connections are established directly on the target cluster.

Closes #25178

* Modify tsh tests to capture issues with jump hosts

Alters the root and leaf cluster and node names used by tsh tests
so that the root cluster is named `root` instead of `localhost` and
sets a unique `NodeName` for each cluster instead of reusing
`localnode` for both. This was masking problems in jump hosts tests
by connecting to the node in the root cluster instead of the leaf
cluster.

Some additional changes to tsh tests were made as a result of
changing the cluster and node names.

* fix proxy client tests

* update TestList to login once

* ignore TestList in flaky test detector
2023-05-02 18:03:35 +00:00
Andrew LeFevre 68feffbf82 fix connecting to agentless leaf nodes (#25206)
* fix connecting to agentless leaf nodes

Pass user and role information to Auth server signing OpenSSH cert
so avoid user/role lookup errors if the target node is on a leaf
cluster. Also use role and trait information from the current
connection rather than the backend to support role impersonation.

* make protobuf changes backwards-compatible
2023-05-02 17:39:47 +00:00
STeve (Xin) Huang 860d91012c Add missing Connection header for ALPN connection upgrade (#25346) 2023-05-01 13:09:19 +00:00
Michael Wilson 892883fbcd Simplify Okta assignment statuses. (#25166)
* Simplify Okta assignment statuses.

The Okta assignment statuses have been simplfieid so that there's only a
status on the Okta assignment object itself and the number of states is
reduced.

* Fix tests, remove unused code.

* Add in Duration for update statuses to prevent changing status too soon.

* Make sure LastTransition is UTC.

* Remove actions in favor of targets, make cleanup time non-nullable.
2023-04-26 13:30:10 +00:00
Alan Parra 48dd429917 Return auto-enroll status on Ping (#24752)
* Return auto-enroll status on Ping

* Verify both old and new flags
2023-04-24 14:43:29 +00:00
cf2c7059a3 Add full IP pinning enforcement (#24743)
* Add full IP pinning enforcement

We're adding IP pinning check to `authorizer.Authorize` which is used for every call,
so now all communications with teleport should enforce IP pinning.
Also making sure we always provide login IP for user certificate creation
and correct client IP propagation everywhere.

* Add integration test for App IP pinning.

* Fix wording

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

* Wrap error

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

* Add godocs

* Clone TLS config

* Improve proxyHeaderSigner usage

* Wider use proxyHeaderDialer and remove adhoc writing of singed header

* Add helper function TLSDial

* Use proxyHeader dialer in authConnect

* Simplify tlsConfig manipulation

Co-authored-by: Przemko Robakowski <przemko.robakowski@goteleport.com>

* Remove redundant channels processing in TLSDial

* Reduce nesting

* Update generated protobufs

* Remove ignoring of bad IP on signed PROXY header generation

* Provide logger to CheckIPPinning function

---------

Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>
Co-authored-by: Przemko Robakowski <przemko.robakowski@goteleport.com>
2023-04-23 17:09:49 +00:00
rosstimothy b6b57bcfe8 Unify errors returned from ProxyClient when targets are ambiguous (#25004)
Ensures that SSH and gRPC connections via `tsh` return the same
error when dialing a host fails.

Closes #24943
2023-04-21 20:36:47 +00:00
Brian Joerger 3883084766 Add key attestation to generate user certs to catch non-login flows. (#24867) 2023-04-20 17:28:01 +00:00
Marco André Dinis f3a5d9695e Integrations: AWS OIDC - ListDatabases action (#24460)
* AWSOIDC Integration: ListDatabases

This PR adds a new Action for the AWSOIDC Integration: ListDatabases
The goal of this action is to provide the User a list of RDS Databases
from which the User will pick one to be added as a Teleport Database
Resource.
This way, the user doesn't need to copy/paste DB name, endpoints and
labels.

Before being able to call this action, the User has to set up an AWS
OIDC integration.

How does it work:
```
                    Client (web app)
                     │     ▲
                     │     │4. Returns list of DBs
 1. List Databases   │     │   (name, tags, status, endpoint)
                     │     │
                     │     │
                     │     │
                     │     │
                     ▼     │       3. rds.DescribeDBInstances
               ┌───────────┴────┐     (auth: token)                ┌─────────┐
               │                ├─────────────────────────────────►│         │
               │ Teleport Proxy │                                  │   AWS   │
               │                │     3.1. Get OIDC Config         │         │
               │                │◄─────────────────────────────────┤         │
               │                │     3.2. Get RSA Public Key      │         │
               │                │◄─────────────────────────────────┤         ├─────────┐ 3.3.
               │                │                                  │         │         │Validates token signature
               │                │                                  │         │         │with received public key
               │                │   3.4 Returns list of DBs        │         │◄────────┘
               │                │◄─────────────────────────────────┤         │
               └─┬──────────────┘                                  └─────────┘
                 │
                 │  2. Sign Token
                 │
                 ▼
              ┌───────────────────┐
              │                   │
              │   Teleport Auth   │
              │  RSA Private Key  │
              └───────────────────┘

```

* add resource and account ids to DB resource

* move api namespaces

* use types.Database instead of custom database format

* add database uri

* fix comments and rate limiter

* test name override when converting RDS V2 DBs

* fix webapi database URI field

* TestClusterDatabasesGet: add parallel
2023-04-19 15:42:53 +00:00
Andrey Bulgakov ad80fa3e17 Partial cache healthiness (#24080)
* Partial cache healthiness

* IsSupersetOf -> Contains

* NewWatchStatus fixes

* make map[kindSubKind]types.WatchKind with capacity

* fixed TestRootNetwork?

* post-rebase fix

* fixes regarding docs/comments

* const noSubKind = ""

* preallocate slices for validKinds

* DisablePartialHealth

* test fixes

* fixed struct logging field name

* use custom identity in TestEventsPermissionsPartialSuccess

* fixed TestNodeCAFiltering

* don't look at versions in events APIs

* RFD state: implemented
2023-04-15 20:07:43 +00:00
STeve (Xin) Huang b1941aaa85 TLS routing behind LB support for Auth, SSH, Reverse tunnel (#23866)
* ALPN connect test improvements

* fix typos

* remove extra period

* simplify error check

* moving things over

* tsh dials

* reverse tunnel

* fix auth connect

* move ping

* add ssh support

* add HTTP client support

* Move ALPN dialer, ALPN conn upgrade, Ping conn to api

* beatify

* add test

* beautify round 2

* fix timeout

* Implement alpn-ping upgrade for reversetunnel and ssh

* clean up

* fix proxy test

* minor refactor

* remove WebProxyAddr

* require IsALPNConnUpgradeRequiredFunc

* add tlsRoutingWithConnUpgradeConnect

* fix lint

* simplify

* remove debug log and change unknown upgrade type to 404

* Force new proxy client to use web proxy when TLS routing is enabled
2023-04-14 19:22:23 +00:00
rosstimothy 640bd01640 Improve performance of MFA ceremony (#24250)
To date clients attempting to access a resource first have to call
`proto.AuthService/IsMFARequired` to determine if an mfa ceremony
is needed for access to a resource. In an effort to reduce an
extra round trip to the Auth server this can can be bundled into
`proto.AuthService/GenerateUserSingleUseCerts`.

In order for RBAC to determine if mfa is required for SSH sessions
the OS login of the session must be known. To accomodate this a
new `SSHLogin` field was added to `proto.UserCertsRequest`.

The response to the initial request of the stream now contains a
`proto.MFARequired` enum which indicates whether mfa is required,
not required, or it's unknown if mfa is required. The last variant
should only be returned when the `SSHLogin` field is unset in the
initial request.

The `(auth.Server) isMFARequired` check was also modified for nodes
to make use of `ListResources`. Instead of retrieving **all** nodes
into memory and finding the matching ones, a request is made to
`ListResources` with the `SearchKeywords` populated with the target
from `proto.IsMFARequiredRequest_Node.Node.Node`. Care was taken
to filter out any matches from labels to preserve the original
matching behavior.
2023-04-14 19:08:28 +00:00
Marek Smoliński bf695e0cb4 Database Agent - remove Support for UserCA (#23758) 2023-04-14 07:57:38 +00:00
Marco André Dinis c0e5e1a1ef Integration: add service to server and client (#24133)
* Integration: add service to server and client

* Add cache for Integration to Proxy

* Add RO for Integration resource for Proxy role
2023-04-12 11:34:21 +00:00
rosstimothy c692538864 Improve client api for listing resources (#23592)
Adds `GetResource` helpers that leverage generics to return a slice
of the expected resource type. This eliminates the need to use
a `type.ListResourcesResponse` and then call `AsServers` to convert
the `[]types.ResourceWithLabels` to `[]types.Server`.

Only calls for `types.Server` have been converted. Other resources
can be converted over time.
2023-04-11 18:23:47 +00:00
Forrest ceb61f53d2 maintenance window API (#22850) 2023-04-11 00:23:03 +00:00
Andrey Bulgakov 62bfd2175b Proto changes for partial cache (#24229) 2023-04-10 17:42:31 +00:00
Alan Parra 8a18b2b58e Drop gRPC call options from api/client.Client (#23917)
* Drop Client.WithCallOptions

* Drop Client.callOpts
2023-04-05 19:34:25 +00:00
rosstimothy a5898a2a99 Convert tsh ssh to use the proxy transport service instead of ssh (#23228)
* Convert tsh ssh to use the proxy transport service instead of ssh

In an effort to reduce latency establishing sessions `tsh ssh` is
migrating away from connecting to the Proxy via SSH in favor of
using gRPC. The SSH handshakes with the Proxy increase latency in
situations where the distance between geolocations of the client
and Proxy are large. TLS handshakes used by the gRPC service have
proven to reduce latency by ~20% in the same scenario.

A new `lib/client.ClusterClient` has been introduced that should
be used instead of `lib/client.ProxyClient` to connect to a Teleport
cluster. Most of the functionality within the `ClusterClient` was
a direct copy from the `ProxyClient`.

The `lib/client.TeleportClient` now has a `ConnectToCluster` method
which will connect to both the Proxy and Auth service via the
`api/client.ProxyClient` which first attempts to use gRPC and reverts
back to SSH to preserve backwards compatability. The `ClusterClient`
should be passed around and reused instead of following the
established pattern of `tc.ConnectToProxy` followed by a
`proxy.ConnectToCluster` to get an `auth.ClientI`.

Additionally some of the `agentless` package was refactored to reduce
dependencies and allow it to work with connections to the Proxy that
originated via gRPC instead of SSH.

Changes to the integration tests are mostly to accomodate IP Pinning
and ensure that it works for both connections established via SSH
and gPRC.

This is the final PR needed to complete #19812.

* fix typos and unify span attributes

* pass node name to ConnectToNode

* simplify jump host resetting
2023-04-04 21:31:39 +00:00
Alan Parra 4c59d2fc66 Declare device resource CRUD methods (#23913) 2023-04-03 22:14:19 +00:00
STeve (Xin) Huang ea85f050a8 Move ALPN dialer, ALPN conn upgrade, Ping conn to api (#23860) 2023-04-03 14:16:30 +00:00
rosstimothy d3276b2caa Make proxy.Client infer the cluster name from Proxy (#23644)
Instead of relying on users to provide the cluster name, the client
now determines the cluster name by inspecting the certificate
presented by the Proxy during the TLS or SSH handshake. This is
required when connecting to a Proxy via a jump host since the
name of the cluster may not match the currently logged in cluster.

This is achieved by leveraging a custom `credentials.TransportCredentials`
when connecting via gRPC and a custom `ssh.HostKeyCallback` when
connecting SSH.
2023-04-03 12:34:43 +00:00
Marco André Dinis f0fcf62fb2 Integration resource: add types and grpc methods (#23553)
* Integration resource: add types and grpc methods

This commit adds the new types for Integration resource.
It also adds the gRPC methods that will be used later on for:
- Integrations CRUD management
- Integrations resource caching

* decouple integration service from auth

* return resource on CRU operations

* Add OneOf prop to distinguish Integrations subkind

* Version subkind spec

* godocs
2023-03-31 15:20:51 +00:00
Brian Joerger eee79ac4fb Address deprecation TODOs for v13 (#23679)
* Address deprecation TODOs.

* Add reserved lines.

* Remove unused mock servers.
2023-03-28 20:04:35 +00:00
Marco André Dinis 3102b82770 Use stable/cloud when Automatic Upgrades is on. (#23395)
* Use `cloud/stable` when Automatic Upgrades is on.

Teleport provides scripts to install teleport agents/services.
Those scripts use YUM/DEB repositories when possible.
Each repo has multiple channels:
- stable/v11
- stable/v12
- cloud/stable

We want to ensure that if the cluster is running in the cloud and
automatic upgrades is on (auth service was started with
TELEPORT_AUTOMATIC_UPGRADES=yes teleport ...), then the installation
script must offer the `cloud/stable` channel.

This PR changes the following scripts:
- Discover Install Node
- Discover Install Database Service
- Install App script
- EC2 default-installer and EC2 default-agentless-installer

* add helm chart knobs to enable auto updater

* use let instead of const and remove default export

* add HA to helm chart

* always return .automatic_upgrades in web ping response

* rename cloud/stable to stable/cloud

* fix ts test
2023-03-28 16:05:09 +00:00