Commit graph

115 commits

Author SHA1 Message Date
Jim Bishopp 4511f7a687
Client Certificate Authentication for GCP Cloud SQL (#9991)
Allow users to secure GCP Cloud SQL instances by setting "Allow only SSL
connections", which enforces client certificate authentication.

This implementation does not require any configuration changes for Teleport
users. Teleport will detect whether client certificate authentication is
required and handle either case automatically.

Client certificates are ephemeral. They are created for every connection by
calling the GCP Cloud SQL API's GenerateEphemeralCert function. Certificates
are only created when the destination Cloud SQL instance is configured to
require client certificate authentication. The configuration is detected by
requesting instance settings from the GCP Cloud SQL API on every connection
attempt.

A special case was implemented for MySQL. MySQL servers in GCP Cloud SQL do not
trust the ephemeral certificate's CA but GCP Cloud Proxy does. To work around
this issue, the implementation will connect to the MySQL Cloud Proxy port using
a TLS dialer instead of the default MySQL port when client certificate
authentication is required.

The common.CloudClients interface and implementation now return an interface
(GCPSQLAdminClient) from the GetGCPSQLAdminClient function instead of the GCP
client's sqladmin.Service. Returning an interface simplified calling code and
allowed for the client to be mocked for testing.

Existing GCP Cloud SQL tests are configured to not require client certificate
authentication by default. A new test named TestGCPRequireSSL was created to
simulate client certificate authentication for both Postgres and MySQL. This
required some minor changes to the test server code.

A new ConnectWithDialer function was added to the
github.com/gravitational/go-mysql fork. This function is available upstream in
v1.4.0 but other changes upstream resulted in a number of errors and a panic
processing network packets. So instead of upgrading, the dialer function was
copied to the Teleport fork and a custom version was created instead:
v1.1.1-teleport.1.
2022-01-31 20:52:03 +01:00
Alan Parra ff3c911cac
Update golang.org/x/crypto to v0.0.0-20220126234351-aa10faf2a1f8 (#9984)
The newer version automatically renews certificates affected by the Let's Encrypt TLS-ALPN-01 issue[1].

This is a fix for the autocert method, certbot users are unaffected

[1] https://community.letsencrypt.org/t/2022-01-25-issue-with-tls-alpn-01-validation-method/170450
2022-01-27 22:07:42 +00:00
Edoardo Spadolini e254076700
Improved Google OIDC connector (#9697)
* go get google.golang.org/api

go get: upgraded cloud.google.com/go v0.60.0 => v0.100.2
go get: upgraded github.com/golang/snappy v0.0.1 => v0.0.3
go get: upgraded github.com/googleapis/gax-go/v2 v2.0.5 => v2.1.1
go get: upgraded go.opencensus.io v0.22.5 => v0.23.0
go get: upgraded golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d => v0.0.0-20211104180415-d3ed0bb246c8
go get: upgraded google.golang.org/api v0.29.0 => v0.65.0

* Optionally fetch transitive groups in the Google OIDC connector

* Refactor the google workspace parts of the OIDC code

* Further refactoring

This undoes the user account impersonation changes, and always requires
an admin account again.

* Test coverage

* Address review comments

* Minor refactor and name changes

* Allow domain filtering, tests now bypass addGoogleWorkspaceClaims

* Update `OIDCConnectorV2` to `OIDCConnectorV3`

* Backwards compatibility for OIDCConnector v2

This also removes the extra boolean flag that was added previously.

* Update e-ref

Enterprise builds will break unless gravitational/teleport.e#385
is included.
2022-01-21 18:26:28 +00:00
Joel 62173e096b
use google/uuid instead of pborman/uuid (#9793)
* replace imports

* use google/uuid

* fix test

* reverse changelog changes

* update gomod

* zac steps

* tidy

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
2022-01-19 23:44:48 +00:00
rosstimothy 95d0f0d27f
Update google.golang.org/grpc to v1.43.0 (#9656)
Update grpc dependency to the latest version. Needed to fix the client side hang that
prevents TwoClustersTunnel from running succesfully, see #9655.
2022-01-10 15:36:50 -05:00
Edoardo Spadolini 5acab226a0
Upgrade from go.etcd.io/etcd v3.4.14 to go.etcd.io/etcd/{api,client}/v3 v3.5.1 (#9607)
* Prepare `etcdbk` to use the newer `go.etcd.io/etcd/v3` lib

* `go get go.etcd.io/etcd/api/v3 go.etcd.io/etcd/client/v3`

* Fix direct/indirect split in go.mod
2022-01-10 13:44:25 -05:00
Roman Tkachenko 95be5fda37
Update Postgres audit events (#9435) 2022-01-06 17:44:20 +00:00
Roman Tkachenko 1e09b825f6
Port fixes from v8 (#9397)
* Update oxy
* Do not allow MySQL COM_CHANGE_USER command
* Add support for all MongoDB wire messages
* Drone fix
2021-12-15 06:38:05 +00:00
Roman Tkachenko beb91db747
Bump x/crypto (#9205) 2021-12-02 17:56:06 -08:00
Roman Tkachenko 4d5493eb69
Add Azure access token auth support for Postgres/MySQL (#8951) 2021-12-01 14:30:25 -08:00
Andrew Burke 2ac300a1f8 Update vendor 2021-11-18 09:28:25 -08:00
Nic Klaassen 07ffb23e4e
make update-vendor (#9017) 2021-11-17 07:31:56 +00:00
Nic Klaassen d67e9b347f
update gosaml2 dep (#8937) 2021-11-16 10:07:11 -08:00
Nic Klaassen 3798ca8b44
replace dgrijalva/jwt-go with golang-jwt/jwt (#8939) 2021-11-12 16:09:44 -08:00
Andrew Burke 71ea32fbae
Add '+' to key sanitizer whitelist (#8396) 2021-10-28 16:02:55 -07:00
Brian Joerger 20da22ca35
API release automation with go script (#8484) 2021-10-28 10:15:47 -07:00
Russell Jones b5fc327dfb Updated go.mod and re-vendored. 2021-10-22 14:01:25 -07:00
Russell Jones 675be8fc21 Updated Go to 1.17.2. 2021-10-22 14:01:25 -07:00
Nic Klaassen 2d10515f19
Implement Simplified Node Joining (#8250) 2021-10-08 10:41:28 -07:00
Steven Martin c3b07306f8
Adds OIDC logic for Ping Provider (#8308)
Checks if provider is ping and uses only client secret post for oidc auth method

* Update go-oidc fork to v0.0.5 to include PingID workaround
2021-10-05 16:41:19 -04: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
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
Joel 48077e168f
Fix firestore (#8181) 2021-09-14 11:32:53 +02: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
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
Roman Tkachenko 060750bc88
Vendor our logrus fork to fix data race (#7940) 2021-08-17 12:58:20 -07:00
Andrej Tokarčík f97b7c09d3
Reject cert generation requests for locked-out users/hosts (#7746) 2021-08-12 19:52:13 +02:00
Brian Joerger 9b8b9d6d0c
rollback - Upgrade api version. (#7751) 2021-07-30 15:34:19 -07:00
Nic Klaassen 185e5fda35
Add hsmKeyStore implementation (#7614) 2021-07-29 13:08:01 -07:00
Brian Joerger c040aca4c1
Upgrade api version. (#7609) 2021-07-28 13:51:21 -07:00
Russell Jones 45f8954c5b Fixed vendoring issue. 2021-07-14 14:41:34 -07:00
Eugene Yakubovich c83d028d92 libbpfgo has been moved out of tracee
libbpfgo is now a standalone project and thus
requires Teleport to vendor less code.
2021-07-14 11:56:59 -07:00
Roman Tkachenko efc3973f78
Better handling of database access IAM errors (#7525) 2021-07-14 09:13:39 -07:00
Roman Tkachenko 6b9726f961
Add MongoDB database access support (#7213) 2021-06-21 22:54:05 -07:00
Andrew Lytvynov 41d0e1f557
grpc: call trail.ToGRPC from gRPC interceptors (#7217)
* grpc: call trail.ToGRPC from gRPC interceptors

The reduces the boilerplate a bit in the gRPC handlers and ensures you
won't forget the conversion.

* Update lib/auth/grpcserver.go

Co-authored-by: Andrej Tokarčík <andrej@goteleport.com>

Co-authored-by: Andrej Tokarčík <andrej@goteleport.com>
2021-06-10 15:05:56 -07:00
Russell Jones 3043809051 Updated vendoring of tracee/libbpfgo.
Updated vendoring of  github.com/aquasecurity/tracee/libbpfgo to point
to 242d721b using the following command:

CGO_LDFLAGS=-lbpf \
  go get -u -v github.com/aquasecurity/tracee/libbpfgo@242d721b
2021-05-28 15:25:23 -07:00
Eugene Yakubovich 585c33232b Move from BCC to libbpf with CO-RE. 2021-05-28 15:25:23 -07:00
Russell Jones 66f3aab036 Fixed IBM Cloud AppID SSO integration.
IBM Cloud AppID SSO returns strings as well as integers in JWT headers.
Updated version of our go-oidc fork which handles string and integer
values in JWT headers.
2021-05-20 18:45:26 -07:00
Brian Joerger f533872a25
Upgrade api's trace dependency to 1.1.15 (#6341) 2021-05-03 16:27:51 -07:00
a-palchikov d301da5a39
Embed webassets natively into teleport instead of attaching to the binary (#5935)
Switch to go1.16. Use embed package to embed webassets instead of ad-hoc attaching to binary
2021-03-26 17:37:52 -07:00
Roman Tkachenko 8739417729
Add Postgres Cloud SQL support (#5941) 2021-03-22 09:38:05 -07:00
Roman Tkachenko b2ff4df8fa
Fix app access websockets support (#6072) 2021-03-22 08:56:44 -07:00
Andrew Lytvynov efc99a068c Update Go dependencies
Several dependencies can't be updated due to breakages (etcd and grpc
for example).

Also updated ttlmap usage since their API changed.
2021-02-23 18:04:55 -08:00
Brian Joerger 427bafe7b2
API Go module (#5449) 2021-02-22 16:20:43 -08:00
Roman Tkachenko e235dfa35a
Update go-mysql to fix performance issue (#5554) 2021-02-11 17:31:56 -08:00
Roman Tkachenko 81e1102250
Add MySQL support for database access (#5453) 2021-02-10 11:08:13 -08:00
Andrew Lytvynov 491a298b1a
mfa: replace u2f-host with github.com/flynn/u2f (#5477)
This change removes the need for users to manually install u2f-host.
It also enables us to do U2F authentication with multiple devices.
2021-02-04 11:10:00 -08:00
Andrew Lytvynov e3ee42a775
Upgrade go-sqlite3 (#5436)
After a recent local C compiler upgrade, I started getting these
warnings when building teleport:

```
\# github.com/mattn/go-sqlite3
sqlite3-binding.c: In function 'sqlite3SelectNew':
sqlite3-binding.c:123303:10: warning: function may return address of local variable [-Wreturn-local-addr]
123303 |   return pNew;
       |          ^~~~
sqlite3-binding.c:123263:10: note: declared here
123263 |   Select standin;
       |          ^~~~~~~
```

Upgrading to the latest version clears those.
Here's the full changelog: https://github.com/mattn/go-sqlite3/compare/v1.10.0...v1.14.6
2021-01-29 12:15:14 -08:00
Roman Tkachenko 8e1865464b
Database access (#5005) 2021-01-14 18:21:38 -08:00
a-palchikov 6684c37103
Use fake clock consistently in units tests. (#5263)
Use fake clock consistently in units tests.
2021-01-12 12:10:00 +01:00
a-palchikov 54ee98f529
Upgrade github.com/gravitataional/trace to v1.1.13 (#5187)
* Upgrade github.com/gravitataional/trace to v1.1.12

We were a few versions behind. In particular this versions lets us use
stdlib's `errors.Is/As` to inspect errors.

* Bump trace to 1.1.13

Co-authored-by: Andrew Lytvynov <andrew@goteleport.com>
2020-12-23 11:30:15 +01:00
Andrew Lytvynov 05c73c9372
Upgrade gosaml2 library to v0.6.0 (#5118)
See https://github.com/russellhaering/gosaml2/security/advisories/GHSA-xhqq-x44f-9fgg
2020-12-14 11:34:20 -08:00
a-palchikov c94e5042c7
Server data race (#4790)
* Add logger attributes to be able to propagate logger from tests for identifying tests
* Add test case for Server's DeepCopy.
* Update test to using the testing package directly. Update dependency after upstream PR.
2020-12-09 16:46:33 +01:00
a-palchikov 7c87576a8b
flaky tests: consistent logging (#4849)
* Update logrus package to fix data races
* Introduce a logger that uses the test context to log the messages so they are output if a test fails for improved trouble-shooting.
* Revert introduction of test logger - simply leave logger configuration at debug level outputting to stderr during tests.
* Run integration test for e as well
* Use make with a cap and append to only copy the relevant roles.
* Address review comments
* Update integration test suite to use test-local logger that would only output logs iff a specific test has failed - no logs from other test cases will be output.
* Revert changes to InitLoggerForTests API
* Create a new logger instance when applying defaults or merging with file service configuration
* Introduce a local logger interface to be able to test file configuration merge.
* Fix kube integration tests w.r.t log
* Move goroutine profile dump into a separate func to handle parameters consistently for all invocations
2020-12-07 15:35:15 +01:00
Andrew Lytvynov 76d07d10cf
Bump Go to 1.15.3 (#4811)
* Bump Go to 1.15.5

* Downgraded Go version to 1.15.3.

* Sign .drone.yml

Co-authored-by: Russell Jones <rjones@gravitational.com>
Co-authored-by: Gus Luxton <gus@gravitational.com>
2020-11-16 18:36:17 +00:00
Russell Jones e94e4b5147 Updated vendoring of AWS SDK.
Vendored github.com/aws/aws-sdk-go/aws/applicationautoscaling.
2020-11-03 17:46:34 -08:00
Russell Jones a175e21c97 Vendored gopkg.in/square/go-jose.v2/jwt. 2020-11-03 14:32:13 -08:00
jane (quin) 888d6f5d9a
updated HDR histogram vendor (#4461) 2020-10-07 17:13:18 -07:00
Andrew Lytvynov cfb7839c08 Update vendored k8s dependencies 2020-09-29 21:04:02 +00:00
Andrew Lytvynov 8aacdc1b0f Update github.com/russellhaering/goxmldsig to v1.1.0
See https://github.com/russellhaering/goxmldsig/security/advisories/GHSA-q547-gmf8-8jr7
2020-09-29 17:51:50 +00:00
Sasha Klizhentas d160507430 Session streaming
This commit introduces GRPC API for streaming sessions.

It adds structured events and sync streaming
that avoids storing events on disk.

You can find design in rfd/0002-streaming.md RFD.
2020-09-28 23:08:56 -07:00
Andrew Lytvynov 3587cca784
Always collect metrics about top backend requests (#4282)
* Always collect metrics about top backend requests

Previously, it was only done in debug mode. This makes some tabs in
`tctl top` empty, when auth server is not in debug mode.

* backend: use an LRU cache for top requests in Reporter

This LRU cache tracks the most frequent recent backend keys. All keys in
this cache map to existing labels in the requests metric. Any evicted
keys are also deleted from the metric.

This will keep an upper limit on our memory usage while still always
reporting the most active keys.
2020-09-16 20:33:19 +00:00
Andrew Lytvynov 9c041361f9 Vendor testing dependencies
- github.com/stretctr/testify
- github.com/google/go-cmp
2020-08-28 00:28:45 +00:00
Andrew Lytvynov ad59af2220 Re-vendor dependencies with go mod
This is a result of "go mod vendor".
You'll notice that some versions have changed. This is due to the
transient module dependencies that dep wasn't aware of.

For example:
- Gopkg.lock imported cloud.google.com/go v0.41.0 and
  github.com/fsouza/fake-gcs-server v1.11.6
- github.com/fsouza/fake-gcs-server v1.11.6 has a go.mod file that
  depends on cloud.google.com/go v0.43.3:
  https://github.com/fsouza/fake-gcs-server/blob/v1.11.6/go.mod#L4
- therefore, "go mod vendor" bumped cloud.google.com/go to v.0.43.3

Same transient dependency version bumps got applied to some other
modules.

A few are also removed via "go mod tidy".
2020-07-17 16:09:23 +00:00
Andrew Lytvynov f8d1f0bcba Create initial go.mod
This go.mod uses the exact versions of dependencies from existing
Gopkg.lock.
2020-07-17 16:09:23 +00:00