Commit Graph
341 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
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 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
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
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
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
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
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
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
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
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
Joel 386589bd50 Allow opting out of forced OIDC email verification (#15847) 2022-08-29 15:20:22 +00:00
Gavin Frazar 7f2c1b18a9 Fix azure protobuf (#15864)
Fix copy paste mistake
2022-08-26 22:29:59 +00:00
Alan Parra 0b76b44973 Use to Buf to lint, format and generate api/ protos (#15856)
Change the proto layout of `api/` to a more standard setup, allowing the use of
modern tools (like Buf) to format/lint (and maybe, one day, generate sources).

The new layout looks like this:

``` api/ proto/       <- root of protos and proto imports teleport/  <- base
package for Teleport protos (akin to "google/" or "gogoproto/") legacy/  <- root
of "legacy" protos (most linters disabled) client/ proto/ types/ events/
webauthn/ wrappers/ ```

Non-legacy `api/` protos are expected to follow this layout:

``` api/ proto/ teleport/ mynewpackage/  <- package name v1/          <- protos
explicitly versioned gen/      proto/  <- root for generated sources
(multi-language possible, separate from hand-written code) go/ mynewpackage/ v1
<- generate Go sources go here. ```

Some outstanding issues, like lack of `go_package` declarations and non-standard
import paths (`import "github.com/gravitational/teleport/.../some.proto"`) are
fixed.

Legacy protos still have irregular package declarations. It's possible to fix
that, but it's a bit harder to reason about, as generated sources change in
possibly-meaningful ways.

Future iterations could change legacy packages to match the directory structure
and apply a similar change to protos within lib/ packages, but this seems
sufficient for a first step.

* Add Buf to buildbox
* Unify API protos under Buf
* Fix proto generation
* Reformat protos
* Update generated protos
* Generate protos using Buf
* Appease linter
* Review: make sure gogo protobuf versions are in sync
* Clean leftovers from previous attempts
* Fix operator/Makefile
* Rename internal make gRPC targets to `*/host`
* Sort `make fix-license` targets (nit)
2022-08-26 18:11:38 +00:00
Gabriel Corado a3a65e863b TLS routing ping for database protocols (#14887) 2022-08-26 16:42:23 +00:00
Gavin Frazar 66c010dce1 Add Azure resource ID to protos (#15673)
* Add Azure auto-discovery configuration fields

* Init databases if azure matchers are in config

* Use AzureMatchers in db service

* Use all azure subscriptions/resource groups if omitted in matcher

* Add azure config tests

* Update protobuf and fix database serialization

* Update azure database spec/status

* Change proto to use resource id string

* Fix database serialization test
2022-08-25 22:51:25 +00:00
Andrew LeFevre 7edf9c333f Merge pull request #15144 from gravitational/capnspacehook/file-copy-role-option
Added file copying role option and node config option
2022-08-24 20:13:41 +00:00
Joel 6caba42ec1 Add support for IdP-Initiated SAML2 login (#13924) 2022-08-22 18:27:44 +00:00
Ryan Clark 253173376f Record when a session recording is accessed (#14302)
This adds a new SessionRecordingAccess event that is emitted every time a session's events are queried, or if a session's events are streamed.

This event is emitted by both v1 and v2 of the API, so both the web UI and tsh play will result in an event in the audit log.

Implements #13880.

The frontend change for supporting this event type is here - gravitational/webapps#970.
2022-08-22 17:35:25 +00:00
Forrest Marshall c33c53a2d9 cluster alerts 2022-08-19 13:14:04 -07: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
Tobiasz Heller 6812c7449e Delete touch_id credentials during tsh mfa rm (#15459)
Delete touch_id credentials of tsh mfa rm
2022-08-19 10:14:12 +02:00
d8c9b08001 Support China and GovCloud for database access (#15359)
Co-authored-by: waylen <waylen.guo@gmail.com>
Co-authored-by: Jianghui Guo <89057156+waylenguo@users.noreply.github.com>
Co-authored-by: STeve (Xin) Huang <huangin52@gmail.com>
2022-08-16 18:42:18 +00:00
Marco André Dinis 37b80c03b1 Connection Diagnostic: update, traces and ConnectionTester (#15158)
This PR adds the concept of ConnectionTester

ConnectionTester will generate ConnectionDiagnostics by connecting to
the actual resource using a user and some Resource Specific parameters
(principal for SSH access, Database User and Name for Database access,
and so on) and storing the result of multiple checkpoints.

Each resource will have a ConnectionTester (we'll start by SSH access
and then Databases).

It also improves Connection Diagnostics by adding
- update operation (similar to the create one)
- a list of traces, which contain the result of checkpoints in multiple
  steps of the connection flow

As an example, for SSH, we'll have at least the following checks:
- Node is reachable
- User has the right permissions
- Node has the expected Principal

The trigger to test a connection will be an endpoint, because our
primary goal is to let the user test the access right after adding the
resource.

This PR does not implement the actual SSHConnectionTester but creates
most of the boilerplate to do so.

The next PR will focus in adding the actual traces.
2022-08-16 11:03:06 +01:00
Alex McGrath f56dd09ebd Add an installer script resource type and public HTTP endpoint (#13146)
* Add an installer script resource type and HTTP endpoint

* Add default installer scripts

* Resolve comments

- run `shfmt` over the installer script
- add MustNewInstaller
- move default installer logic to GetInstaller
- only include PublicProxyAddr in server.Config

* Resolve comments

- move from auth_with_roles -> auth/grpcserver
- document `MustNewInstallerV1`
2022-08-15 10:27:33 +00:00
Zac Bergquist d1c6b0618e Fix lint warnings (#15312)
Mostly duplicated imports and redundant types in struct literals.
2022-08-08 20:20:29 +00:00
Marco André Dinis 117d7d2d40 Add Suggested Labels to Provision Tokens (#15114)
For Teleport Discover, the user will be able to test connecting to a
resource right after adding it.

The flow should look like this:
- User selects the resource type - in this case Server/Nodes
- WebUI generates a new Token
- WebUI shows the `sudo bash .../<token>/install.sh` to the user
- When the user runs this command, and assuming everything works out,
  the WebUI should be able to receive the Server/Node that was
  generated from that specific Token.

To achieve this, here's a more detailed flow, which this PR implements
- User selects the resource type - in this case Server/Nodes
- WebUI generates a new Token
  This generates a Provision Token which contains a RefResourceID
  WebUI receives back that ID
- WebUI shows the `sudo bash .../<token>/install.sh` to the user
  This generates a script which includes setting the labels as part of
  the `teleport configure` command:
  `$ teleport configure ... --labels teleport.internal/resource-id=<refResourceID> ...`
- User runs the provided command on the target host
- WebUI should be able to query the Servers/Nodes which contain that
  specific `<resource-id>` and allow the user to connect to it.

Demo:
![image](https://user-images.githubusercontent.com/689271/182440692-97c75ae0-1e14-4f76-b9ff-d41060c73ed0.png)
2022-08-08 17:06:41 +00:00