Commit Graph
64 Commits
Author SHA1 Message Date
Hugo Shaka 061b0e2bea lint (#50690) 2025-01-02 19:50:08 +00:00
rosstimothy 47c021650c Convert lib/devicetrust to use slog (#50458) 2024-12-19 22:41:37 +00:00
Zac Bergquist b1d8c3bdf0 devicetrust: don't invoke powershell when reading system information (#50372)
The device trust web flow can result in a web browser launching
Teleport Connect (which launches tsh, which in turn launches
powershell).

Some antivirus solutions flag cases where a powershell process is
a descendent of a web browser process. In order to avoid being
blocked by the antivirus software, we want to read system information
directly instead of via powershell.
2024-12-19 18:55:53 +00:00
Grzegorz Zdunek 095b0a329a Show device trust status in Connect (#49508)
* Check if device is trusted

* Move `TrustedDeviceRequirement` enum to a separate file and generate TS definitions for it

Generating TS definitions for the entire legacy/types/types.proto would result in 50K lines of generated code, and the bundle size would increase by ~20% (around 1 MB).

* Extract function to calculate device trust requirement that can be used both by the server and the client

Important: it now uses `GetEnforcementMode` instead of `GetEffectiveMode`. The check for OSS module is performed on the server-side anyway.

* Check what is device trust requirement based on cluster config and user roles

* Show device trust status in UI

* Remove `types.` prefix

* Improve godocs

* Bring back `getRoles func() ([]types.Role, error)`

* Simplify `TestHasDeviceTrustExtensions`

* Clean up and improve `TestCalculateTrustedDeviceRequirement`

* Move `CalculateTrustedDeviceRequirement` and tests to a separate file

* Add colors to shield icons

* Declare variables where they are used

* Extract a component to display device trust status for better readability

* Correctly reference `lib/client.ProfileStatus.Extensions`

* Set group limit to 8

* Make `switch` exhaustive

* Regenerate protos

* `make fix-license`
2024-11-29 10:11:30 +00:00
Nic Klaassen 0a0d4137db eliminate rsa.GenerateKey and lib/auth/native (#47768) 2024-10-21 20:55:22 +00:00
Alan Parraandrosstimothy 335cae0dc9 Fix TestAutoEnroll_disabledByEnv flakiness (#47723)
* Fix TestAutoEnroll_disabledByEnv flakiness

* Use t.Setenv

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2024-10-18 19:00:21 +00:00
Alan Parra 6669f2d160 feat: Disable auto-enroll via environment variable (#47679) 2024-10-18 17:02:02 +00:00
Alan Parra 0b751713b5 fix: Avoid needless user escalation during auto-enroll (#47676) 2024-10-18 13:25:06 +00:00
Zac Bergquist c8b364efb1 Set min macOS version to 11 (#46461)
Go 1.23 has a hard requirement of macOS11 Big Sur or later.
2024-10-04 23:31:00 +00:00
Alan Parra 4d9fab6962 fix: Enforce device trust on OSS processes (#46940)
* fix: Enforce device trust on OSS processes

* Fix TestSessionController_AcquireSessionContext
2024-09-27 14:13:32 +00:00
Nic KlaassenandAlan Parra f1083d89f0 remove lib/client dependency on lib/devicetrust/authn (#45673)
* remove lib/client dependency on lib/devicetrust/authn

* add cgo depguard

* fix typo

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

---------

Co-authored-by: Alan Parra <alan.parra@goteleport.com>
2024-08-22 20:38:30 +00:00
Nic Klaassen 45d33c4751 Device Trust support for split SSH and TLS keys (#45546)
* Device Trust support for split SSH and TLS keys

* chalResp -> tpmChallenge

* clarify comment on sha256 import

* use input struct, crypto.Signer instead of keys.PrivateKey

* use trace errors in challenge package
2024-08-19 18:59:08 +00:00
Tiago Silva cdfed087b8 [devicetrust] fix: handle server errors in bi-directional streams (#44677)
* [devicetrust] fix: handle server errors in bi-directional streams

Fix an edge case in the devicetrust gRPC bi-directional stream handler where the stream could terminate with an error after the last client `Recv` call but before the next `Send` call.
Previously, this scenario caused the `Send` method to return an `io.EOF` error, which indicated that the connection was terminated but did not reveal any errors returned by the server.
This update ensures that the client continues to consume the stream until an error is returned, allowing for proper error handling and more robust stream management.

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>

* add license headers

* drop helper and local skip io.EOF errors

---------

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
2024-07-30 08:45:07 +00:00
Tiago SilvaandAlan Parra e05dd7f379 [sec_scan][17] add AssertDevice to FakeDeviceService (#44159)
* [sec_scan][17] add `AssertDevice` to `FakeDeviceService`

This PR introduces a `AssertDevice` logic into `FakeDeviceService` to authenticate devices during unit tests using device trust credentials.

This PR is part of https://github.com/gravitational/access-graph/issues/637.

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>

* simplify assert tests

* Update lib/devicetrust/assert/assert_test.go

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

---------

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
Co-authored-by: Alan Parra <alan.parra@goteleport.com>
2024-07-15 09:11:09 +00:00
Alan Parra 2cb249dc9f Define server-side device assertion interfaces (#44036)
* Define server-side device assertion interfaces

* Update proto comments

* Update generated protos
2024-07-11 13:13:47 +00:00
Tiago Silva e3ae590c21 [sec_scan][6] add device events (#43905)
This PR adds the ability to watch for events for `*devicepb.Device` objects.

Backend storage representation of  `devicepb.Device` is achieved using an internal representation that lives in `e/lib/devicetrust/storage` and whose logic is internal to the package.

To be able to expose the unmarshal logic necessary for events to work, this PR exposes a registration hook that `e/lib/devicetrust/storage` function must call during initialization to register the unmarshal function.

Part of https://github.com/gravitational/access-graph/issues/637

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
2024-07-11 10:27:54 +00:00
Alan Parra a545068e65 Add a client-side API to assert devices (#43890)
* Add a client-side API to assert devices

* Add a godoc to authnStreamAdapter
2024-07-10 16:26:53 +00:00
Michael b85d1a6e0e Include BuildCommunity in built type checks (#42391)
* Include BuildCommunity in built type checks

This commit will add two new methods to the modules interface,
IsEnterprise and IsOSS. This is to help alieviate any pain around the
code base that used to look specifically for BuildOSS. Now that we have
two "oss types" (oss and community), we can use these methods to do
enterprise/oss checks, rather than specifically looking at the build
type. This also will allow any future build types to not affect these
checks again in the future.

* Update e
2024-06-04 20:10:38 +00:00
Zac Bergquist 631c1fcae2 Update min macOS version to 10.15 (#42017)
Teleport 16 will be built with Go 1.22, which requires macOS 10.15
(Catalina) or later.
2024-05-28 14:59:31 +00:00
Alan Parra a1c7ab71a2 Modify lib/devicetrust/authn to return the DeviceConfirmationToken (#40377)
* Update FakeDeviceService to issue confirmation tokens

* Modify lib/devicetrust/authn to return the DeviceConfirmationToken
2024-04-12 14:34:22 +00:00
Alan Parra e178635711 fix: Set an upper bound for the DMI cache file (#40219) 2024-04-04 21:45:56 +00:00
Alan Parra fd562794cb Implement client-side device web authentication (#39426)
* Implement client-side device web authentication

* Update TestCeremony_Run
2024-03-18 14:51:53 +00:00
Alan Parra 5056cec1ba Fix .clangd file on lib/devicetrust/native (#39062) 2024-03-07 16:42:00 +00:00
Alan Parra a469c4ce2b feat!: Apply role device mode to App Access (#35274)
* Apply role device mode to App Access

* nit: Don't capture traces on guard errors

* Consistently return ErrTrustedDeviceRequired

* Surface device error trust error for apps

* Reply with a custom message for device trust errors

* Review: Remove the DisableDeviceAuthorization field

* Review: Refactor device trust message into its own method

* Review: Wrap guard errors

* Review: Simplify device error message
2023-12-04 17:53:30 +00:00
fheinecke b178b8b732 Updated Teleport codebase to AGPL3 license (#35259)
Signed-off-by: Fred Heinecke <fred.heinecke@goteleport.com>
2023-12-01 17:48:14 +00:00
Alan Parra f86c527a31 Collect device data concurrently on Windows (#34707) 2023-11-21 13:38:30 +00:00
Alan Parra ffce86db1f Keep a device data cache in-process (#34597) 2023-11-17 13:27:23 +00:00
Alan Parra 0cef1a31ca Return an user-friendly message on TPM permission errors (#34681)
* Return an user-friendly message on TPM permission errors

* Drop tpmDevice.signChallenge

* Create parents when creating the state dir
2023-11-17 13:03:28 +00:00
Alan Parra 40dc2e9c6c Collect device data concurrently on Linux (#34602)
* Read DMI files concurrently

* Refactor DMI logic into its own method

* Collect device data concurrently on Linux

* Drop the mutex on DMIInfoFromFS, simplify
2023-11-16 14:20:57 +00:00
Alan Parra e92d0bffff Add the os_id field to device messages (#34588)
* Add the os_id field to device messages

* Update generated protos

* Add os_id field conversions

* Collect os_id on Linux devices

* Fix Linux tests
2023-11-16 13:05:47 +00:00
Alan Parra 7008dc1fc2 Implement Linux support for device enroll and authn (#34557)
* Close streams on errors

* Rename fake_windows_device.go to fake_tpm_device.go

* Test enroll/authn ceremonies against Linux

* Allow Linux devices to enroll and authenticate

* Implement Linux TPM methods

* Attempt attestation without the event log on failures
2023-11-14 14:23:30 +00:00
Alan Parra 9db7a1bf96 Implement device data collection for Linux (#34467)
* Rename others.go to device_others.go

* Move various functions to tpm_common.go

* Read device collected data on Linux

* Add the mode param to native.CollectDeviceData

* Add the mode param to collectDeviceData

* Run escalated `tsh device dmi-info`

* Write cached DMI info

* Read cached DMI info

* Avoid asset tags with spaces on them

* nit: Use deviceStateFolderName without a dot on Linux

* Test various data collection scenarios

* Fix macOS/Windows typo
2023-11-14 13:13:22 +00:00
Alan Parra ee9ded0ec6 Refactor device TPM logic to better support Linux (#34133)
* Dupe device_windows.go

* Split functions between generic and OS-specific

* Add the tpmDevice abstraction

* Add "No Asset Information" to the list of skipped tags

* Appease linter, reintroduce windows build tag
2023-11-02 16:40:52 +00:00
Alan Parra c5ec921536 fix: Use octal mode for Windows TPM files (#34102) 2023-11-01 13:21:32 +00:00
Alan Parra 32bcd71591 fix: Fix panic on tsh device enroll --current-device (#32694)
* Test RunAdmin enrollment failure

* Fix RunAdmin when enrollment fails, protect tsh from nil device
2023-09-28 13:56:46 +00:00
Alan Parra ff44238edd fix: Skip known bad asset tags on Windows (#31360) 2023-09-04 15:03:42 +00:00
Brian Joerger cf6473feb9 Add gRPC error interceptors to API client (#30578)
* Move gRPC error intercetpors to api/utils/grpc/interceptors.

* Use error interceptors in api client and mock server.

* Apply suggestions from CR.

* Unwrap FromGRPC errors in middleware.

* Use gRPC auth service in tests instead of external example service.

* It's gRPC!!!

* Fix unit test.

* Add error interceptor to proxy client.

* Fix merge conflict.
2023-08-24 23:27:06 +00:00
Alan Parra 5c8f91a4dd Add --current-device capabilities to tsh and tctl (#30636)
* Add the `tsh device asset-tag` hidden command

* Implement registration in the fake device service

* Add `--current-device` to `tsh device enroll`

* Add `--current-device` to various `tctl` commands

* s/currentDeviceCommand/canOperateOnCurrentDevice/

* Delete the non-unused `enroll.RunCeremony`

* Document RunAdminOutcome

* fix: Correctly handle partial successes

* nit: Logging
2023-08-18 15:03:50 +00:00
Alan Parra d1cb52d7e6 fix: Save device keys on os.UserCacheDir (#30171) 2023-08-08 14:26:36 +00:00
Alan Parra 2033220279 fix: Drop custom OS checking in device authn (#29609) 2023-07-25 22:17:49 +00:00
Alan Parra ec8594f96d fix: Ignore staticcheck false positive on darwin (#28038) 2023-06-19 18:42:10 +00:00
60a325aa7c Device Trust: tsh privilege elevation for TPM enrollment (#27833)
* Start fleshing out UAC elevation

* Use `runas` and ShellExecuteW to open a child process with elevated privileges

* Add tsh command to re-execute

* Add method to be called in the elevated child process

* Ugly, but working, credential activation in UAC dialogued child

* Add TODO

* Add some further notes/explanation on windows.ShellExecute

* Change error message to match function name

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* Improve comment

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* Use `trace.BadParameter` instead of `Errorf`

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* Use `tpm-activate-credential` instead of `activate-credential`

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* Remove spurious newline

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* Move towards more production ready elevated process

* Add stubs for darwin/other

* Use path in state dir for cred activation results

* Fix stub return values

* Fix test missing context.Context pass

* Add additional message when cred activation completes

* Use ShellExecuteExW to get handle to process to wait on

* Improve comment in windowsexec

* Minor stylistic changes from review

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* Minor adjustments to error handling and logging

* Use `windows` over `syscall`

* Leverage `mkwinsyscall`'s error handling

* Missing param in test

* Always show error, not just when `-d` is provided

* Remove unnecessary trace.Wrap(err)

* Restore cf.Debug check

* Explicitly ignore return values from `FPrintln`

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* Simplify code

* Add null check to `info.hProcess`

* Minor format changes from review

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>

---------

Co-authored-by: Alan Parra <alan.parra@goteleport.com>
Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
2023-06-16 17:35:03 +00:00
Noah Stride 87ab3ffe37 Add Proto types for storing TPM Platform Attestation in Collected Data (#27680)
* Add types for storing Platform Attestation

* Add to/from resource conversion

* Use bytes for nonce field

* Tidy up usage of pointers

* Ensure tests cover multiple entries

* Adjust comments as per PR review
2023-06-12 16:13:26 +00:00
Brian Joerger ae4303c84b Replace global testing variables for device trust with pluggable ceremony interface. (#27039) 2023-06-01 17:37:51 +00:00
Alan Parra 44a656f868 Refactor test globals out of lib/devicetrust/enroll (#27084) 2023-05-30 20:13:00 +00:00
Noah Stride 63b0612687 Windows TPM Device Authentication (#26830)
* Start of Windows support for authentication

* Finish clientside implementation of TPM device auth

* Rename getOSType -> getDeviceOSType everywhere

* More efficient byte trimming suggested by Zac

* Use `filepath.Join` rather than `path.Join`

* Add test for device auth

* Improve comments

* Log TPM closure errors

* Rename Auth -> Authn for clarity

* GoDoc for FakeDevice iface

* Use UserConfigDir rather than UserHomeDir
2023-05-30 07:07:12 +00:00
Noah Stride f330bd0bee Device Trust: TPM Enrollment support EKCerts (#27070)
* Send EKCert if one is present

* Consistent naming

* Add configuration types for EKCertAllowedCAs

* Add fileconfig support for EKAllowedCAs

* Add test cases for fileconf loading and parsing

* Rename helper functions for consistency

* Correct GoDoc format

* Add source URL for pem file
2023-05-29 18:42:41 +00:00
Alan Parra 2083dc8109 Fix "unnecessary conversion" in lib/devicetrust/native (#27051)
It trips the "unconvert" linter.
2023-05-29 13:32:16 +00:00
Alan Parra 5031d9581f Collect MDM data from macOS (#26796)
* Collect MDM data from macOS

* Add serial number and model examples
2023-05-25 12:56:12 +00:00
Noah StrideandAlan Parra 13dfbbc1e1 Windows TPM enrollment support (#25801)
* Start implementation of Windows TPM enrollment

* Basic device data collection for windows

* Add AK get/creatiom

* Add helpers for converting tpm protos

* Don't create AK in inappropriate circumstances

* Furhter simplify AK load/create

* Add tests for proto/attest conversions

* Ensure that digestalg varies between test cases

* More accurate proto field name

* Missing license header

* Add credential fingerprinting function

* Add getDeviceCredential implementation for windows

* Add dependencies so this builds

* Fix generation of credential id

* Introduce AKPublic field

* Collect other key data

* Add some additional debug logging

* Add more specific serial number fields to dcd

* Use faster powershell call for determining OS version

* Fix missing field in DeviceFromResource

* Add link to to-do issue

* Add packages necessary for enterprise submodule

* Fix import orders

* bump go-tpm-tools to latest versions

* Tidy up returned errors

* Add failure case test for Linux enrollment

* move linux device fake to lib/devicetrust/testenv

* Add test to exercise `RunCeremony`

* Tidier assertion messages

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* Further simplifcations of test assertions/errors

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* Apply suggestions from code review

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* Further fixes as per the llama's suggestions

* Further simplification and header on logs

* Use BadParameter rather than platform unsupported

* Add further notes on RSAness of `go-attestation`

* Minor adjustments to comments

* Unused import removed

* License headers

* rename `mustRandomBytes` -> `randomBytes`

---------

Co-authored-by: Alan Parra <alan.parra@goteleport.com>
2023-05-22 16:50:52 +00:00