Commit graph

6713 commits

Author SHA1 Message Date
Alen 93934eff16
Db access gui client improvements (#7950)
* Modifying db GUI guides to include pgAdmin Windows access and DBeaver MySQL access instructions
* Cert to Certificates to match screenshot
* Clearing up wording for readability and adding mysql.dbeaver_min_ver to config.json
2021-09-11 17:45:51 -07:00
Steven Martin 393c9f0a42
correct license file name in k8s cluster getting started(#8188) 2021-09-11 17:31:02 -07:00
Steven Martin 118c32d5ee
Modified auth server example to only have one auth server (#8199) 2021-09-11 17:20:20 -07:00
Alan Parra 6bc540050a
Add a global disable flag for Webauthn (#8191)
Since #8176[1] landed, tsh login favors Webauthn challenges over U2F, a behavior
recommended to other clients as well (such as the Web UI). This creates a
problem: until the Webauthn implementation if proven in the wild, if there are
issues with it, then clients could consistently fail login.

This change introduces a fallback for disabling Webauthn regardless of the
cluster's second_factor:on or second_factor:optional setting. By stopping
challenge generation we automatically push clients over to U2F or TOTP as a
fallback, allowing breaking issues to be fixed without impact. (Note that using
second_factor:u2f as a fallback isn't always possible, since it disables OTP as
well.)

The added setting is meant as a safety switch - once Webauthn is proved in the
wild it is to be removed.

This affects both teleport.yaml and cloud resource configs.

teleport.yaml:

```yaml
auth_service:
  authentication:
    type: local
    second_factor: on # or "optional"
    u2f: {}           # omitted
    webauthn:
      disabled: true
```

Resource configuration:

```yaml
kind: cluster_auth_preference
version: v2
spec:
  type: local
  second_factor: on
  webauthn:
    disabled: true
```

[1] https://github.com/gravitational/teleport/pull/8176

* Add global disable flag for Webauthn
* Generate protos
* Apply Webauthn global disable flag
2021-09-10 11:47:32 -07:00
Trent Clarke e91860631e
Port backend tests to testify / fix racy tests (#8170)
In order to get better visibility into the backend database tests using
the standard Go tooling, this changeset ports the backend tests away
from `Check`, and into subtests & `testify` for assertions.

This change means that individual sub-tests
 1. can be more easily identified in the json test logs, and
 2. can be more easily run individually from the command line

During this port I also discovered that some tests are using the fake
clocks incorrectly, which may be a cause of some of our flaky etcd
tests.
2021-09-10 04:14:04 -07:00
Steven Martin 079c678ac5
Expand error message on tctl enterprise usage (#8093) 2021-09-09 19:51:58 -07:00
Steven Martin aae9ffe393
Expanded AWS Console examples (#8127)
* Expanded AWS Console docs with more examples

* Corrected file names for cert file
2021-09-09 19:14:57 -07:00
Lisa Kim ecee1fdfb2
Account Recovery Token Getter and Create New Codes (#8177)
* Define new rpc CreateAccountRecoveryCodes that 
  creates new recovery codes for users who meet requirements, 
  invalidating their previous existing codes
* Define new rpc GetAccountRecoveryToken that
   validates and retrieves a recovery token
2021-09-09 15:31:22 -07:00
Roman Tkachenko 4ea2ecdcfc
Introduce app server and app resources (#8140) 2021-09-09 14:19:02 -07:00
Alan Parra 697e135c77
Pick a number for the Webauthn RFD (#8187) 2021-09-09 12:59:00 -07:00
Alan Parra 266c3dfd0f
Support Webauthn challenges in tsh login (#8176)
Implement the device polling loop for Webauthn devices and apply it to
tsh login.

A separate package, lib/auth/webauthncli, is introduced to hold client-focused
Webauthn logic. The separation highlights the distinction between server- and
client-side code and isolates client-side dependencies from the existing
lib/auth/webauthn.

Includes improved test coverage for TeleportClient.Login (local logins only) and
refactoring of existing code to support Webauthn challenges (PromptMFAChallenge
logic has less branching and U2F device loop extracted and refactored into
lib/auth/webauthncli).

In terms of device compatibility, this is identical to the existing U2F
solution- we are using the same underlying libraries and adapting the CTAP1
responses to Webauthn. This is easy to do and easy to reason about. I'm planning
for a native Webauthn solution, such as libfido2, but that is larger change that
doesn't seem to get us all the way to where we want for now (looking at you,
Touch ID).

* Add transformations and validations to lib/auth/webauthn
* Implement client-side Webauthn login
* Use RunOnU2FDevices in the lib/auth/u2f package

This one is optional: it cuts a bit of the codebase today, but one could
argue that it is safer to keep U2F untouched (up to the point where it
gets removed).

* Use CollectedClientData definition in lib/auth/mocku2f
* Fix data race on auth.Server clock usage
* Add direct test for TeleportClient.Login
* Reply to Webauthn challenges on `tsh login`
2021-09-09 12:39:08 -07:00
Alan Parra 78ac83553b
RFD: WebAuthn Support (#7808)
* Initial draft for the WebAuthn RFD

* Address review comments: wording and spelling

* Simplify configuration settings

* Make tsh rely on the /webapi/ping server version

* Add a section on user handles

* Add the Attestation section

* Add a references section

* Update tsh+WebAuthn with latest data

* Add detailed Touch ID sections

* Errata on App Attestation Service

It appears to only support iOS.

* Simplify config and expand on RPID and RPOrigin

* Only use attestation from U2F if all attestation keys are empty

* Add U2F phase out section

* Tweaks to names and messages to better match the codebase

* Mention cluster_auth_preference changes
2021-09-09 12:14:38 -07:00
Brian Joerger b3bc7f396a
LoadIdentityFileFromString (#8132) 2021-09-09 11:24:36 -07:00
Lisa Kim 5695f3b611
Implement CompleteAccountRecovery, Step 3 in Account Recovery (#8103)
* Define new rpc CompleteAccountRecovery, Step 3 in Account Recovery
   after ApproveAccountReocvery. After success, users authn is changed
   which allows a user to login with new credentials.
* Added a verifyMFARespAndAddDevice helper func to unify adding a
   device through stream or by a user token.
2021-09-08 14:26:25 -07:00
Lisa Kim da6e191fff
Implement ApproveAccountRecovery, Step 2 in Account Recovery (#8100)
* Define new RPC ApproveAccountRecovery Step 2 in Account Recovery after 
  StartAccountRecovery that after successful invocation produces
  a recovery approved token that allows a user to change authn, 
  view/delete their MFA devices and get new recovery codes.
* Placed rate limit to this endpoint
* Added a verifyUserToken helper method that verifies 
  that a user token is not expired and is of the allowed subkinds.
2021-09-08 12:56:49 -07:00
Nic Klaassen 0bcff02fe0
support empty string ca_pin (#8154) 2021-09-08 12:24:44 -07:00
Zac Bergquist 034e56bd50
webclient: use the provided context (#7801)
Ensure that the webclient package makes HTTP requests using the
provided context so that timeouts and cancelation are respected.

Updates #7795
2021-09-08 11:47:24 -07:00
Ben Arent 693c4a34e9
New videos for MongoDB Atlas and PostgreSQL (#8097) 2021-09-08 10:45:21 -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
Steven Martin adb7c6ea12
correct port number example (#8168) 2021-09-07 19:01:36 -07:00
Zac Bergquist 992c10f547
Stop using ; as a separator in URL query strings (#8143)
Go 1.17 (by default) disallows using ; as a separator. Our tests fail
on Go 1.17 with the following error. Since we only do this in test
code, it's easiest just to switch to & so we don't have a breakage
when we start compiling with 1.17.

See also: https://github.com/golang/go/issues/25192

Error:

    2021/09/03 10:21:57 http: URL query contains semicolon, which is no longer a supported separator; parts of the query may be stripped when parsed; see golang.org/issue/25192

    ----------------------------------------------------------------------
    FAIL: apiserver_test.go:473: WebSuite.TestSAMLSuccess

    apiserver_test.go:524:
        c.Assert(u.Scheme+"://"+u.Host+u.Path, Equals, fixtures.SAMLOktaSSO)
    ... obtained string = ":///web/msg/error/login"
    ... expected string = "https://dev-813354.oktapreview.com/app/gravitationaldev813354_teleportsaml_1/exkafftca6RqPVgyZ0h7/sso/saml"
2021-09-06 19:56:36 -07:00
Alan Parra b17f67dbeb
Unparallel racy test (#8142)
Fixes raciness on TestInit_bootstrap.
2021-09-03 16:32:07 -03:00
Andrej Tokarčík 2be3cc8695
Make TestLockWatcherStale more robust (#8134) 2021-09-03 08:20:38 -07:00
Tim Buckley f825d4558c
Do not attempt to sign Windows builds on push (#8137)
In #7897 we started signing Windows builds by default, which requires
a signing certificate. This certificate is only available during tag
builds, so push builds now fail.

This modifies the `push-build-windows-amd64` job to use the
`release-windows-unsigned` Makefile step on push builds to fix the
job failure.
2021-09-02 17:42:57 -06:00
Tim Buckley c821ec5f2f
Sign tsh.exe on tag builds (#7897)
* Sign tsh.exe on tag builds

This adds a Makefile step to sign tsh.exe when the
`$WINDOWS_SIGNING_CERTIFICATE` env var is set to a base64-encoded
pkcs12 code signing certificate. The certificate must not be password
protected.

This includes a sample cert (`cert-dummy.pfx`) for CI pipeline
testing. It should be removed in any eventual PR, along with the
other modifications to the drone pipeline. The cert is imported into
the environment in the `Makefile` for testing purposes; in practice
it will be imported from a secure secret store (drone secrets, etc).

* Improve Windows code signing

 - Split signing into a separate step; `release-windows-unsigned` now
   performs the build, `release-windows` signs the binary.
 - Require `release-windows` to successfully generate a signed
   binary.
 - Clearly mark unsigned binaries and archives as such.
 - Guard against stdout secret leakage in Makefiles.
 - Move temporary cert data from Makefile into dronegen to test
   full pipeline.

* Use an invalid cert string for testing purposes.

* Pass certs to the build process via a statically named file

Signed Windows builds now depend on a `.gitignore`'d
`windows-signing-cert.pfx` at the root of the source directory. This
should ease testing and help avoid accidental secret leakage.

* Use production secret

* Remove windows-signing-cert.pfx before continuing to the next step

Additionally, fix variable reference as the bracket syntax does not
seem to play nice with Drone.

* Update .gitignore

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

Co-authored-by: Andrew Lytvynov <andrew@goteleport.com>
2021-09-02 16:34:57 -06: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
Alan Parra d00d6b97f9
Wire Webauthn to login endpoints (#8094)
Allow login using Webauthn instead of U2F.

Installs with second_factor:on will automatically support Webauthn, generating
challenges for any U2F devices and allowing Webauthn to be used throughout the
entire login process.

Web REST API modified as follows:

Added /webapi/mfa/login/begin (1st login step)
Added /webapi/mfa/login/finish (2nd login step, SSH)
Added /webapi/mfa/login/finishsession (2nd login step, web session)
U2F endpoints deprecated, but support full breadth of MFA login options
(/webapi/u2f/signrequest, /webapi/u2f/certs and /webapi/u2f/sessions,
respectively)
Auth REST API modified as follows:

Added /:version/mfa/users/:user/login/begin (1st login step)
ssh/authenticate and web/authenticate now support Webauthn (2nd login step)
U2F endpoints deprecated, but support full breadth of MFA options as well
(/:version/u2f/users/:user/sign)

RFD: https://github.com/gravitational/teleport/pull/7808.

* Plug Webauthn into MFAAuth protos
* Generate protos
* Make CredentialAssertionResponse json-friendly
* Add Webauthn proto conversions
* Wire Webauthn to auth apiserver
* Wire Webauthn login to web apiserver
* Wire Webauthn to web login
* Add missing license headers
* Delete login_identity_test.go
* Use previously acquired devices on mfaAuthChallenge
* Take U2F App ID literally if it's not a proper URL
* Add direct tests for auth.Server
* Use trace.BadParameter consistently
* Include user name in "failed to authenticate" logs
* Add more login-related tests to auth.Server
2021-09-02 11:51:42 -07:00
Andrej Tokarčík 138f8f8650
Fix session URL displayed by teleport status (#8072) 2021-09-02 10:01:14 -07: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
Roman Tkachenko 3410bc8594
Dynamically register/unregister database resources (#7957) 2021-09-01 15:27:02 -07:00
Lisa Kim d0942b7abc
Implement StartAccountRecovery, Step 1 in Account Recovery (#8095)
* Define new RPC StartAccountRecovery
* Placed rate limit to this endpoint
* Define new user token type `UserTokenTypeRecoveryStart`
   that allows users to begin recovery process
* Added new field to UserTokenSpec, `UserTokenUsage` to
   store data about how a user token will be used
2021-09-01 11:41:34 -07:00
Zac Bergquist 9a8bbc5b4d
auth: remove DataDir from RegisterParams (#8110)
We stopped using this field years ago when support for CA pinning
was added in e69e67e372.
2021-09-01 08:29:44 -07:00
Brian Joerger b4e7cd3a5e
Mask token in logs (#7955) 2021-08-31 11:11:23 -07:00
Paul Schisa 85addfbd36
Update Architecture Docs link in Readme (#8107)
Pointed out by customer, link in Readme is no longer current link so updating to https://goteleport.com/docs/architecture/overview/
2021-08-31 09:29:02 -07:00
Alexander Klizhentas 3610d05956
Cleanup docs on users and roles (#8098) (#8099)
* Cleanup docs on users and roles

- Updates roles to use v4
- Moves users to a separate guide
- Creates up to date reference for users and roles resources

* Update docs/pages/setup/reference/resources.mdx

Co-authored-by: Roman Tkachenko <roman@gravitational.com>

Co-authored-by: Roman Tkachenko <roman@gravitational.com>

Co-authored-by: Roman Tkachenko <roman@gravitational.com>
2021-08-30 19:53:44 -07:00
Trent Clarke 50ca44c18a
Access & Review request docs (#7791)
Adds documentation on how to use claims_to_roles in Access and Review Requests.

See-Also: #7135
See-Also: #7538
2021-08-31 11:51:22 +10:00
Brian Joerger a95b3ae066
Add kube-cluster env for tsh (#7867) 2021-08-30 14:28:24 -07:00
Alan Parra 91449219e7
Adapt lib/auth/webauthn to Identity and type changes (#8082)
Adjust lib/auth/webauthn to correctly match Identity methods (interfaces
deviated a little during reviews) and make use of WebauthnLocalAuth to create
and record Webauthn user IDs.

* Adjust lib/auth/webauthn to Identity and configs
* Apply default Webauthn challenge timeout
* Create and make use of Webauthn ID
2021-08-30 12:10:10 -07:00
Brian Joerger c10d55b69c
API workflows example (#6827) 2021-08-30 11:46:29 -07:00
Andrew Lytvynov 5b090f8633
Connect proxy <-> windows_desktop_service <-> RDP server (#7990)
* Connect proxy <-> windows_desktop_service <-> RDP server

Link together the proxy (websocket), service (mTPS) and RDP client. Pass
target desktop UUID via SNI on the TLS connection from the proxy.

* Use client CAs to validate incoming desktop_service connections

* Send binary frames on desktop websocket
2021-08-30 11:22:39 -07:00
Alan Parra 6561ea2748
Move newly-added Webauthn tests out of gocheck (#8074)
Move newly-added tests from gocheck to testing/require.

* Move newly-added Webauthn tests out of gocheck
* Use t.TempDir and t.Run
* Make use of newIdentityService in recently merged code
2021-08-30 10:59:01 -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
Lisa Kim ab57eab5c0
[RC 2] Extend GetMFADevices to accept tokenID (#8036)
* Add withSecrets bool parameter to identity service GetMFADevices 
  that removes secret (totp key) if true
* Add web handlers for getting devices for authenticated users
* Fix data race with RecoveryAttemptsCRUD test
2021-08-26 19:19:35 -07:00
Lisa Kim 6c1a5b7b87
Implement Account Recovery Codes (#8034)
* Add dice-ware library to create the recovery codes
* Add new recovery code "generated" and "used" events
* Implement create, upsert, and get recovery codes
* Create ChangeUserAuthentication grpc endpoint that is essentially a rework
  of ChangePasswordWithToken that returns both a web session and
  recovery codes (if user meets requirement)
* Add custom rate limit for grpc endpoint for ChangeUserAuthentication

* This commit also includes unused methods related to verifying recovery
  code and recovery attempts that isn't utilized until later PRs
2021-08-26 17:29:08 -07:00
Roman Tkachenko 66d79a4bb4
Update e (#8073) 2021-08-26 11:44:54 -07:00
Alan Parra f44ff5fc36
Add the WebAuthn user ID to LocalAuthSecrets (#8013)
WebAuthn recommends using a random user handle (aka user ID) in its protocol.
We are adding the user ID to LocalAuthSecrets (under Webauthn) and allowing it
to be updated and read, both through the user and independently.

The lib/auth/webauthn package is going to be responsible for assigning IDs to
users (and using them).

See https://www.w3.org/TR/webauthn-2/#sctn-user-handle-privacy.

WebAuthn Support RFD[1]

[1] https://github.com/gravitational/teleport/pull/7808

* Add Webauthn to LocalAuthSecrets
* Generate protos
* Add WebauthnLocalAuth persistence to Identity
2021-08-26 15:24:08 -03:00
Alan Parra c401bb7cf7
Implement WebAuthn login (#8009)
Add the necessary logic to perform WebAuthn logins/authentication, including
both necessary steps (named "Begin" and "Finish" after the Duo Labs
API/reference implementation).

Note that the login logic is not yet wired to Teleport, that is to come in a
future PR.

Part of the WebAuthn Support[1] work.

[1] https://github.com/gravitational/teleport/pull/7808

* Vendor duo-labs/webauthn and fxamacker/cbor/v2
* Implement the first step of login
* Implement the second step of login
* Add WebAuthn support for mock U2F devices
* Add tests for the complete login flow
* Be explicit about the default attestation value
* Refactor "appid" into a constant
* Add missing license headers
2021-08-26 10:50:59 -07:00
Alan Parra 43c3541ddc
Add support for WebAuthn configuration (#7949)
WebAuthn configuration works as follows:

If there is an explicit WebAuthn config, use it
Otherwise, try to fallback to the U2F config, copying/deriving what we can from it
Falling back to U2F allows users to easily migrate to Webauthn (in fact, if second_factor is "on" then Webauthn takes over from U2F).

See the "UX and configuration"[1] section of the RFD for reference.

[1] 0fc785dbff/rfd/9999-webauthn-support.md (ux-and-configuration)

* Add protos for WebAuthn configuration
* Add validation for types.Webauthn
* Add Webauthn to FileConfig
* goimports api/types/authentication_authpreference_test.go
* Add missing license headers
2021-08-26 10:24:05 -07:00
Alexander Klizhentas 5220853972
Move and expand troubleshooting section (#8052) 2021-08-25 15:09:11 -07:00
Rui Li 75a4105082
RFD 32: Datalog based role tester (#6818) 2021-08-25 17:04:56 -04:00