Commit Graph
313 Commits
Author SHA1 Message Date
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
Alan Parra 93a7a8926b Return preferred MFA method on ping endpoints (#8439)
Give Teleport clients a consistent hint of which MFA method they should
favor when facing multiple options.

To be used by tsh and Web UI to decide whether they should refer to
"U2F" or "WebAuthn" during the transitional period.

* Return preferred MFA method on ping endpoints
2021-10-01 13:35:22 -07:00
Lisa Kim d0c09338ac Rename VerifyAccountRecovery and token ID proto fields (#8395)
- Rename ApproveAccountRecovery to VerifyAccountRecovery 
   to match the language we use for the UI
- Use generic TokenID field naming for requests where more 
   than one type of token is accepted or a single token use 
   may be unlikely (MFA related rpcs)
2021-09-28 10:29:11 -07:00
Nic Klaassen 99cc8eb5ef Require enterprise license for HSM support (#8370) 2021-09-27 10:40:47 -07:00
Lisa Kim 8c4bf751b2 Implement AddMFADeviceSync and GetAccountRecoveryCodes (#8287)
Following allows for UI dashboard mfa and recovery code management:

- Adds new rpc AddMFADeviceSync (nonstream) so users can add device
- Adds new rpc GetAccountRecoveryCodes to retrieve nonsensitive data 
  about a users recovery codes e.g. created date to display in the users 
  dashboard
- Added privilege access to DeleteMFADeviceSync and 
  CreateAccountRecoveryCodes
2021-09-24 12:26:45 -07:00
Lisa Kim c2016bbae7 Unify creating u2f, totp, and webauthn MFA register challenges (#8342)
One endpoint is now responsible for creating/returning 
MFA register challenges:
- Deprecates RotateUserTokenSecrets 
- Deprecates GetSignupU2FRegisterRequest
2021-09-24 08:59:48 -07:00
Andrej Tokarčík bddc54d8c4 Remove ClusterConfig resource (#8150) 2021-09-23 13:56:35 -07:00
Alan Parra 6187d00c74 Add Webauthn support to ChangePassword and Ping (#8337)
Add Webauthn support to a few outstanding endpoints and RPCs.

* Refactor and add Webauthn support to ChangePassword
* Add explicit JSON tag to AuthenticateUserRequest.Webauthn
* Add Webauthn support to /webapi/users/password/token
* Add Webauthn to /webapi/ping
* Add default Webauthn device name to ChangeUserAuthentication
* Tidy Ping tests
2021-09-23 13:34:30 -07:00
Lisa Kim 9196d8a521 Implement User Privilege Token (#8076)
- Privilege tokens are obtained after a logged in user successfully
  re-authenticates with their second factor. This token allows 
  access to protected actions and will last 5 minutes. 
- There is one exception where a user can obtain `PrivilegeException` 
  token without re-authenticating if a user doesn't have any second factors.
  Currently used to allow users to add their first MFA devices for
  auth type optional.
- Added web handlers
2021-09-22 16:09:07 -07: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
Trent Clarke a3d8f72d43 Replace log with logrus in Webclient (#8328)
Using the standard logger results in log messages being routed to the
console even in non-debug mode, so reverting to `logrus` which will
honour the debug setting
2021-09-22 21:08:49 +10:00
Roman Tkachenko 6502a12f1f Add API and CLI for managing application resources (#8185) 2021-09-20 08:44:13 -07:00
Trent Clarke e1b2a267a9 Allow login over plain http in restricted situations (#7835)
This patch will allow the web api to (optionally) fall back from HTTPS
to HTTP under very particular circumstances:

  1. The appropriate `insecure` flag was set, and
  2. The target host is the loopback

If both conditions are met, this patch will allow the WebAPI client to
fall back to plain HTTP when attempting to login to the auth server.
2021-09-17 19:47:03 +10:00
Lisa Kim e624dd1730 Allow getting MFA authenticate challenge with recovery token (#8231)
Created a new rpc `CreateAuthenticateChallenge` that 
replaces/deprecates `GetMFAAuthenticateChallenge`

Allows 3 ways to invoke this request:
1. with username + password 
2. with token ID (username retrieved from token)
3. with empty request (username retrieved from context)
2021-09-14 14:48:41 -07:00
Lisa Kim 7a7502bd2f Allow deleting/listing MFA devices with recovery tokens (#8197)
- Implemented `DeleteMFADeviceSynce`, which takes in a token 
  that allows users to delete devices during the recovery process
- Refactored `GetMFADevices` to take in recovery token
- Pulled out deleting MFA device (from stream version) into helper func to be re-used
- Added delete MFA web handler
2021-09-14 13:28:22 -07:00
Alan Parra 79b10f3bb5 Introduce WebauthnDevice proto and registration messages (#8201)
WebauthnDevice is a prerequisite for registration, as are the message changes in
AuthService.

This lays the groundwork for registration and ensures only valid devices may
enter storage.

* Add WebauthnDevice to MFADevice
* Add Webauthn to AuthService registration messages
* Validate WebauthnDevice on upsert
2021-09-14 10:16:37 -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
Marek Smoliński c142b656c8 ALPN SNI Proxy (#7524) 2021-09-13 11:54:49 +02:00
Lucas MelchiorandAlexander Klizhentas fb180dafe1 fix broken links in api client readme (#8125)
Co-authored-by: Alexander Klizhentas <klizhentas@gmail.com>
2021-09-11 19:43:37 -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
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
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
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
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
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
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
Andrew Lytvynov f2cda7b3ee Split UpsertWindowsDesktop into Create/Update 2021-08-18 18:44:41 +00: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
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
Brian Joerger 6b8a57f114 Fix client.New race condition (#7774) 2021-08-04 11:25:29 -07: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 7d878fff24 Enforce locks in auth.Authorize (#7625) 2021-07-28 18:54:21 +02:00
Roman Tkachenko 1576833094 AWS console access (#7590) 2021-07-26 08:17:16 -07:00
Brian Joerger 740547095c API Client UX fixes (#7521) 2021-07-20 18:50:19 -07:00
Trent Clarke 5ffa4b4829 Adds Message of the Day (#7396)
Adds a configurable MotD to the auth service. If a message is set, any
attempt to login into a cluster via `tsh` will display that message and
not begin to log the user in until that message is acknowledged.
2021-07-20 10:48:00 +10:00
Eugene Yakubovich 67c0eb3b4c Add restricted session
Adds the ability to block network traffic on SSH sessions.
The deny/allow lists of IPs are specified in teleport.yaml file.
Supports both IPv4 and IPv6 communication.

This feature currently relies on enhanced recording for
cgroup management so that needs to be enabled as well.

-- Design rationale:
This patch uses Linux Security Module (LSM) hooks, specifically
security_socket_connect and security_socket_sendmsg, to control
egress traffic. The LSM provides two advantages over socket filtering
program types.
- It's executed early enough that the task information is available.
  This makes it easy to report PID, COMM, etc.
- It becomes a model for extending restrictions beyond networking.

The set of enforced cgroups is stored in a BPF hash map and the
deny/allow lists are stored in BPF trie maps. An IP address is
first checked against the allow list. If found, it's checked for
an override in the deny list. The policy is default deny. However,
the absence of the NetworkRestrictions API object is allow all.

IPv4 addresses are additionally registered in IPv6 trie (as mapped)
to account for dual stacks. However it is unclear if this is sufficient
as 4-to-6 transition methods utilize a multitude of translation and
tunneling methods.
2021-07-16 16:49:04 -07:00
Brian Joerger a0f9729c12 ListNodes limit exceeded test timeout fix (#7464) 2021-07-15 19:11:26 -07:00
Joel 98d51c529d Implement an API for exporting session events (#7360) 2021-07-14 01:29:00 +02:00
Joel 01dd8068aa Allow querying for audit events in either an ascending or descending order (#7425) 2021-07-12 13:14:05 +02:00
Andrej Tokarčík b3aba1aed8 Disable nonlocal SetClusterAuditConfig calls (#7465) 2021-07-07 18:49:31 +02:00