Commit Graph
51 Commits
Author SHA1 Message Date
Forrest Marshall ecef3465b6 instance heartbeats 2022-12-30 12:09:11 -08:00
Edoardo Spadolini 236b1b2f3c Remove the SQL backend (#17057)
* Revert "Azure AD authentication for the Postgres backend (#15757)"

This reverts commit 33c6d82dc3.

* Revert "SQL Backend (#11048)"

This reverts commit 06fef2abf1.

* Remove Postgres backend from the docs

* Remove the Postgres backend from the testplan
2022-10-07 10:40:44 +02: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
Vitor Enes f7634d1f72 Fix some typos in lib/ (#15556) 2022-08-23 07:34:36 +00:00
Tiago Silva 037daad083 Introduce dedicated server type for Kubernetes resources (#14389)
## What

First part of the Kubernetes [Discovery RFD](https://github.com/gravitational/teleport/pull/13376/) to introduce a Kubernetes server per cluster. 

This PR introduces a separate Kubernetes server that uses the already introduced `KubernetesClusterV3`. 

## Compatibility

In previous versions, Kubernetes Clusters were part of regular `ServerV2` resource and this refactoring deprecates the `ServerV2` usage but keeps them for compatibility with previous version.

Everything is backward compatible, so v10 kubernetes agents and trusted clusters can connect fine.

## Next steps

Once this is merged, a new PR will introduce dynamic registration for Kubernetes Clusters discovered through EKS Discovery.
2022-08-04 14:21:11 +00:00
Noah Stride 02b4f8575f Configure linter to catch British 🇬🇧 spellings 🇺🇸 🦅 📖 (#14363)
* configure golangci-lint misspell to check for anglicized spellings

* Americanize spellings

* fix aws constant value with british spelling 🇬🇧

* update api types with americanized spellings

* use american spellings .cloudbuild/scripts
2022-07-14 10:51:23 +00:00
Andrew LeFevre cc27d91a45 add ExactKey function to create absolute storage paths
Storage paths returned by Key do not contain a trailing slash, which will
cause range matching to match on paths that contain the original path as
a prefix. By using ExactKey, range matching will only match sub-paths.

Fixes #5188.
2022-05-06 09:49:38 -04:00
Jim Bishopp 06fef2abf1 SQL Backend (#11048)
Add a new backend supporting PostgreSQL and CockroachDB. 

Implements #10253 without cloud connectivity.
2022-03-29 00:18:09 +00:00
Jim Bishopp fe958969dc Remove migration from backend API (#10835)
The Migrate method on the Backend interface was not implemented by any
backends.

Migration should be implemented in the New method of backends so they
can be sure migration happens before any background processes are
started.
2022-03-08 03:08:09 +00:00
Lisa Kim 632d851783 Add KindWindowsDesktops to ListResources (#10769)
* Also add windows desktops sorter and its type converters
* Use forked vulcand/predicate library: allows traversing
  by embedded fields

Part of RFD 55
2022-03-07 08:58:26 -08:00
Lisa Kim 74a21212c3 Implement resource sorter for server, appserver, dbserver (#10243)
* Define sorters for resource Server, AppServer, and DbServer
* Add sorting to ListResources in caching and presence layer
* ListResources now returns nextKey set to the limit+1th item,
  previously it returned a possible next key, where there
  may or may not be more results.
2022-02-17 00:42:03 +00:00
Gabriel Corado 5f403562ab feat: ListResources gRPC rpc (#9096) 2021-12-15 18:09:21 +00:00
Isaiah Becker-Mayer 0a8b2abba6 simplify connection establishment (#9098)
* Adds username and initial screen size to the websocket parameter string and sends over tdp during the connection process

* simplifications from CR

* fixes // //
2021-12-01 20:48:07 -08:00
Forrest Marshall 19c5768873 server-side filtering 2021-10-22 16:42:33 -07:00
Andrej Tokarčík 4d0117b50d Migrate DynamoDB events to store fields as map type (#8292) 2021-09-29 03:47:14 -07:00
Zac Bergquist 7be6fa91e3 Improve FirestoreDB/KeepAlive test failure message (#8273)
This commit makes it easier to see what went wrong by:
- including information on how many events were received and expected
- making backend.Event a fmt.Stringer, so that we don't dump a []byte

Failure message before:

    --- FAIL: TestFirestoreDB (13.05s)
        --- FAIL: TestFirestoreDB/KeepAlive (10.01s)
            suite.go:487:
                	Error Trace:	suite.go:487
                	            				suite.go:461
                	            				suite.go:136
                	Error:      	Context expired waiting for event.
                	Test:       	TestFirestoreDB/KeepAlive
                	Messages:   	Captured so far: [{Put {[47 101 97 97 101 53 49 48 56 45 50 50 56 49 45 52 49 55 100 45 57 98 99 99 45 52 50 97 102 49 53 54 52 99 98 97 99 107 101 121] [118 97 108 49] 1984-04-04 00:01:02 +0000 UTC 449884801000000000 0}}]

Failure message after:

    --- FAIL: TestFirestoreDB (10.01s)
        --- FAIL: TestFirestoreDB/KeepAlive (10.00s)
            suite.go:487:
                    Error Trace:    suite.go:487
                                                            suite.go:461
                                                            suite.go:136
                    Error:          Context expired waiting for events.
                    Test:           TestFirestoreDB/KeepAlive
                    Messages:       Captured 1 of 2 so far: [Put /545e2ee9-3e40-4a0c-ba58-0882ab9024e7key=val1]
2021-09-15 12:49:12 -07:00
Brian Joerger b4e7cd3a5e Mask token in logs (#7955) 2021-08-31 11:11:23 -07:00
Brian Joerger 9b8b9d6d0c rollback - Upgrade api version. (#7751) 2021-07-30 15:34:19 -07:00
Brian Joerger c040aca4c1 Upgrade api version. (#7609) 2021-07-28 13:51:21 -07:00
Brian Joerger 20a734ec5d Paginated rpcs - Replace GetNodes with ListNodes (#7415) 2021-07-01 14:03:23 -07:00
Andrej Tokarčík 3d22eaac0e Turn AuditConfig into a standalone resource (#6997) 2021-06-14 15:49:22 -05:00
Brian Joerger 7bff7c41bd Remove API aliases (#6983) 2021-06-04 13:29:31 -07:00
Trent Clarke 3149d0b953 Enforce valid UTF8 keys on all backends.
The use of non-UTF8 keys with the DynamoDB back-end causes a failure
deep within the AWS request deserialization code, presenting a
non-obvious failure to the user.

This change adds validation to all backends that requires all keys
are valid UTF8 strings. It also adds a warning to the Backend
interface declaration that the keys may be constrained to valid
UTF8.

Other changes include:
 * Updating the `Backend` conformance test suite to not present binary
   keys to the various backend implementations.
 * Adding a `region` value to the DynamoDB configuration test input
 * Adding missing imports to `_test` files.
 * Updating build instructions in README
2021-03-19 17:14:05 -07:00
Brian Joerger 39eff6e625 Refactor OpType and constants from lib/backend into the types package. (#5241) 2021-01-12 10:47:30 -08:00
joerger f020f75078 Refactor API client into a separate package. 2020-12-29 10:06:37 -08:00
Andrew Lytvynov c68b571080 Add a Migrate method to backend.Backend
Unify migrations and expose them to the calling code at startup.
All backends except for etcd implement a nop migration.
2020-07-02 23:24:49 +00:00
Alexander Klizhentas 6b5935fb71 Use RADIX trees for prefix matching. (#2666)
Buffer fan out used simple prefix match
in a loop, what resulted in high CPU load
on many connected watchers.

This commit switches to RADIX trees for
prefix matching what reduces CPU load
substantially for 5K+ connected watchers.
2019-04-22 15:28:04 -07:00
Alexander Klizhentas 92e5bf5081 Fixes in DynamoDB event polling (#2661)
* Add resest for buffers to close watchers
and reset buffer the state.
* Add reconnect logic to DynamoDB
* Add tests for cache watchers, make sure
the errors of the cache internal watcher propagate to
external watchers.
2019-04-17 18:52:09 -07:00
Sasha Klizhentas 8356ae6a74 Use in-memory cache for the auth server API.
This commit expands the usage of the caching layer
for auth server API:

* Introduces in-memory cache that is used to serve all
Auth server API requests. This is done to achieve scalability
on 10K+ node clusters, where each node fetches certificate authorities,
roles, users and join tokens. It is not possible to scale
DynamoDB backend or other backends on 10K reads per seconds
on a single shard or partition. The solution is to introduce
an in-memory cache of the backend state that is always used
for reads.

* In-memory cache has been expanded to support all resources
required by the auth server.

* Experimental `tctl top` command has been introduced to display
common single node metrics.

Replace SQLite Memory Backend with BTree

SQLite in memory backend was suffering from
high tail latencies under load (up to 8 seconds
in 99.9%-ile on load configurations).

This commit replaces the SQLite memory caching
backend with in-memory BTree backend that
brought down tail latencies to 2 seconds (99.9%-ile)
and brought overall performance improvement.
2019-04-12 14:23:09 -07:00
Sasha Klizhentas f40df845db Events and GRPC API
This commit introduces several key changes to
Teleport backend and API infrastructure
in order to achieve scalability improvements
on 10K+ node deployments.

Events and plain keyspace
--------------------------

New backend interface supports events,
pagination and range queries
and moves away from buckets to
plain keyspace, what better aligns
with DynamoDB and Etcd featuring similar
interfaces.

All backend implementations are
exposing Events API, allowing
multiple subscribers to consume the same
event stream and avoid polling database.

Replacing BoltDB, Dir with SQLite
-------------------------------

BoltDB backend does not support
having two processes access the database at the
same time. This prevented Teleport
using BoltDB backend to be live reloaded.

SQLite supports reads/writes by multiple
processes and makes Dir backend obsolete
as SQLite is more efficient on larger collections,
supports transactions and can detect data
corruption.

Teleport automatically migrates data from
Bolt and Dir backends into SQLite.

GRPC API and protobuf resources
-------------------------------

GRPC API has been introduced for
the auth server. The auth server now serves both GRPC
and JSON-HTTP API on the same TLS socket and uses
the same client certificate authentication.

All future API methods should use GRPC and HTTP-JSON
API is considered obsolete.

In addition to that some resources like
Server and CertificateAuthority are now
generated from protobuf service specifications in
a way that is fully backward compatible with
original JSON spec and schema, so the same resource
can be encoded and decoded from JSON, YAML
and protobuf.

All models should be refactored
into new proto specification over time.

Streaming presence service
--------------------------

In order to cut bandwidth, nodes
are sending full updates only when changes
to labels or spec have occured, otherwise
new light-weight GRPC keep alive updates are sent
over to the presence service, reducing
bandwidth usage on multi-node deployments.

In addition to that nodes are no longer polling
auth server for certificate authority rotation
updates, instead they subscribe to event updates
to detect updates as soon as they happen.

This is a new API, so the errors are inevitable,
that's why polling is still done, but
on a way slower rate.
2018-12-10 17:20:24 -08:00
Sasha Klizhentas e84bf10889 Batch get for tunnel connection, remote cluster
Use batch fetch for tunnel connections
and remote cluster objects to speed up
teleport in scenarios with many trusted clusters.
2018-09-28 11:00:36 -07:00
Sasha Klizhentas bcc25f971f Upgrade etcd backend
New Etcd backend is using GRPC api v3,
dependencies were updated accordingly.
2018-09-10 15:58:05 -07:00
Russell Jones ce1c7476b9 Updated dir backend to a flat keyspace. Added UpsertItems endpoint to
all backends to support bulk insertion. Added UpsertNodes endpoint,
which is used by the state cache to speed up GetNodes.
2018-07-13 20:12:34 +00:00
Russell Jones 8d203821e6 Add support for GetItems to all backends. 2018-06-21 23:56:13 +00:00
Sasha Klizhentas 3e144cb900 Teleport certificate authority rotation.
This commit implements #1860

During the the rotation procedure issuing TLS and SSH
certificate authorities are re-generated and all internal
components of the cluster re-register to get new
credentials.

The rotation procedure is based on a distributed
state machine algorithm - certificate authorities have
explicit rotation state and all parts of the cluster sync
local state machines by following transitions between phases.

Operator can launch CA rotation in auto or manual modes.

In manual mode operator moves cluster bewtween rotation states
and watches the states of the components to sync.

In auto mode state transitions are happening automatically
on a specified schedule.

The design documentation is embedded in the code:

lib/auth/rotate.go
2018-04-30 12:58:57 -07:00
Sasha Klizhentas f2549155fd Update DynamoDB backend
* Add support for TTL
* Add support for Batch reads
* Update default values
* Use batch reads to retrieve nodes
2017-11-10 12:20:18 -08:00
Sasha Klizhentas 3c2570fa35 Sasha High Availability. 2017-04-07 16:54:15 -07:00
Sasha Klizhentas d6ff6f6204 Configure web session duration, fixes #691
* Fix bug with OIDC powered sessions logged out after 10 minutes
* Adjust web sessions durations by taking roles into account
* Provide explicit TTL enforced on the server side for bearer tokens

Before this PR the web session TTL was measured using defaults,
10 minutes for local sessions and 1 hour for OIDC sessions and
the system relied on client to renew the bearer token.

With this change bearer token TTL is set to 10 minutes
and the entire web session will expire if not renewed before

The maximum session duration is set to 12 hours, if not
limited to a smaller value by roles in RBAC modules.
2017-02-17 16:16:44 -08:00
Ev Kontsevoy 312af8f02d Converted DynamoDB and etcd to common backend API
TODO:
- fix etcd tests
- do some manual testing of all backends
2017-01-15 16:28:18 -08:00
Ev Kontsevoy eee8bac224 Added filesystem backend configuration parsing
+initialization
2017-01-15 16:28:18 -08:00
Ev Kontsevoy bdd46234ee Implemented backend.NewFunc() for the FS backend 2017-01-15 16:28:18 -08:00
Ev Kontsevoy 14fb2068db Removed backend.CompareAndSwap() method from all backends 2016-12-27 12:57:14 -08:00
Ev Kontsevoy 4ed536a2f0 First pass at cleaning up DynamoDB and locks
- Added ability to read AWS config from `~/.aws` directory for testing
- Fixed TTL bug in DynamoDB back-end
- Made FS back-end return similar error types as Boltdb does
- Cleaned up buggy tests for DynamoDB
- Removed unnecessary locks everywhere in code
2016-12-27 00:12:59 -08:00
Ev Kontsevoy 0d02c3be6f Removed backend.TouchVal()
It was never actually used in Teleport
2016-12-25 21:58:59 -08:00
Ev Kontsevoy 79c9f32f38 Removed backend.GetValAndTTL()
It was never used anywhere in actual Teleport code.
2016-12-25 21:58:59 -08:00
Adrien Pestel 436ee596b6 DynamoDB backend
This backend can be enabled by optionally adding a new build flag.
See lib/backend/dynamo/README.md for details.

It should not affect default Teleport builds.
2016-10-25 23:26:35 -07:00
Ev Kontsevoy 757c34a755 Added the ability to stop teleport without restarting the process 2016-04-03 12:17:28 -07:00
klizhentas 866b1e18c3 add support for session resizing 2016-03-01 13:19:43 -08:00
klizhentas 6cdaba2ef6 user mappings should be deleted if user is deleted, fixes #116
This commit includes refactoring and cleanup of cert authority sybsystem:

* User keys methods are deleted
* Authorities CRUD is simplified
* Lots of code removed
2016-02-17 15:29:01 -08:00
klizhentas 00ef621e6b Apply apache license to teleport 2015-10-31 11:56:49 -07:00