Commit Graph
97 Commits
Author SHA1 Message Date
Michael Wilson 8a13439fb8 The SAML IdP CA will be handled during auth.Init. (#22668)
When the SAML IdP CA was added, it was not added to `checkResourceConsistency`
during `auth.Init`. This made bootstrapping a fresh server from a cluster state
impossible from versions of Teleport that support the SAML IdP CA, as the
`auth.Init` process couldn't recognize the CA.

With this change, the SAML IdP CA is now handled properly by
`checkResourceConsistency`, which makes bootstrapping a cluster from a cluster
state possible again.

Closes #22662
2023-03-07 17:33: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
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
Marco André Dinis e861946ea1 PresetRoles: remove unecessary upsert when role doesn't change (#20824) 2023-02-02 12:33:26 +00:00
Andrew LeFevre e71f024a9f Add OpenSSH CA (#20020)
* WIP adding OpenSSH CA

* fix creating OpenSSH CA for tests

* fix a test name and tctl usage flag

* fix 'tctl status' not displaying openssh CA sometimes

* add OpenSSH CA to TestInit_bootstrap, remove TLS key pair

* add OpenSSH CA to a few more places

* make help text of 'tctl auth rotate' more helpful and accurate

* fix web cert export test

* tbot doesn't need to know about OpenSSH CA

* address feedback

* fix comment formatting
2023-01-13 18:23:19 +00:00
Hugo Shaka 4f89756d8b Add --apply-on-starup flag (#19009) 2022-12-06 15:50:52 +00:00
Jakub Nyckowski 9379243390 Use pre-generated RSA keys in tests (#18750)
Many of our tests (db package, I'm looking at you) generate many RSA keys. This has two main side effects; makes our tests slow and flaky as CPU usage spikes in random moments when the tests are run in parallel.
This change pre-generates RSA keys at the beginning of each test module and reuse them in randomized order to reduce the situation that one key has been used multiple times in one test.
I had to move a few files to avoid circular dependencies.
2022-12-05 19:33:49 +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
Nic Klaassen 847f13a8a9 refactor keystore config (#17907) 2022-10-28 11:30:49 -07:00
Alan Parra 57508a9e58 Address U2F sunset TODOs (#17030)
Address TODOs, add deprecation warnings and remove as many U2F code references
as possible.

Existing behavior is kept unaltered: it's still possible to inform Teleport of
old U2F AppIDs and U2F configurations are still silently converted to WebAuthn.
There's no reason to break that, so we don't.

Most server-side references to SecondFactorU2F are removed, but client-side
references remain: this makes it possible to interop newer clients with old
clusters (something else may break, but hopefully not this part).

Closes #10375.
2022-10-05 13:13:09 +00:00
Noah Stride 85c426bbcd Remove deprecated cert authority fields and migration (#16761)
* Remove old/deprecated cert authority migration

* Remove on-the-fly migration and deprecated fields

* Remove references to removed and deprecated key fields

* Fix tests for removed fields

* Fix tests that referenced deprecated fields
2022-09-28 17:30:34 +00:00
rosstimothy ebfbfd496e Use testauthority instead of native to generate keys in tests (#16486)
* use test authority

* use testauthority for InitConfig RSAKeyPairSource

* add named returns to test authority
2022-09-21 20:53:09 +00:00
Marco André DinisandRoman Tkachenko f8317dfaa7 Add Default Allow Rules for new resources (#16237)
* Add Default Allow Rules for new resources

When adding a new resource, we usually also set some default access
rules on the preset Roles (editor, access, auditor).

However, for existing clusters those new rules are not applied when we
start the cluster with the new teleport version.

This then requires manual intervention for setting up access to those
resources.

This PR adds a new mechanism to remove the need for manual intervention.

For each of the preset rules, we'll have default rules.
When the server starts, it tries to create the preset roles but if they
exist, instead of failing we will:
- check if the resource exists either in allow or deny rules
  - if so, then we don't do anything else
- add the default rule

This assumes it's ok to re-create the default rules when the admin
removes those resources from the allow/deny rule set.

* add log when adding default allow rules

Co-authored-by: Roman Tkachenko <roman@goteleport.com>
2022-09-14 01:50:41 +00:00
Noah Stride 071bb116bc Skip cache during CreateBot RPC (#14899)
* Skip cache during CreateBot RPC

* Adjust calls to use .Service rather than .Identity

* Switch to CreateRole from UpsertRole
2022-08-02 13:39:48 +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
Marco André Dinis 306d011151 Deprecate ca_signature_algo config (#13033)
After the merge of https://github.com/gravitational/teleport/pull/12674 we no longer use the following configuration:
```yaml
teleport:
    ca_signature_algo: "rsa-sha2-512"
```
As we now rely upon the `x/crypto` package to choose the signing algorithm (it defaults to `rsa-sha2-512`)

**Demo**
If we set `ca_signature_algo` (the value is irrelevant) and start `teleport` we get:
```shell
root@marco:/workspace# teleport start --debug
2022-06-02T09:33:58Z WARN             ca_signing_algo config option is deprecated and will be ignored, we'll always default to rsa-sha2-512. config/configuration.go:348
2022-06-02T09:33:58Z INFO             Generating new host UUID: b001159a-10e0-49a7-b4dc-61c73fbe9e42. service/service.go:726
...
```

Fixes #12905
2022-06-06 16:18:15 +01:00
Alan Parra 59fa9f0dae Drop validation and references to U2F Facets (#12892)
U2F facets don't serve a purpose since Webauthn became the de-facto MFA
mechanism. This should make it easier for users to write v10-style
authentication configs.

The remaining U2F fields are still relevant for when we derive Webauthn settings
from U2F, so those are kept (and validated).

Note that we still keep the fileconf field, since we don't want configs to
needlessly break during version upgrades.

#10375

* Remove references to U2F.Facets
* Remove Facets from U2F proto
* Reinstate proto Facets field

U2F gets marshaled as JSON to storage, so we better keep the field to
avoid issue with resource configs.

* Add deprecation notice on comment
* Update generated protos
2022-05-31 21:00:24 +00:00
Marco André Dinis 2493448cbd Bump x/crypto to 20220518 and remove custom algorithm signer (#12674)
This commit upgrades the version of x/crypto we use, to the current latest
`go get -u golang.org/x/crypto`

We also replaced the deprecated variables and updated the tests to match the
current default KEX Algos

The x/crypto didn't support RSA-SHA2 algos, so we developed our own algorithm
signer. This is no longer the case, and after upgrading x/crypto to 20220518 we
can safely remove the custom code we have.


From OpenSSH 8.8+, it works if we explicitly add the older algorithm
Somthing like this: `./ssh -vvv -oPubkeyAcceptedAlgorithms=+ssh-rsa-cert-v01@openssh.com teleportadmin@moon.marco.mydemo`
2022-05-25 14:47:00 +01:00
rosstimothy 9f094aaef6 Add tracing instrumentation for ssh clients/servers (#12434)
* Add tracing instrumentation for ssh clients/servers

Add tracing context to the existing ProxyHelloSignature to provide
span information across ssh connections. To add span context per
ssh session on top of new connections, the same tracing context is
passed in the first global request of the session.

In order to ensure that tracing context is pulled from and inserted
into the proper context.Context, some interfaces and methods were
changed to take one as the first argument.
2022-05-25 12:24:02 +00:00
Joel 99116409d4 Remove needlessly complex key generation scheme (#12113) 2022-04-25 09:26:10 +00:00
Jakub NyckowskiandMarek Smoliński 1aa38f4bc5 Create Database CA (#9593)
Introduce Database Certificate Authority. New CA is used by Database Access to sign database certificates making them independent from Host CA. 

Co-authored-by: Marek Smoliński <marek@goteleport.com>
2022-04-05 19:44:46 +00:00
rosstimothy 550d23d15d Fix goroutine and memory leak in watchCertAuthorities (#10871)
* Fix goroutine and memory leak in watchCertAuthorities

The CA Watcher was blocking both on writing to a channel when the watcher
was closed and on HTTP calls that had no request timeout or context passed
to cause cancellation.

All resourceWatcher implementations that had a bug which may cause them to block
on writing to a channel forever were fixed by selecting on the write and ctx.Done.

Adding context.Context to all Get/Put/Post/Delete methods on the auth HTTPClient to
force callers to propagate context. Prior all calls used context.TODO which
prevents requests from being properly cancelled.

Add context propagation to RotateCertAuthority, RotateExternalCertAuthority,
GetCertAuthority, GetCertAuthorities. This is needed to get the correct ctx
from the CertAtuhorityWatcher all the way down to the HTTPClient that makes
the call.

Closes #10648
2022-03-10 11:05:39 -05:00
JoelandZac Bergquist 62173e096b use google/uuid instead of pborman/uuid (#9793)
* replace imports

* use google/uuid

* fix test

* reverse changelog changes

* update gomod

* zac steps

* tidy

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
2022-01-19 23:44:48 +00:00
Forrest Marshall d2a55b62b8 fix racy test 2021-12-09 21:58:58 -08:00
Alan Parra 906227ab0f Make Teleport startup resilient to invalid roles (#9062)
Removing the old roles migration allows Teleport to start even in the face of
invalid roles. The system will still be largely unusable, but `tctl rm` is now
possible as a fallback.

Added logging makes it easier to determine the bad role.

Turns this scenario:

```shell
$ teleport start
> (...)
> ERROR: initialization failed
> could not parse 'where' rule: "!contains(ssh_session.participants, user.metadata.name)", error: ssh_session.participants is not defined
> (teleport exits)
```

into this:

```shell
$ teleport start
> (...)
> 2021-11-18T16:50:29-03:00 WARN [AUTH:1:CA] "Re-init the cache on error: role \"join_own_sessions_only\"\n\tcould not parse 'where' rule: \"!contains(ssh_session.participants, user.metadata.name)\", error: ssh_session.participants is not defined." cache/cache.go:725
> 2021-11-18T16:50:29-03:00 WARN [AUTH:1:CA] Cache "auth" first init failed, continuing re-init attempts in background. error:[
> ERROR REPORT:
> Original Error: *trace.BadParameterError could not parse &#39;where&#39; rule: &#34;!contains(ssh_session.participants, user.metadata.name)&#34;, error: ssh_session.participants is not defined
> Stack Trace:
> 	(...)
> User Message: role &#34;join_own_sessions_only&#34;
> 	could not parse &#39;where&#39; rule: &#34;!contains(ssh_session.participants, user.metadata.name)&#34;, error: ssh_session.participants is not defined] cache/cache.go:678
> 2021-11-18T16:50:35-03:00 WARN [AUTH:1:CA] "Re-init the cache on error: role \"join_own_sessions_only\"\n\tcould not parse 'where' rule: \"!contains(ssh_session.participants, user.metadata.name)\", error: ssh_session.participants is not defined." cache/cache.go:725
> (teleport running, tctl works)
```

See https://github.com/gravitational/teleport/issues/9059 for the larger
context.

* Remove Teleport 4.3 role migration
* Remove unused parameters
* Add role name to GetRoles validation failures
2021-11-19 14:56:14 -08:00
Zac Bergquist 01ced111f4 Add RBAC for Windows desktop access (#8520)
* Add RBAC for Windows desktop access

This commit adds RBAC checks for Windows Desktops as described in
RFD 33 and RFD 34:

- add Windows desktop logins & labels to role definition
- introduce new file config for host labels based on a regexp match
- auth server API performs access checking for Windows desktop resources
- add RDP client callback to authorize the user
- support user/role locks
- respect the client idle timeout setting

Note: in cases where an connection is terminated to to RBAC, the web UI
currently displays "websocket connection failed" because the connection
is closed from the server. We'll need to follow up with a nice error
message for the client side to improve the UX here.

Other changes:

* Remove OSS RBAC migration marked for deletion
* Stop creating a default admin role
* add wildcard desktop access to the preset access role

Updates #7761
2021-10-12 14:52:59 -06:00
Alan Parra 63d2250494 Remove pre-v7 device migration logic (#8448)
Follows up on a few `// DELETE IN: 7` TODOs.

* Remove pre-v7 device migration logic
* Fix godoc typos
2021-10-06 09:18:21 -07:00
Andrej Tokarčík bddc54d8c4 Remove ClusterConfig resource (#8150) 2021-09-23 13:56:35 -07:00
Roman Tkachenko e1c3f80aa0 Fixes for cert checker and Postgres config builder (#8251) 2021-09-17 13:28:40 -07:00
Zac Bergquist 839cdcfa97 Convert GenerateServerKeys to GRPC (#8193)
This commit contains 2 changes:

1. Rename GenerateServerKeys to GenerateHostCerts.
   This is a more accurate name and consistent with the existing
   GenerateUserCerts endpoint.
2. Change the request type to include a single role, rather than a
   list of roles. We only ever allowed a single role in the list
   anyway, so this change will prevent future mis-use of the API.

Note: a side effect of this change is we now have two similar endpoints:
- GenerateHostCert: old API that generates SSH cert only
- GenerateHostCerts: a newer API that generates SSH and TLS certs

To avoid making this change too big, we'll aim to deprecate
GenerateHostCert in the future.
2021-09-13 14:37:28 -07:00
Alan Parra b17f67dbeb Unparallel racy test (#8142)
Fixes raciness on TestInit_bootstrap.
2021-09-03 16:32:07 -03:00
Alan Parra 133ebcd454 Correctly validate JWT CA on bootstrap (#8119)
Presently, teleport start --bootstrap state.yaml fails due to incorrect
handling of JWT CAs, even when the data is generated using
tctl get all --with-secrets.

Fixes https://github.com/gravitational/teleport/issues/7853.

* Correctly validate JWT CertAuthorities on bootstrap
* Remove commented code
2021-09-02 07:09:00 -07:00
Andrej Tokarčík f97b7c09d3 Reject cert generation requests for locked-out users/hosts (#7746) 2021-08-12 19:52:13 +02: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
Andrej Tokarčík b4f1b8c265 Fix RBAC verbs checked for SetSessionRecordingConfig (#7466) 2021-07-20 21:22:22 +02:00
Nic Klaassen c50f4465f4 Use ssh.Signer instead of raw private keys (#7438)
* use ssh.Signer for (Host|User)CertParams
2021-07-06 10:13:09 -07:00
Andrej Tokarčík b503661240 Fix occasional data race when testing dynamically configurable resources (#7374) 2021-06-22 15:53:33 +02:00
Andrej Tokarčík 10a43dbf30 Relax ClusterName validation to allow ClusterID migration (#7363) 2021-06-21 17:09:30 +02:00
Brian Joerger bd07d7be20 CheckAndSetDefaults sets all defaults. (#6846) 2021-06-18 12:57:29 -07:00
Brian Joerger 917df5ad02 gRPC conversions - Auth Preference (#7220) 2021-06-18 12:30:56 -05:00
Andrej Tokarčík d63d144e8e Move ClusterID field from ClusterConfig to ClusterName (#7050) 2021-06-18 18:42:09 +02:00
Andrew Lytvynov d4247cb150 hsm: migrate CA storage schema (#7245)
* hsm: migrate CA storage schema

Migrate types.CertAuthorityV2 schema according to
https://github.com/gravitational/teleport/blob/master/rfd/0025-hsm.md#backend-storage

Includes proto changes, types.CertAuthority wrapper changes and data
migration.

Note that we keep and update the old fields for backwards-compatibility.
If a cluster is upgraded to v7 and then downgraded back to v6,
everything should keep working.

* Address review feedback
2021-06-16 12:17:03 -05:00
Andrej Tokarčík 3d22eaac0e Turn AuditConfig into a standalone resource (#6997) 2021-06-14 15:49:22 -05:00
Andrej Tokarčík 9410346b8d Make SessionRecordingConfig resource dynamically configurable (#7054) 2021-06-08 08:30:44 -07:00
Brian Joerger 7bff7c41bd Remove API aliases (#6983) 2021-06-04 13:29:31 -07:00
Andrej Tokarčík 3ca21aca9a Make ClusterNetworkingConfig resource dynamically configurable (#7013) 2021-06-04 19:42:50 +02:00
Andrej Tokarčík 555695dfdd Introduce SessionRecordingConfig extracting fields from ClusterConfig (#6708) 2021-05-19 12:01:37 -07:00
Andrej Tokarčík ad00c6c789 Introduce ClusterNetworkingConfig extracting fields from ClusterConfig (#6638) 2021-05-07 13:54:08 +02:00