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.
* Read DMI files concurrently
* Refactor DMI logic into its own method
* Collect device data concurrently on Linux
* Drop the mutex on DMIInfoFromFS, simplify
* 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
* 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
* 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
* 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>
* 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
* 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
* 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
* 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>
Handle a few common macOS errors, as well as gRPC unimplemented errors, and
return more user-friendly messages in their place.
gravitational/teleport.e#514
Implement native macOS methods required by device enrollment, namely methods to
Create/Get the device key, Sign challenges with it, and to collect device data
(aka serial number).
The implementation is rather similar to lib/auth/touchid, but simpler in a few
aspects:
1. Device keys don't require user interaction (as in they don't cause a touch ID
prompt); and
2. There exists, at most, a single device key at all times.
I've added a tiny refactor to reuse Apple public key parsing from touchid, plus
some changes so touchid doesn't break in the face of unexpected keys (which the
device key didn't cause, per se, but my experiments getting to it did).
gravitational/teleport.e#514
Implement the client-side enrollment ceremony and define the interfaces for
native-only methods.
The server-side implementation for Device Trust is Enterprise-only, so sadly we
can't against the real server here. I've opted to write a couple of fakes that
we can reuse for the device authentication ceremony and, eventually, to test
against other OS implementations. The current design attempts to write as much
as possible without build tags, so we can unit test the most of it.
Follow ups will add the native parts and wire the ceremony to the corresponding
`tsh` command.
gravitational/teleport.e#514