Commit graph

776 commits

Author SHA1 Message Date
Roman Tkachenko d87ee8f640
Fix mongo access with mfa and add tests (#8799) 2021-11-02 12:06:58 -07:00
Marek Smoliński 59633e4747
Align SNI routing logic (#8689) 2021-10-22 17:04:36 +02:00
Marek Smoliński 32d48745d7
Align the user message printed during the 'tsh proxy db' command (#8681) 2021-10-22 13:10:43 +02:00
Marek Smoliński 17a5cadabb
Add Proxy listener mode and proxy v2 configuration (#8511) 2021-10-21 14:45:47 +02:00
Marek Smoliński 7606d330e9
AWS CLI access (#8151) 2021-10-19 10:43:53 +02:00
Zac Bergquist 44045e20ae tctl: allow comma-separated --windows-logins
In order to be consistent with other CLI flags, we support both
--windows-logins=foo,bar as a shortcut for specifying multiple
values.
2021-10-14 11:09:25 -04:00
Zac Bergquist 85541510fe
Support traits for Windows Logins (#8585)
- Add --windows-logins flag to tctl users add command
- Support {{internal.windows_logins}} and external traits from IDP

This allows one to define a role allowing desktop access without
hard coding all allowed/denied Windows logins.

Updates #7761
Fixes #8578
2021-10-13 08:39:31 -07:00
Roman Tkachenko 36998cf566
Add CockroachDB support (#8505) 2021-10-12 14:30:59 -07: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
Nic Klaassen 2d10515f19
Implement Simplified Node Joining (#8250) 2021-10-08 10:41:28 -07:00
Marek Smoliński 56c536e61f
ALPN DB Proxy fix insecure flag (#8440) 2021-10-08 14:38:51 +02:00
Andrew Lytvynov f2862537a2
Publish Teleport CA to NTAuth store over LDAP (#8438)
* Publish Teleport CA to NTAuth store over LDAP

Also, refactor the LDAP client.
Also also, implement more missing scard ioctls.

* Address review comments
2021-10-07 10:28:52 -07:00
Brian Joerger c6f0a8a2fe
Kube Proxy Forwarder handles kube services with same name (#8362)
Update Proxy kube forwarder to attempt to dial through all available
endpoints in a random order.
2021-10-06 16:01:08 -07:00
Marek Smoliński 700f9f71e5
Add support for MFA for DB access (#8270) 2021-10-06 13:59:35 -07:00
Alan Parra 16a5c336ef
Adjust tsh language in regards to Webauthn (#8451)
This is a collection of a few small changes related to user presentation of
WebAuthn/MFA in tsh. The intent is to make tsh language match ongoing Web UI
changes.

* Make use of preferred MFA in `tsh mfa add`
* Tweak prompt error message

    Old:
    ERROR: "U2F\n" is not a valid option, please specify one of [TOTP, WEBAUTHN]

    New:
    ERROR: "U2F" is not a valid option, please specify one of [TOTP, WEBAUTHN]

* Directly mention WebAuthn when prompting for challenges
* Fix typo on godoc
* Print devices sorted by name on `tsh mfa ls`
* Address origin validation TODOs

    For registration and a few other use cases the original error is relayed
    back to the client, so there is already a good indicator that it failed
    due to origin woes.

    For login we purposefully obsfucate errors. To address that I've added a
    few debug-level server-side log statements; it seems best to not make
    further changes in this case.

* Amend preferred device type logic
* Adjust PromptMFAChallenge message
2021-10-06 10:54:50 -07:00
Roman Tkachenko 288c5519ce
Accept multiple SANs in tctl auth sign for databases (#8449) 2021-10-05 16:00:28 -07:00
Brian Joerger 2c8342c9de
Remove RoleConditions type alias from lib/services. (#8441) 2021-10-05 14:04:18 -07:00
Andrew Lytvynov 813dff20c1
PIV authentication for RDP (#8408)
* PIV authentication for RDP

This uncomfortably large change fully implements smartcard PIV
authentication for RDP clients using the Teleport CA:
- PIV applet implementation in emulated RDP smartcard
- generating Windows-compatible certificates using Teleport CA with a
  dedicated RPC
- generating dummy CRLs for Teleport CA and publishing it via LDAP

The CRLs are required by Windows for any smartcard login certificate, we
can't avoid that. But we can avoid making it public: the CRL can live in
ActiveDirectory instead of a public endpoint of a Teleport service.
Here, we use LDAP to publish the CRL on startup, valid for a year.

There are a few unhandled cases in the current implementation:
- LDAP server certificate is not validated when upgrading to TLS
- multiple active CAs (with HSMs) are not supported, only one CRL is
  published
- CA rotation is not supported, CRL is not re-published on rotation

All of the above issues will be handled in future PRs as this one is
already too large.

* Address review feedback

* Fix linter errors
2021-10-01 15:01:17 -07:00
Roman Tkachenko 9959ea381f
Auto-configure IAM for RDS databases (#8339) 2021-10-01 11:06:17 -07:00
rosstimothy fb0ab2b9b7
Watcher System Metrics (#8338)
* add event watcher prometheus metrics and a new tctl top tab to visualize them
2021-09-28 12:16:03 -04:00
Marek Smoliński e8f9220fe7
Fix ALPN SNI Proxy TLS termination for DB connections (#8303) 2021-09-24 09:42:13 +02:00
Alan Parra 5574cc52c4
Add the DeviceType proto to Auth Service (#8336)
Replaces the local device type in AddMFADeviceRequestInit for a global enum.
Useful for future RPCs.

* Add the DeviceType proto to Auth Service
* Generate protos
* Use new DeviceType in implementations
2021-09-22 15:36:33 -03:00
Alan Parra c8e9ce2deb
Add Webauthn devices via tsh mfa add (#8310)
Introduce client-side registration for Webauthn and ensures `tsh mfa` commands
are compatible.

* Implement client-side Webauthn registration
* Add Webauthn devices via `tsh mfa add`
* Add Webauthn devices to ValidateMFADevice
* Add a brief explanation about CheckAuthenticate's usage
* Use constants for CLI device types
2021-09-20 18:37:20 -03:00
Roman Tkachenko 6502a12f1f
Add API and CLI for managing application resources (#8185) 2021-09-20 08:44:13 -07:00
Roman Tkachenko e1c3f80aa0
Fixes for cert checker and Postgres config builder (#8251) 2021-09-17 13:28:40 -07:00
Tim Buckley 01acea141a
Add support for tsh ssh on Windows (#7790)
* Add support for `tsh ssh` on Windows

This adds Windows session support to tsh, taking advantage of ANSI
terminal support and VT emulation added in recent versions Windows
10. On supported Windows versions (Windows 10 1607+), `tsh ssh`
should work as expected in `cmd.exe`, PowerShell, and the new
Windows Terminal app.

* Address a few review comments

* Remove significant chunks of unnecessary tncon code.

Removes the global buffer, `GetVTSeqFromKeyStroke`, and several
ancillary headers and functions that aren't needed for our (current)
use-case. Also removes mouse and focus events.

* Refactor OS-specific terminal handling

This significantly simplifies OS-specific terminal behavior:
 * Move OS specific terminal code into a new `terminal` package
 * Remove `session_windows.go` in favor of an OS-independent
   `session.go`, defer to terminal package for OS specific
   functionality.
 * Remove ConPTY since it's not needed.
 * Always wait for the terminal and ssh session to fully close before
   quitting.
 * Refactor tncon; ensure the raw reader can be closed and reopened,
   remove lots of unnecessary C code.

* Revert dependency changes

* Use WindowsOS constant.

* Fix `tsh play` on Windows

This fixes `tsh play` on Windows by using the new `terminal` module to
initialize the terminal for raw input in a cross-platform way.

Additionally, this simplifies `terminal.New()` since in practice we never
want interactive mode at init time, and  fixes a broken unit test.

* Use correct log library

* Fix `tsh play` player controls on Windows

This fixes the console player controls on Windows as well as the timestamp
writer.

* Clean up lints

* Add missing license header

* Fix broken unit test

* Fix cross-compile builds on Linux/Docker

We need windows.h, which is not capitalized in the mingw packages
(and is case insensitive on Windows).

* Address code review feedback

 - Rename `Terminal.InitInteractive` to `Terminal.InitRaw`
 - Ensure goroutines terminate on close
 - Fix outdated godoc comments
 - Ensure Terminal event subscribers are cleared (and their channels
   are closed)
 - Ensure terminal output mode is reset on error in initTerminal
 - Bubble up errors in Terminal.Close()
 - Add author notice to tncon.c re: our changes
 - Add go-ansiterm as a direct dependency
 - Run `make update-vendor`

* Add constants and a small player.go TODO.

* Clear linter warning
2021-09-16 15:53:08 -06: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
Marek Smoliński c142b656c8
ALPN SNI Proxy (#7524) 2021-09-13 11:54:49 +02:00
Steven Martin 079c678ac5
Expand error message on tctl enterprise usage (#8093) 2021-09-09 19:51:58 -07:00
Roman Tkachenko 4ea2ecdcfc
Introduce app server and app resources (#8140) 2021-09-09 14:19:02 -07:00
Zac Bergquist 8a15c9a3a6
Require that public TLS and SSH keys are provided to register via token (#8135)
* Require that public TLS and SSH keys are provided to register via token

The original behavior attempted to make providing public keys optional,
and would generate keys if they were not provided. This had several
problems:

- The auth server is generating private keys for nodes and is
  potentially able to share them over the network.
- The return value for keys.Key would sometimes be set and sometimes
  be empty (the key is only set if the auth server generated it and
  knows what the key is)
- We only ever relied on this behavior as a shortcut in test code.
  In the production code this behavior was never used (and actually
  never worked due to a bug that would overwrite and discard the
  generated private key)

This commit requires that public keys are always provided, ensuring
that the private key is generated locally and never known by the
auth server.

It also results in a cleaner error message when either or both of the
public keys are missing from the request.

* Address review comments

* Fix tests that relied on certs being generated
2021-09-08 10:17:37 -07:00
Tim Buckley 6f56aa5c4f
Generate Windows-compatible OpenSSH config in tsh config (#7848)
* Generate Windows-compatible OpenSSH config in `tsh config`

This tweaks `tsh config` to generate OpenSSH config blocks compatible
with Windows. It works around several issues:
 * Hosts must be translated from a full hostname (e.g.
   `node.foo.example.com`) to a Teleport node name (`node`). On Unix
   clients we can use a bash subshell snippet to extract the cluster
   domain but this isn't possible on Windows. Instead, this adds a
   hidden tsh subcommand (`tsh config-proxy`) to act as a
   `ProxyCommand` that manipulates the strings as necessary.
 * Windows does not have an ssh-agent enabled by default. This
   configures `IdentityFile` and `CertificateFile` so no ssh-agent
   is needed. This should also improve the experience for users
   without a compatible ssh-agent (e.g. GNOME).
 * Windows requires a full executable path in `ProxyCommand`
   directives.

* Remove unnecessary conversion

* Use /usr/bin/ssh explicitly in `tsh config` template for Unix

* Remove special case for leaf clusters; always require a SiteName

* Apply suggestions from code review

Co-authored-by: Andrew Lytvynov <andrew@goteleport.com>

* Pass through remote login name

This should improve compatibility with OIDC and other users with
federated Teleport usernames. The teleport proxy should always accept
a remote username for which the user's certificate is valid.

* Use `exec.LookPath` to resolve the ssh path

This prefers whichever `ssh` exists on the PATH for all OSes. After some
testing, Git for Windows SSH works just as well as Microsoft's, so we don't
need to overspecify things.

Also, quotes the tsh.exe path in generated config. Git for Windows' ssh
didn't autoescape the Windows paths.

Co-authored-by: Andrew Lytvynov <andrew@goteleport.com>
2021-09-02 15:47:43 -06:00
Andrej Tokarčík 138f8f8650
Fix session URL displayed by teleport status (#8072) 2021-09-02 10:01:14 -07:00
Roman Tkachenko 3410bc8594
Dynamically register/unregister database resources (#7957) 2021-09-01 15:27:02 -07:00
Brian Joerger a95b3ae066
Add kube-cluster env for tsh (#7867) 2021-08-30 14:28:24 -07:00
Alan Parra dba49bfad6
Lint and fix missing license headers (#8075)
Introduce new make targets to check and add license headers to files
("make lint-license" and "make fix-license"). License checking is now a part of
"make lint" as well.

Initial attempts used goheader, but it caused "make lint-go" to become about 9x
slower (if not more), plus it only targets go files. Google's addlicense is fast
enough and targets however many file types we want.

Existing files that were missing licenses got the header added, using the
current year as the license date.

* Introduce lint-license and fix-license make targets
* Ignore generated files
* Add license to go files
* Replace irregular licenses with standard copyright/license
* Add license to proto files
* Install addlicense in build.assets Dockerfile
2021-08-30 09:44:09 -07:00
Rui Li 89440dcfcf
Datalog based access tester (#7543)
Created an access tester for troubleshooting access related issues with Teleport RBAC system. This access tester allows admins to answer questions like:

Can user alice SSH into a node node-1 as root?
If not, which role(-s) prevents access?
Which roles allow access to production as login admin?
2021-08-25 14:39:59 -04:00
Brian Joerger 2d7bfe311c
Add support for a profile specific kubeconfig file. (#7840) 2021-08-24 10:28:26 -07:00
Nic Klaassen c48ee9f062
Add support for HSM CA rotation (#7862) 2021-08-18 21:21:43 -07:00
Nic Klaassen c9fda499de
Add support for multiple CA pins (#7905) 2021-08-18 20:13:20 -07:00
Brian Joerger 928aaf2f91
Add support for nowait on requests. (#7895) 2021-08-18 17:01:05 -07:00
Andrew Lytvynov ab062428b1 Windows desktop service boilerplate
Boilerplate for a new service and API objects:
- windows_desktop_service config section
- service registration and heartbeats
- static host registration and heartbeats
- caching, permissions, etc
- "tctl get" support

For new connections the service aborts after authentication, since the
RDP client implementation is not ready yet (pending in
https://github.com/gravitational/teleport/pull/7824).

Tested that the service starts, registers (both over a tunnel and
directly) and creates the API objects.
2021-08-18 18:44:41 +00:00
Andrej Tokarčík 2e419119f8
Introduce tctl lock command (#7809) 2021-08-13 06:24:46 -07:00
Brian Joerger 25c9c982db
API client tunnel address discovery fix (#7533) 2021-08-11 14:34:50 -07:00
Lisa Kim 09ba1ebbcf
Rename ResetPasswordToken to UserToken for general use (#7681) 2021-08-10 13:41:12 -07:00
Andrej Tokarčík 7d9067da24
Replicate locks to remote clusters (#7737) 2021-08-09 11:59:10 -07:00
Roman Tkachenko 25aeeae3ac
Adding database resource API and tctl commands (#7792) 2021-08-09 07:14:39 -07:00
Roman Tkachenko 629042ed30
Decouple database server from database (#7771) 2021-08-05 01:50:21 -07:00
Marek Smoliński b4006bcfc9
Fix tctl db resource UT (#7760) 2021-08-02 23:34:34 -07:00
Brian Joerger 9b8b9d6d0c
rollback - Upgrade api version. (#7751) 2021-07-30 15:34:19 -07:00