Commit Graph
244 Commits
Author SHA1 Message Date
Gavin Frazar 12c113bc84 add GCP Spanner (#40859) 2024-05-07 22:21:27 +00:00
Isaiah Becker-Mayer b878fd077d Cleanup regular.Server (#40723)
* remove unused default shell setting

* remove unused nodeWatcher

* remove unused caGetter

* cosmetic
2024-04-22 21:17:10 +00:00
Edoardo Spadolini bd47f0e02a Improve Teleport reload behavior (#37773)
* clean up pidfile and reloads

* reduce log spam during graceful shutdowns

* hold an exclusive advisory lock on the pidfile

* do systemd reloads with the pidfile rather than $MAINPID

* prioritize signals over internal restarts
2024-02-13 15:27:54 +00:00
Marco André Dinis dc6cd0d9be Move TokenLenBytes to defaults package (#37254)
Some consts in the `auth` package are used in a lot of other packages.
This increases the probality of getting a cyclic dependency error.

This PR moves some of those consts to the defaults package and updates
all the required locations of their usage.

Only one is missing in the `/e/` repo, which I'm going to open a PR for
it.
After merging, we can also remove the `lib/auth.TokenLenBytes`
2024-01-25 18:30:43 +00:00
Mike Jensen 09a33d86d6 Remove account lockout from failed recovery attempts (#35325)
* Remove account lockout from failed recovery attempts

This account lockout looks to be unecessary and potentially problematic.  Recovery codes and recovery through MFA are not possible to brute force.

In addition the potential to lockout an account from being able to use a recovery method could result in them being unable to unlock their account from other potential abuse cases (for example an attacker locking the account from failed password attempts).

As discussed in the RFD (https://github.com/gravitational/teleport/pull/35533) this includes the removal of all the API used for this locking mechanism.

* accountrecovery: Update `WithLock` function names

* accountrecovery: Combine verifyRecoveryCode and verifyRecoveryCodeWithRecord into one function

* Further GRPC cleanup after PR feedback

* Apply PR Feedback
2024-01-24 18:17:52 +00:00
Reed Loden d14548746c Update FIPS algorithms inline with upstream x/crypto/ssh proposed changes (#36685)
`x/crypto/ssh` is adding a `fipsonly` mode (similar to `crypto/tls/fipsonly`) in
golang/go#64769. Once this has landed and been released, we'll swap to using it.
In the meantime, update our hardcoded algorithm set to match the algorithms listed
in https://go-review.googlesource.com/c/crypto/+/550515.

The only difference is that `aes192-ctr` is kept in `FIPSCiphers`, as it seems to be
approved by NIST SP 800-131A rev 2 (page 17).

Additionally, we now define a list of approved public key authentication algorithms for
SSH server connections. This isn't configurable for normal use case (yet), only handled
for FIPS builds.
2024-01-15 17:36:35 +00:00
Reed Loden 95aa537f68 Increase minimum password length and account lock interval (#36389)
* Increase `MinPasswordLength` from 6 to 12 characters
  - PCI DSS v4.0 control 8.3.6 requires a minimum password length of 12 characters.
  - NIST SP 800-63B section 5.1.1.1 requires a minimum password length of 8 characters.

* Increase `AccountLockInterval` from 20 to 30 minutes
  - PCI DSS v4.0 control 8.3.4 requires a minimum lockout duration of 30 minutes.

This will contribute to better supporting customers to meet certain compliance requirements.

Ref #1936.
Ref #7687.
2024-01-10 04:11:28 +00:00
Mike Jensen b92b1a5a0c Update direct go-jose usage to v3 (#36435)
This updates all direct usage of go-jose to v3.  V2 has been deprecated and is no longer supported.
2024-01-09 01:16:08 +00:00
Zac Bergquist 44a6bb1933 Use pkg slices from the standard library (#35905)
Prefer the stdlib version of the experimental package.
Includes a depguard update to prevent future regressions,
as well as an e-ref update to appease depguard.

Generated with:

    $ gofmt -w -r '"golang.org/x/exp/slices" -> "slices"' . && \
        make fix-imports
2023-12-19 23:06:53 +00:00
rosstimothy 26ae87a4fa Detect and report latency measurements for SSH sessions in the UI (#34862)
Monitors both the UI<->Proxy and Proxy<->SSH host connections in
order to provide users with near real time latency data for ssh
connections established via the UI. The client portion of the
connection is measured by how long it takes to receive a web socket
pong in response to sending a web socket ping. The host portion of
the connection is measured by how long it takes to receive a reply
of a keepalive@openssh.com global SSH request. The statistics are
periodically sent via a new envelope type over the web socket where
they are consumed and displayed to users.
2023-12-06 22:34:50 +00:00
fheinecke b178b8b732 Updated Teleport codebase to AGPL3 license (#35259)
Signed-off-by: Fred Heinecke <fred.heinecke@goteleport.com>
2023-12-01 17:48:14 +00:00
Anton Miniailo 6d873431da Fix headless login timing out prematurely (#34163) 2023-11-03 16:29:17 +00:00
Mike Jensen 05adc2d422 Limit GRPC Active streams (#33936)
Originally there was a default limit of 100 max concurrent streams, however in 2017 the GRPC team removed this default: https://github.com/grpc/grpc-go/pull/1624

With the recent HTTP/2 Rapid Reset DoS, it is now being encouraged to re-introduce a limit.  The fix requires this value to be configured in fact: https://github.com/grpc/grpc-go/pull/6703
2023-10-27 15:26:07 +00:00
Brian Joerger 5b850c9bfd Extend handshake read deadline to allow signature operations that require user input to be completed (hardware key touch/pin). (#32921) 2023-10-09 19:14:38 +00:00
Marco André Dinis 44209ce8dc DiscoveryMatchers: move checkandset to types package (#32857)
* DiscoveryMatchers: move checkandset to types package

* add opensearch to iamrole as users
2023-10-04 13:48:09 +00:00
Rafał Cieślak 847a1b1167 Implement waiting for Connect My Computer node to join cluster (#30905)
* Add daemon.Service.ResolveClusterURI

* Accept agents dir through command line flag

tshd needs to know this out of band, so that when the Electron app tells
it to watch for host UUID file for a specific cluster, the Electron app
can send just the profile name of the cluster instead of an arbitrary path
on the computer.

* Implement WaitForConnectMyComputerNodeJoin in tsh daemon

* wait: Use addEventListener instead of onabort

* Make TshAbortController emit abort event only once

This aligns it with a regular AbortController, which also emits the event
only once.

* Refactor how types are imported in tshd fixtures

* Implement WaitForConnectMyComputerNodeJoin in Electron app

* createAbortController: Add signal.aborted, use emitter.once

* Improve wait function based on Deno implementation

https://github.com/denoland/deno_std/blob/72d6e6641e3cd39ae69fba89a78feab354018ef0/async/delay.ts#L39

* Add a comment about the events package
2023-09-21 11:43:10 +00:00
Michael 9c55a33e01 Add Unified Resource watcher (#28296)
* Adds a UnifiedResource watcher to the auth server. This watcher
will watch all the types that are displayed in the web UI and store
them in-memory to allow us to search/filter/query and get multiple
kinds returned at the same time.
[RFD](https://github.com/gravitational/teleport/pull/28162)

* Add ListUnifiedResources gRPC and web endpoints (#29661)

Adds the `ListUnifiedResources` grpc endpoint that returns paginated unified resources and exposes it in the web apiserver

* Fix test
2023-08-14 21:13:46 +00:00
Mike Jensen b7f571b00d Consistent http.Server timeout configurations (#30248)
* Consistent `http.Server` timeout configurations

This commit builds on the work from https://github.com/gravitational/teleport/pull/30151 in the following ways:
* A couple additional server configuartions that were missing timeouts are now covered
* Timeouts are now configured in a consistent way.  This means:
  - Configuring the `ReadTimeout` which was not covered by only setting `ReadHeaderTimeout`
  - Set `ReadHeaderTimeout` to be the more aggressive (1 second) `defaults.ReadHeadersTimeout`
  - Set a `WriteTimeout` in cases of potential large responses

* defaults.go: Update ReadHeadersTimeout to 10 seconds

* alpnproxy/local_proxy.go: Move http timeouts to the top
2023-08-11 15:48:38 +00:00
Andrew Burke 013f23d4e5 Add GCP VM auto-discovery (#28562)
This change adds node auto-discovery for GCP VMs.
2023-07-25 19:27:01 +00:00
Marek Smoliński 3160e90119 Add ClickHouse DB Engine (#27004) 2023-07-21 15:19:24 +00:00
Michael f814b2d510 Add sshserver file transfer handlers (#24580)
Add web terminal handlers for file transfer requests (#24581)
2023-05-03 20:53:57 +00:00
Mike Jensen d16a3b18f1 Rate limit all unauthenticated HTTP endpoints (#24623)
* Rate limit all unauthenticated HTTP endpoints

This commit is an extension to what was done in #172. And is designed to fix https://github.com/gravitational/teleport/issues/4330 and https://github.com/gravitational/teleport-private/issues/403.

Rather than audit endpoints and choose what endpoints should be rate limited, this commit proposes that for safety and reduced cognitive load, all unauthenticated endpoints become rate limited.

The primary concern in this type of change would be if our rate limit becomes too aggressive for general use.  There are two considered strategies to make sure this does not become impacting:
1. Adjust the rate limiter so the rate limit becomes endpoint specific.  This would avoid the need to consider how activity on one endpoint effects another.
2. Accept that rate limit interactions are possible and instead ensure rate limits are high enough to avoid this concern.

This commit chooses option #2.  While #1 has advantages, particularly as endpoints and new use cases are added.  #2 provides the strictest and safest rate limits.

Our rate limits were configured to:
period: 1 min
avg rate: 10
burst rate: 20

In order to build a safety buffer with option #2 those allowed rates were doubled.

Additionally the ability to avoid rate limits by authenticating your request (even if the endpoint is otherwise unauthenticated) was added.  This is particularly useful for the `ping` endpoint which may have high levels of activity on large clusters, but which has a portion of that activity over authenticated requests.

* Add additional `High` Rate Limiting

This new `High` rate limit is designed for endpoints which are only CPU bound (and thus don't have as significant of DoS risks).
Initially this was motivated for `ping` and `find` due to the concern that these endpoints are used unauthenticated at login, and potential NAT's may result in very high rates from single egress IP's.
In my testing on my laptop, all of these endpoints can easily get 640/req/sec on a single core within a VM.  Setting the maximum of 480 burst and 120 continuous should both ensure that no single source utilizes all the CPU, as well as build in additional safety margins while providing a layer of protection.

* Fix for missing error check
2023-05-01 21:54:22 +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
Krzysztof Skrzętnicki 2af9d76ec0 AWS-hosted OpenSearch support (#23305)
* AWS-hosted OpenSearch support.

* Review: comments, case, cleanup.

* Review: comments, region discovery, typos, shared func, fix error type, fix empty CA case.

* Review: address comments.

- add docs
- refactor opensearch engine code
- make `opensearchsql` default client
- drop utils.CloneRequest function, it is not suitable for general use
- drop "extra args" functionality, it should be a separate PR and more generic
- minor refactorings

* Fix: linting, refactoring issues.

* Review: update the comment for accuracy.

* Correct merge issue.

* Review: reuse transport, use different context, rename tests

* Review: unexport internal error types, explicitly test the error serialization.
2023-04-13 06:14:39 +00:00
Andrew LeFevre 40c113b8da refactor SFTP backend to use upstream dep, not our fork (#23786)
* refactor SFTP backend to use upstream dep, not our fork

This change also greatly reduces the number of SFTP audit logs.
Now SFTP events are only sent when files are opened or modified
in any way, instead of for *every* SFTP request.

* added to SFTP integration test

* fix error when handling setstat on dirs

* fix linter warning

* move file/dir permission constants to lib/defaults package
2023-04-07 01:51:22 +00:00
Marek Smoliński 0f3c14e0f9 Add Support for Oracle protocol (#23227) 2023-03-31 17:35:21 +00:00
Forrest 924dcdd664 reduce cache retry load (#23025)
* add exponential backoff

* improve cache backoff
2023-03-21 05:03:51 +00:00
Forrest aaee695927 node hb and watcher scalability improvements (#21490)
* node hb and watcher scalability improvements

* ensure that node has ample time to hb

* fix degraded state

* hbv2 test cov
2023-03-03 17:39:00 +00:00
Andrew Burke e28d969fdc Add Azure auto-joining (#21087)
This change adds the ability for Azure virtual machines to automatically
join a Teleport cluster.
2023-03-01 22:18:43 +00:00
Alex McGrath 66985553db Add agentless installer in the teleport discovery service (#19648)
* Add agentless installer

* Resolve comments

* Resolve comments

* Use GetCertAuthorities locally

* Try to get IMDS hostname

* Try get imds hostname first

This seems to be how its implemented for non-agentless nodes

* Use FIPS cipher suites

* use the openssh ca, resolve comments

* write keys to /etc/teleport/agentless by default

* Resolve comment

* lints

* test fixes
2023-01-24 14:49:06 +00:00
Gavin Frazar 5bb0ef15db add dynamodb database access (#18843)
* Add a new db engine
* Add tests for new engine
* Update tsh db subcommands
* Refactor error message and suggestions for unsupported tsh commands
* Add dynamodb to test plan
* Add AWS external ID to db config and update protos
2022-12-30 18:22:30 +00:00
Zac Bergquist 166dc5a1be Clean up defaults (#18860)
- Make vars const where possible
- Move constants that are only used by the audit log into lib/events
- Remove unused vars
2022-11-30 15:50:29 +00:00
Jeff Pihach 7e64ae32ba Generate new session on new ssh websocket connection. (#18523)
SSH Sessions from the UI are now managed under a single websocket connection instead of through multiple HTTP and WS calls.
2022-11-28 21:26:57 +00:00
Noah Stride f5b8aa7928 Remove unused CheckPassword Auth HTTP endpoint (#18677)
* Remove unused CheckPassword endpoint

* Remove unused context key
2022-11-22 15:45:04 +00:00
Zac Bergquist da7680ad0b Use x/exp/slices instead of home grown utilities (#18524)
We were inconsistent throughout the codebase and would sometimes
use the slices package and other times use our own equivalents
in api/.

This removes our versions in favor of the golang.org/x package that
does the same, which has the added benefit of reducing the surface
area of the public API module.

Note: despite existing uses of the slices package, for some reason
it didn't show up in go.mod or go.sum. Fixed that too.
2022-11-17 15:25:46 +00:00
Jakub Nyckowski 0ee91f6c37 Enable GCI linter (#17894) 2022-10-28 20:20:28 +00:00
Marek Smoliński 7aa224e430 Add Cassandra/Scylla database support (#15895) 2022-10-10 12:37:51 +02:00
Zac Bergquist 7f1f8ec098 Remove upload completer grace period (#16809)
The 24-hour grace period was kept in Teleport 10 for backwards
compatibility, but is no longer necessary for Teleport 11 due
to the session tracker system.

As a result, it takes about an hour to complete an abandoned upload
instead of 24 hours.
2022-09-29 13:18:52 +00:00
Ryan Clark 806a568ada Introduce config v3, add auth_server and proxy_server, remove auth_addresses (#15761) 2022-09-28 15:30:15 +00:00
Krzysztof Skrzętnicki 684956a06c Elasticsearch audit log support (#16191) 2022-09-23 11:46:15 +00:00
Alan Parra 65e0116512 Remove HOTP support (#16579)
While looking up github.com/gokyle/hotp I found some old deprecation warnings
and decided to address them.

* Remove HOTP support
* Update comment on checkOTP
* Remove OTPType
* Remove a few more HOTP references
2022-09-21 17:50:33 +00:00
Alex McGrath e2fab63ba9 Introduce discovery_service and automatically run an SSM Document on discovered EC2 nodes (#14094)
* Add initial version of installer

* Resolve comments

- Use aws waiters when checking commands
- Use SSMRunRequest rather than passing instances
- General comments

* Resolve comments, (rebase) pass scriptname parameter

This resolves comments regarding running on multiple ec2 instances at
once by adding state to the instances cache to check if the instance
is known about and how far into installation it is

* Revert cache

* Dont cache on non discovery nodes

* Resolve some comments

* Move discovery out to its own serviec

* Add a `discovery_service` section

* Fix messed up conflict merge

* Make starting a standalone discovery agent work

* Resolve comments

* Resolve comments

- use a regular events.Emitter
- resolve a thousand typos :)

* Resolve comments

* resolve comments, fix a bad merge

* Fail when a non ec2 matcher type is configured

* fix lint-go

* Resolve comments

* Resolve comments, add initial test (currently broken)

* Fix log string so only 1 pair of [] are used

* Chunk instances for sending commands

* add 'isInitialized' to watchers

* Add test for chunked discovery, log output

* lints

* explicetly set matcher.Tags to "*":"*" if its unset
2022-09-21 12:23:06 +00:00
Alan Parra a75fcc21d8 Update golangci-lint to 1.49.0 (#16507)
Update metalinter, fix a few lint warnings and replace deprecated linters.

`deadcode`, `structcheck` and `varcheck` are abandoned and now replaced by [`unused`][1].

Since 1.19, `go fmt` reformats godocs according to https://go.dev/doc/comment. I've done a bulk-reformatting of the codebase to keep the linter happy. Backporting is mostly harmless (the exception being `lib/services/role_test.go`, that for some reason breaks the _old_ linter using the new format).

[1]: https://golangci-lint.run/usage/linters/

* Bump golangci-lint version
* Replace abandoned linters
* Fix bodyclose on lib/auth/github.com
* Fix bodyclose on lib/kube/proxy/streamproto/proto_test.go
* Fix bodyclose on lib/srv/alpnproxy/proxy_test.go
* Fix bodyclose on lib/web/conn_upgrade_test.go
* Silence staticcheck on lib/kube/proxy/forwarder_test.go
* Silence staticcheck on lib/utils/certs_test.go
* Address BuildNameToCertificate deprecation warnings
* Run `go fmt ./...`
* Run `go fmt ./...` on api/
* Ignore formatting in role_test.go
* Remove redundant initializers in lib/srv/uacc/
* Update e/
2022-09-19 22:38:59 +00:00
Andrew LeFevre 4d25801fab Deny Github organizations using external SSO on Teleport OSS (#14529)
* added check that blocks enterprise Github organizations using external SSO from using Github auth connectors on Teleport OSS

* added details to docs and changelog

* move check from init to on login

* cache org sso status; address small pieces of feedback

* use utils.FnCache instead of 3rd party cache

* addressed feedback

* addressed feedback

* revised docs

* addressed more feedback

* remove notes in changelog

* removed unused interface
2022-09-16 16:14:15 -04:00
44b89c75c0 Elasticsearch support (#15768)
Co-authored-by: Anton Miniailo <anton@goteleport.com>
Co-authored-by: Marek Smoliński <marek@goteleport.com>
2022-09-05 18:58:21 +02:00
Gabriel Corado a3a65e863b TLS routing ping for database protocols (#14887) 2022-08-26 16:42:23 +00:00
Edward Dowling c96134b66c Edwarddowling/recording ls bugs (#15558) 2022-08-25 09:59:55 +00:00
STeve (Xin) Huang 9b7f023c1f Show proper error message when "tsh db env/config" are not supported (#14971) 2022-08-22 15:56:20 +00:00
Alex McGrath 122bda9ad0 Add an AWS EC2 instance fetcher (#13886)
* Add an AWS EC2 instance fetcher

* Resolve comments

- Remove leftover VPCID stuff
- Document public functions
- Return a notfound when there are no nodes fetched instead of nil nil

* Resolve comments

* Fix fileconf_test.go
2022-08-19 10:52:42 +00:00
Edward Dowling be1438aecd tsh: tctl: Add basic recordings ls functionality (#12763) 2022-08-09 11:22:14 +00:00