Commit Graph
520 Commits
Author SHA1 Message Date
Lisa Kim 8bb0636863 Partial delete deprecated code for "DELETE IN 11.0.0" and lower (#16947)
* Deleted 
   - GetAppServers
   - GetApplicationServers 
   - GetDatabaseServers 
   - GetKubeService 
   - UpsertAppServer
   - DeleteAppServer
   - DeleteAllAppServers
   - RotateUserTokenSecrets
* Delete list nodes fallback
* Use AppServer type for heartbeat test
2022-10-04 17:58:30 +00:00
Alan Parra 2b44e5f23e Bump golangci-lint to 1.50.0 (#16966)
Update golangci-lint to v1.50.0 and fix a few linter issues.
2022-10-04 17:28:23 +00:00
Mike Wilson a4af8ae256 Revert "Ensure audit logging of tsh app login."
This reverts commit 31859e5d30.
2022-10-04 11:14:12 -04:00
STeve (Xin) Huang d319ee2734 Azure Cache for Redis auto discovery (#16755) 2022-10-03 20:54:44 +00:00
Noah Stride eb42cabbea Revert "Introduce ProvisionTokenV3 (#16361)" (#16934)
This reverts commit 3fba50261f.
2022-10-03 14:14:01 +00:00
Brian Joerger 92c7432197 PIV touch prompt (#16781) 2022-10-01 01:19:49 +00:00
Brian Joerger ce20b20753 PIV login enforcement (#15874)
Add private key policy enforcement.

  - Add private key policy cert extensions and enforcement.

  - Add private key policy settings and attestation logic.

  - Wire attestation request through login endpoints.

  - Store attestation data for reissue requests.

  - Add private key policy discovery and logic.

  - Relogin on hardware key policy errors.

  - Include integration with Teleport Connect.
2022-09-30 23:27:48 +00:00
Yassine Bounekhla 09633dd47f Remove license feature flags for Moderated Sessions, Resource Access Requests, Machine ID (#16585) 2022-09-30 21:46:25 +00:00
Nic Klaassen 60950a9aa0 security: log non-interactive SSH commands at beginning of session (#16872)
* include exec command in session.start.initial_command

* trim oversized events
2022-09-30 19:57:01 +00:00
Alan Parra e61da10df2 Update (even more) Go dependencies (#16900)
Do another large batch of dependency updates.

Most updates are around minor versions, so _theoretically_ safe. The following
v0.x updates draw attention:

* cloud.google.com/go/iam (likely safe, as Google is largely trunk-based)
* github.com/Microsoft/go-winio

Notable exceptions are k8s-related modules, which are harder to update for
various reasons.

* Update Go dependencies
* Fix lib/srv/app/aws/endpoints_test.go
2022-09-30 19:22:35 +00:00
Alan Parra dd3a884abe Drop direct dependency on github.com/golang/protobuf (#16898)
Drop dependency on the (superseded) github.com/golang/protobuf and add a
depguard.
2022-09-30 18:19:44 +00:00
Forrest Marshall 3533dd3e36 local alert resync 2022-09-30 10:48:12 -07:00
Mike Wilson 31859e5d30 Ensure audit logging of tsh app login.
Application sessions were previously only logged when launching an application
session via the UI, and not from the `tsh app login` command. This has been
corrected. The AppName and AppURI are now passed in as part of the gRPC
request to the auth server, which is then used to emit the audit event.
2022-09-30 12:53:13 -04:00
Alan Parra 5cda242067 Update various Go dependencies (#16861)
Update various "assorted" dependencies, that either are used throughout
(logging, testing), are mostly algorithmic or otherwise difficult to pinpoint
"ownership".

I've dropped a couple of deprecated/mostly meaningless dependencies. I suspect
`github.com/mitchellh/mapstructure` could be dropped to, but I didn't look
further now.

* Drop dependency on Clever/go-utils
* Drop dependency on github.com/pkg/errors
* Update various Go dependencies
* Use CompareAndSwap instead of CAS (uber/atomic)
* Add a comment after replaced dependencies
2022-09-30 14:01:51 +00:00
Joel da7316973c Validate SAML connectors upon creation (#16565) 2022-09-29 18:46:08 +00:00
STeve (Xin) Huang aabced42dc Azure Cache for Redis engine support (#16551) 2022-09-29 18:25:53 +00:00
Andrew Burke ac257084a7 Automatically import Azure tags (#16218)
This change lets Teleport automatically import tags from the Azure instance it's running on.
2022-09-28 23:40:13 +00:00
Alex McGrathandReed Loden 9535cd0a7b Retrieve an IMDS token in the default ec2 discovery installer (#16664)
* Retreive an IMDS token in the default ec2 discovery installer

* Update api/types/installers/installer.sh.tmpl

Co-authored-by: Reed Loden <reed@goteleport.com>

Co-authored-by: Reed Loden <reed@goteleport.com>
2022-09-28 19:26:48 +00:00
Forrest Marshall 0e6b90071f security patch alerts 2022-09-28 11:06:18 -07: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 aee7a38e59 Update github.com/russellhaering/gosaml2 to latest version (#16775)
Our fork is no longer needed now that https://github.com/gravitational/gosaml2/pull/4
has landed upstream https://github.com/russellhaering/gosaml2/pull/91.
2022-09-28 15:53:16 +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
Noah Stride 3fba50261f Introduce ProvisionTokenV3 (#16361)
* Introduce proto types for ProvisionTokenV3

* Add methods to ProvisionTokenV3 to support ProvisionToken iface

* Start building v3 support into the client

* add support for mashalling and unmarshalling ProvisionTokenV3

* Start unit testing ProvisionTokenV3

* Remove oneof to support yaml marshal/unmarshal

* Client should try V3 methods and fallback to v2

* More tests

* Fix join tests

* Fix integration tests

* Switch integration tests to use v3 spec

* Switch iam tests to use ProvisionTokenV3

* Change ec2 join tests to use V3 tokens

* Fix events tests for V3 token

* support ProvisionTokenV3 within API client events handler

* Explicitly specify JoinMethod

* Tidy up final usage of NewProvisionTokenV2FromSpec in tests

* Improve proto docs on ProvisionTokenV3

* Fix bot join tests

* Clarify error message for invalid join method

* Adjust resource version comment

* Fix comments and return error rather than bool in V2() method

* Catch incompatible conversions case

* Include V2 ProvisionToken in tests and add appropriate DELETE IN notes

* Fix linter warnings/unit test failures

* Use nolint rather than lint:ignore

* Add more DELETE IN notes

* Run goimports on join_ec2_test.go

* Address PR comments from tim.

* Add more deprecation/delete in notices

* Improve godoc comments on checkAndSetDEfaults for provider config

* Simplify implementation by dropping client-ahead compatability

* Add some support for client-ahead but with conversion to v3

* Update code comments to include responsible party

* Rename `Role` to `RoleARN` in EC2 configuration for clarity

* Fix tests for Role -> RoleARN rename

* Move MustCreateProvisionToken out of API and into test packages

* Properly go imports files
2022-09-27 17:05:32 +00:00
Krzysztof Skrzętnicki c07d92c6d5 Add json tags for proto fields. (#16750) 2022-09-27 12:15:53 +00:00
Alan Parra 3fe648485d Update golang.org/x/ dependencies in api/ (#16596)
Update crypto and net in api/, plus pull a few commits that just landed.
2022-09-26 22:44:29 +00:00
rosstimothy 0ec2116ba2 Provide proxy listener mode from reversetunnel.Resolver (#16434)
By only providing the tunnel address from the `reversetunnel.Resolver`
callers would still need to lookup the proxy listener mode to determine
how to dial the address. This results in sending a request to
`/webapi/find` once by the resolver to get the tunnel address and then
a second request to `/webapi/find` by users of the `Resolver` to determine
the proxy listener mode. Propagating the listener mode along with the
tunnel address by the `Resolver` ensures only one `/webapi/find` call
is needed.

This is especially impactful because the `reversetunnel.TunnelAuthDialer`
which is used by the auth http client would do this everytime the
`http.Client` connection pool was empty. When the `http.Client` needed
to dial the auth server it was incurring the additional roundtrip to the
proxy.
2022-09-26 20:15:32 +00:00
Zac Bergquist aa136e7e8a Run a single uploader service per process (#14521)
Prior to this change, each individual service (proxy, app, SSH, db, etc)
would spin up its own uploader service. If you are running multiple
Teleport services in the same process, this means you get multiple
uploaders all looking at the same directory, which can result in
duplicate upload events in the audit log.

Additionally, desktop access has (mistakenly) failed to set up this
service, so desktop sessions would only be uploaded if you happened
to also run some other service in the same process that does spin up
the uploader.

Solve these issues by centralizing the uploader service so that it
runs once per process, and each Teleport service doesn't need to think
about whether or not the service should run.
2022-09-25 22:33:46 +00:00
Ryan Clark 9f9461d5f0 Add labels to Windows Desktop Service, add endpoint for searching them (#16436) 2022-09-23 22:08:04 +00:00
Brian Joerger 4c0a6ff5b1 tsh PIV login integration (#15335)
* Add Yubikey PrivateKey implementation for use by Teleport clients.

  - Add yubikey login logic, reusing previously stored private keys.

  - Fix identity file decoding with PIV keys, which sign ecdsa certificates.

  - Add libpcsclite-dev pre-req for building on linux.

  - Remove unnecessary keys.Signer interface and move its functionality to keys.PrivateKey.

  - Move retry and jitter utils to new api/utils/retryutils package.
2022-09-23 19:44:10 +00:00
Tiago Silva 45c065acee Adds kube_cluster watcher for kubernetes service (#16281)
This PR presents a watcher for dynamic `kube_cluster` resources. The cluster credentials can be set using a `kubeconfig` whose payload is defined in `KubernertesClusterV3.Spec.Kubeconfig`. These credentials are used to connect to the Kubernetes API server and if invalid, the cluster is not served and returns an error.

Currently, `kube_cluster` resources created via the API with a kubeconfig payload can be dynamically served by the `kubernetes_service` by enabling dynamic resources.

```yaml
kubernetes_service:
   enabled: true

   resources:
       labels:
           '*': '*'
```

# Future work
- The discovery service will have to create these resources. 
- Support Azure and AWS dynamic authentication

Part of #16135, #13376  
Related to  #12048, #16276
2022-09-23 17:07:13 +00:00
Krzysztof Skrzętnicki 684956a06c Elasticsearch audit log support (#16191) 2022-09-23 11:46:15 +00:00
Brian Joerger 2654add770 RequireMFAType (#16034)
Replace role/authPref RequireSessionMFA (bool) with RequireMFAType
(string).

  - Add new RequireMFAType constant values with custom boolean marshalling.

  - Add RequireMFAType to role and auth preference and deprecate
RequireSessionMFA.

  - Add session-mfa override login when hardware_key_touch is enforced.

  - Add protobuf enum for RequireMFAType.

  - Add support for proto enums in protoc-gen-crd and update Kubernetes
Operator manifests.
2022-09-22 20:30:32 +00:00
rosstimothy b4317d4014 Update observability dependencies (#16497) 2022-09-22 12:59:30 +00:00
Michelle Bergquist f4ec8c33a2 add cluster alert links (#16426) 2022-09-21 15:49:54 +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
rosstimothy 26126ba457 Update gRPC and Protobuf related dependencies (#16496) 2022-09-19 21:12:15 +00:00
Tiago Silva 24f6957639 Support for dynamic kube_cluster resources (#16276)
This PR introduces Auth Server CRUD API for managing the lifecycle of dynamic `kube_cluster` resources.

Currently, `kube_cluster` resources cannot be manipulated without using the API, nor are they being listened to. It will be part of future developments.

# Future work
- The `kubernetes_service` will have to watch these `kube_cluster` resources.
- The discovery service will have to create these resources. 

Resource manipulation via `tctl` will be introduced later and is not part of the scope.

Part of #16135, #13376  
Related to  #12048
2022-09-16 14:15:29 +00:00
rosstimothy 54d32e1aa8 Use tracing handler per server not per route (#16342)
Tracing handlers consume a large amount of memory over time, which
makes using one per route suboptimal (See https://github.com/open-telemetry/opentelemetry-go-contrib/issues/2413).
Wrapping all `http.Server` handlers with a tracing handler provides
the same tracing abilities for a fraction of the memory usage. A new
span formatter is added which allows servers to still contain the
request span in the span name.
2022-09-13 16:31:53 +00:00
rosstimothy f54a8263f3 Update grpc-go (#15926)
Bumps google.golang.org/grpc to v1.49.0 which includes a fix for
https://github.com/grpc/grpc-go/issues/5358 which has been causing
tests to fail.
2022-09-07 14:24:07 +00:00
rosstimothy 6e5c9a7c85 Prevent ssh.Session SendRequest from wrapping payload twice (#16018)
* Prevent ssh.Session SendRequest from wrapping payload twice

Payloads were inadvertently being wrapped twice by sessions making
the ssh server unable to parse the request payload. This is largely
only an issue for window-change requests, as they are the only request
being sent directly via a session that contains a payload. All window-change
requests now use ssh.Session WindowChange instead or sending the request
manually.
2022-09-06 18:43:30 +00:00
Alan Parra fbc135e672 Add comment and import cycle proto linters (#16082)
Require top-level proto types to have comments and introduce import cycle linter.
2022-09-02 13:31:45 +00:00
Marco André Dinis c219962ccc ConnectionDiagnostics: SSH Tester (#15413)
This PR implements the SSH Tester for ConnectionDiagnostic feature.
This feature is also known as Test Connection, part of Teleport
Discover.

The goal here is to provide immediante feedback about a newly added
resource. Can the user connect to it?

We are targetting SSH Nodes as a first ResourceKind.

To test the access to an SSH Node we require the ResourceName and a
login username (ssh principal).

Then a series of checks will occur in two places:
- SSH client in the Web server
- SSH server in the SSH agent

The ssh client creates a new Connection Diagnostic with some initial
state.
Then it tries to build up the necessary SSH config
This already gives us a couple of things to check for:
- does the node exist and does the current user (inherited from
  websession) can access it?
- is the node accepting TCP connections (in the specific port)?
- is the node accepting SSH protocol on top of the TCP connection?

Then, the ConnectionDiagnosticID is inject into the certificate and the
SSH Server receives it and will also Append traces into it:
- is the requested principal allowed for the current user?
- does the requested principal exist in the target node?

This is not an exhaustive list of checks.
For a complete list of which checks are verified please see the
TestDiagnoseSSHConnection test.

After all those checks, it returns if the Connection was successful and
what all of the traces generated along the way.


Demo:
![image](https://user-images.githubusercontent.com/689271/187976940-55522fd9-f581-4c6d-9bfc-f6e501c1ed72.png)

![image](https://user-images.githubusercontent.com/689271/187976957-35075112-2b42-4726-8d50-19d02fab2464.png)

![image](https://user-images.githubusercontent.com/689271/187976967-81406e2c-0517-474b-b323-dad1f8be1571.png)
2022-09-02 08:17:21 +00:00
Yassine Bounekhla 777e778a04 Add username_claim to OIDC config to select claim from Identity Provider to use as username (#16029) 2022-09-01 17:00:44 -04:00
Forrest Marshall 7c9f26457a upgrade notifications 2022-08-31 12:09:30 -07:00
STeve (Xin) Huang 1dadb34b29 Support AWS Console for US GovCloud Partition (#13442) 2022-08-31 16:29:40 +00:00
Yassine Bounekhla 6d475e12b2 Add Access Request ID to response for UserContext (#15653) 2022-08-30 20:59:29 +00:00
Zac Bergquist 10ceaf5778 Add lock target to lock.create event (#15865)
This adds the target (which may be a user, role, node, login, etc)
to the lock.create audit event.

In order to do this, I had to break the dependency from events->types,
but that was a minimal change.

Fixes #15644
2022-08-30 18:22:23 +00:00
Alex McGrath 6bf2f18435 Allow for multiple installer scripts instead of a singleton (#15682)
* Allow for multiple installer scripts instead of using a singleton

* Resolve comments

- require name be provided to installer
- MetaNameClusterInstallerScript -> defaults.InstallerScriptName
- Require VerbList for GetInstallers

* Resolve comments

- Include the default installer in GetInstallers output
- Update how the scripts are prefixed

* resolve conflicts

* make the linters happy
2022-08-30 17:23:57 +00:00
Alan Parra d5e57f8cd1 Apply linters to legacy protos (#15879)
Applies linters to legacy protos and adds a few additional Makefile targets to
make it easier to manage protos locally.

Proto linters now run in CI.

#15187

* Apply linters to legacy protos
* Handle new folders in genproto.sh, reset gen/proto if exists
* Lint and format lib/teleterm as part of protos/all
2022-08-29 20:54:32 +00:00