Commit Graph
206 Commits
Author SHA1 Message Date
Edoardo Spadolini ccffd6b5be Allow unknown fields when unmarshaling protojson resources (#53469)
* Prohibit implicitly strict protojson unmarshaling

* Avoid jsonpb.Unmarshal

* Define marshal option to disallow unknown fields

* Avoid protojson.Unmarshal

* Disallow unknown fields in tctl create

* Disallow unknown fields in the web UI
2025-03-27 14:35:37 +00:00
Zac Bergquist b0049ecc2a Remove the custom current user lookup function (#52144)
We added this function to mitigate slow user.Current() calls in
Windows Active Directory environments. Go 1.24 ships with an optimized
verison of user.Current, rendering this utility unnecessary.

Closes #41922
2025-03-04 23:43:54 +00:00
Zac Bergquist cc3122e2fa Remove unnecessary keysIn helper (#52671)
* Remove unnecessary keysIn helper

* Remove slices.Any

It's a carbon copy of the standard library's slices.ContainsFunc.
2025-03-03 14:31:30 +00:00
STeve (Xin) Huang a344745017 GitHub proxy: git to prompt for password when tsh session expires (#51305)
* GitHub proxy: git to prompt for password when tsh session expires

* replace reference

* set ctx
2025-02-25 16:14:15 +00:00
STeve (Xin) Huang 84b66bd247 Do not delete integration CAs on auth init (#51938)
* Do not delete integration CAs on auth init

* change to an iterator

* fix lint
2025-02-13 21:02:57 +00:00
rosstimothy 2cced62805 Fix violations of non-constant format strings linter (#51812)
Depends on https://github.com/gravitational/teleport.e/pull/6006.
Now that we are compliant, the ignore rule was removed from the
golangci-lint config to prevent future regressions.
2025-02-04 16:43:35 +00:00
Tiago SilvaandGavin Frazar b61e70ea19 netiq: add plugin install prompt (#51502)
* netiq: add plugin install prompt

This PR adds the plugin prompt code to read the required parameters to
create the netiq plugin.

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

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

* add license

* Update netiq.go

Co-authored-by: Gavin Frazar <gavin.frazar@goteleport.com>

* Update netiq.go

Co-authored-by: Gavin Frazar <gavin.frazar@goteleport.com>

* Update netiq.go

Co-authored-by: Gavin Frazar <gavin.frazar@goteleport.com>

* handle review comments

* Apply suggestions from code review

Co-authored-by: Gavin Frazar <gavin.frazar@goteleport.com>

* Apply suggestions from code review

Co-authored-by: Gavin Frazar <gavin.frazar@goteleport.com>

* consolidate prompt methods

---------

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
Co-authored-by: Gavin Frazar <gavin.frazar@goteleport.com>
2025-01-29 17:57:26 +00:00
rosstimothy ef859498bc Vendor gravitational/trace/trail in api (#51032)
* Vendor gravitational/trace/trail in api

Pulling in the trail package directly in api will allow the trace
module to shed the grpc-go dependency. This needs to land prior
to https://github.com/gravitational/trace/pull/112 being included
in a new version of trace.

There should be no noticable change in the api depdency tree since
it already depends on grpc-go. Some additional items from the
trace/internal package were also vendored within trail as needed.
Additionally, some of the public api of trail that was not being
consumed has been made private.

* fix: appease linters
2025-01-14 21:04:01 +00:00
rosstimothy 17edb10e43 Permit routing to agentless nodes with non-UUID metadata.name (#50915)
We suggest that a UUID is used for agentless nodes metadata.name
field, but we do not enforce it. This causes several edge cases
and slightly weird UX in places that expect the name to be a UUID.
Most notably, this presents dialing problems for the web ui as
described in https://github.com/gravitational/teleport/issues/50914.
To allowing dialing to function in all cases for these servers,
routing has been updated to permit matches on metadata.name, however,
the match is given a lower score then a match on a UUID. This should
permit dialing, though, it may still result in ambiguity.

Closes #50914.
2025-01-09 20:35:14 +00:00
Rafał Cieślak 0ade3a8f58 Add TargetPort to RouteToApp & use it to route connections to multi-port TCP apps (#49047)
* Add TargetPort to RouteToApp and AppMetadata proto messages

* Pass TargetPort during cert generation

* Refactor Pack.makeTLSConfig to accept struct

This will make it easier to add targetPort to it.

* Add labels to UUIDs used by appaccess test pack app servers

This makes them easier to distinguish when routing doesn't work as expected.

* Refactor Pack.CreateAppSession to accept a struct

* TestTCP: Create app session within test

If we kept the old code, we'd need to manually create a session for each
target port, which would create a lot of duplication.

* Prepare integration test fixtures for multi-port tests

* Add api/utils/net.IsPortInRange

* Use TargetPort when routing TCP connections

* Inline dialMultiPortTCPApp, centralize logic

* Check target port when connecting to single-port app

* Reorder check in IsPortInRange

* Use int instead of uint16

* Extract picking dialTarget to separate function

* addr → uriAddr

* Improve err msg for single-port apps when targetPort != uriPort

* Fix unnecessary conversion to int
2024-12-03 13:55:00 +00:00
Rafał Cieślak 87320df204 Add Ports field to app spec (#47706)
* Add Ports to AppSpecV3

* Validate ports of api/types.AppV3

* Add Ports to lib/config and lib/service/servicecfg

* lib/config TestApps: Improve error messages

* lib/service: Convert servicecfg.PortRange to types.PortRange

* Add multi-port TCP apps to config and tctl tests

* Rename Ports to TCPPorts

* Change port fields to uint16 where possible

* Update comments for Port and EndPort

* Extract port range validation to api/utils/net

* Replace custom check type with require.ErrorAssertionFunc

* Simplify validation of end port

* Fix expected message in api/types test

I forgot to update that one.
2024-12-03 12:41:12 +00:00
Nic Klaassen 75c2cef688 improve error message when v17 tctl reads v16 tsh profile (#49305) 2024-11-21 21:52:05 +00:00
Edoardo Spadolini bcbfa8192e Get rid of math/rand in favor of math/rand/v2 (#49294)
* Get rid of math/rand in favor of math/rand/v2

* Update retryutils to use rand.N

* Update e ref
2024-11-21 12:57:32 +00:00
Edoardo Spadolini a92e49fc74 Use thread-local RNGs for jitters (#48860)
* Use math/rand/v2's thread-local RNG for jitters

* Replace NewJitter() with DefaultJitter

* Replace NewFullJitter() with FullJitter

* Replace NewHalfJitter() with HalfJitter

* Replace NewSeventhJitter() with SeventhJitter

* Inline jitters in lib/utils/diagnostics/latency

* Replace var jitters in lib/utils with proxy functions

* Replace utils.HalfJitter with retryutils.HalfJitter

* Replace utils.FullJitter with retryutils.FullJitter

* Replace utils.SeventhJitter with retryutils.SeventhJitter

* Replace sharded jitters with thread-local ones

* Remove NewSeventhJitter reference in integrations
2024-11-13 16:35:09 +00:00
Nic Klaassen 47502620e2 feat: PuTTY PPK support for non-RSA keys (#48650)
The commit adds support for Ed25519 and ECDSA keys to PuTTY PPK files
generated by tsh. It also adds support for Ed25519 and ECDSA trusted
host CAs.
2024-11-12 20:03:19 +00:00
Brian Joerger b7c0e79fed Remove delayed closing of yubikey connection to prevent the connection from leaking after program execution. (#48414) 2024-11-06 20:11:02 +00:00
Grzegorz Zdunek 47494db923 Sign a hashed message in hardware key warmup call (#48206)
Otherwise, signing may fail with "input must be a hashed message" error.
2024-10-31 22:09:39 +00:00
Tiago SilvaandMarco Dinis 768a0bd684 [entraid] add setup script for offline clusters. (#47863)
* [entraid] add setup script for offline clusters.

This PR adds a cli configuration for Entra ID where it's possible to default to system credentials instead of relying on OIDC for authentication in EntraID. OIDC is not always a possibility specially when the cluster is private and not internet acessible.

The UX is the following:

```text

Step 1: Run the Setup Script

1. Open **Azure Cloud Shell** (Bash) using **Google Chrome** or **Safari** for the best compatibility.
2. Upload the setup script using the **Upload** button in the Cloud Shell toolbar.
3. Once uploaded, execute the script by running the following command:
   $ bash entraid.sh

**Important Considerations**:
- You must have **Azure privileged administrator permissions** to complete the integration.
- Ensure you're using the **Bash** environment in Cloud Shell.
- During the script execution, you'll be prompted to run 'az login' to authenticate with Azure. **Teleport** does not store or persist your credentials.
- **Mozilla Firefox** users may experience connectivity issues in Azure Cloud Shell; using Chrome or Safari is recommended.

Once the script completes, type 'continue' to proceed, 'exit' to quit: continue

Step 2: Input Tenant ID and Client ID

With the output of Step 1, please copy and paste the following information:
Enter the Tenant ID: 1056b571-0390-4b08-86c8-2edba8d9ae79
Enter the Client ID: 1056b571-0390-4b08-86c8-2edba8d9ae79

Successfully created EntraID plugin "name".
```

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

* move function to api

* handle code review comments

* Apply suggestions from code review

Co-authored-by: Marco Dinis <marco.dinis@goteleport.com>

* fix url

* enable group claims

* add godoc

* handle code review comments

* fix gomod

---------

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
Co-authored-by: Marco Dinis <marco.dinis@goteleport.com>
2024-10-29 17:51:58 +00:00
Grzegorz Zdunek 22b50149df Support hardware keys prompts in Connect (#47652)
* Add new protos for hardware key prompts

* Implement hardware key prompts on the daemon side

* Show prompts in the UI

* `PromptHardwareKeyPINAsk` -> `PromptHardwareKeyPIN`

* Improve proto docs

* `PromptHardwareKeySlotOverwrite` -> `ConfirmHardwareKeySlotOverwrite`

* Fix typo

* Remove unnecessary `form`

* Pass an enum to `AskPIN` instead of the entire message

* Remove an invalid restriction of PIN/PUK to numbers only

* Improve the copy
2024-10-23 07:12:33 +00:00
Nic Klaassen 0a0d4137db eliminate rsa.GenerateKey and lib/auth/native (#47768) 2024-10-21 20:55:22 +00:00
Grzegorz Zdunek 95af4c1808 Support custom hardware key prompt (#47273)
* Allow passing custom prompt to YubiKey

* Handle `prompt.Touch` cancellation

* Pass `HardwareKeyPrompt` through all the layers

* Add an empty `HardwareKeyPromptConstructor` to Connect

* Remove `ParsePrivateKeyWithCustomPrompt`

* Add missing godoc

* Fix teleterm tests

* Include `cliprompt.go` only for `go:build piv && !pivtest`

* Lint and test fixes
2024-10-16 10:00:03 +00:00
Grzegorz Zdunekandjoerger bd6fdbf2c1 Cache PIV connections to share across the program execution (#47091)
* Cache yubikey objects.

* Cache PIV connections to share across the program execution.

* Do not release the connection until `sign` returns

* Do not ignore errors

* Perform a "warm up" call to YubiKey

* Fix tests

* Use a specific interface to check if the key can be "warmed up"

* Allow abandoning `signer.Sign` call when context is canceled

* Make sure that the cached key is valid for the given private key policy

The reason for adding this check was failing `invalid key policies` test.

* Make `hardwareKeyWarmer` private

* Force callers to release connection

* Improve comments

* Fix lint

* Improve `connect` comment

* Fix race condition

* Simplify `release` logic

* Trigger license/cla

---------

Co-authored-by: joerger <bjoerger@goteleport.com>
2024-10-16 08:02:17 +00:00
rosstimothy 185988f449 Clean up code marked for deletion in v17 (#47364)
* Clean up code marked for deletion in v17

Removes legacy PIVSlot and App SessionID marked for deletion in v17

* fix: remove missed todo delete comment

* fix: restore comment about caching routeToApp

* fix: validate scope and restore username retrieval

* fix: setting scopes in requests

* fix: update TF docs
2024-10-10 15:36:53 +00:00
Krzysztof SkrzętnickiandNic Klaassen cb2f54c2a7 Fix creation of JKS wallet for Oracle. (#47212)
* Fix creation of JKS wallet for Oracle.

Unwrap *keys.PrivateKey to fetch inner signer that satisfies `x509.MarshalPKCS8PrivateKey` expectations. This change allows passing keys.PrivateKey to createJKSWallet. The updated function will correctly marshal the private key for Oracle's JKS wallet creation.

* Add and use `MarshalSoftwarePrivateKeyPKCS8DER`.

* Update lib/client/db/oracle/oracle_test.go

Co-authored-by: Nic Klaassen <nic@goteleport.com>

---------

Co-authored-by: Nic Klaassen <nic@goteleport.com>
2024-10-08 08:15:13 +00:00
Brian Joerger 6a1d6662dd Unify and simplify MFA Ceremony helpers (#46986)
* Refactor MFA ceremony helpers.

* Refactor session MFA ceremony to use new MFA ceremony helpers.

* Simplify calls to NewMFACeremony.

* Remove remaining usage of tc.PromptMFA in favor of Ceremony.

* Rename prompt constructor.

* Add godoc to ceremony; update tests.

* Cleanup.

* Resolve comments; fix tests.

* Update comments.

* Fix test.

* Fix lint.
2024-10-02 19:09:45 +00:00
Nic KlaassenandEdoardo Spadolini 1efa0ae77c fix: tolerate mismatched key PEM headers (#46725)
* fix: tolerate mismatched key PEM headers

Issue #43381 introduced a regression where we now fail to parse PKCS8
encoded RSA private keys within an "RSA PRIVATE KEY" PEM block in
some cases.
This format is somewhat non-standard, usually PKCS8 data should be in a
"PRIVATE KEY" PEM block. However, certain versions of OpenSSL and
possibly even Teleport in specific cases have generated private keys in
this format.

This commit updates ParsePrivateKey and ParsePublicKey to be more
tolerant of PKCS8, PKCS1, or PKIX key data no matter which PEM header is
used.

Fixes #46710

changelog: fixed regression in private key parser to handle mismatched PEM headers

* fix typo in comment

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

---------

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2024-09-18 19:20:43 +00:00
Nic KlaassenandBernard Kim eff0a707d7 split SSH and TLS keys in tsh login (#45995)
* key split wip

* fix piv tests

* fix terraform tests

* spelling fixes

* fix kube benchmark

* fix identity files in integrations tests

* self review

* fix typo in comment

Co-authored-by: Bernard Kim <bernard@goteleport.com>

* speed up device login tests

* use EC keys in TestProxyAppWithIdentity

* faster tsh tests

* fix race on error value

* fix lint

* write out EC SSH keys in OpenSSH format

* fix lint

* fix keyring comparisons

* PrecomputeTestKeys in lib/client

* parallelize TestNoRelogin subtests

* use ecdsa for self-signed TLS certs

* remove redundant GetTrustedCerts

* improve latency of precomputeTestKeys

Instead of waiting for all 25 test keys before returning a single one,
tests can now make use of the first precomputed test key as soon as it's
ready.
In local testing with this change, the first key is ready after ~75ms vs
>350ms on master.

* fix test and lint

---------

Co-authored-by: Bernard Kim <bernard@goteleport.com>
2024-09-12 19:36:32 +00:00
Edoardo Spadolini 4957735a31 Get rid of internal reloads (#44882)
* disable tls client resumption

* avoid redundant verification in TLSDial

* fix wrong use of InsecureSkipVerify in HTTP auth client

* avoid overwriting GetClientCertificate in api client

* Use a getter function for CAs in TunnelAuthDialer

* Use dynamic connector data for the agent's auth client

* Make getPROXYSigner dynamic

* WIP: the thing (reloadless)

* Fix TestInstanceCertReissue

* Fix TestIntegrations/RotateFoo

* get rid of the whole reload mechanism

* Update most tests to not check for reloads

* Get rid of TestDatabaseAccess/RotateTrustedCluster

The test has been unconditionally skipped for two years now.

* avoid clobbering the auth connector

* overwrite clientState in update_servers anyway

* fix integration/hsm tests

* Document ListenForNewEvent

* fix RunWithSignalChannel godoc

* simplify ListenForNewEvents

* Remove forgotten commented code

* Explain the t.Setenv trick for non-parallelism

* explain waitingForNewEvent in integration/hsm
2024-09-11 21:13:09 +00:00
Nic Klaassen c15825c751 use configured algorithms for dynamic SSH host certs (#46329)
* dynamic SSH host certs use configurable algorithms

* lazily PrecomputeKeys everywhere

* slightly speed up TestTSHConfigConnectWithOpenSSHClient
2024-09-11 19:21:50 +00:00
Krzysztof Skrzętnicki 7ce2d0e323 Fix incorrect PostgreSQL spelling (#46072) 2024-09-02 08:24:57 +00:00
Marco DinisandRoman Tkachenko 54cdfb6895 AWS OIDC: Ping rpc and endpoint (#45702)
* AWS OIDC: Ping rpc and endpoint

* Update lib/integrations/awsoidc/ping.go

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

* Update integration.go

---------

Co-authored-by: Roman Tkachenko <roman@goteleport.com>
2024-08-23 07:35:15 +00:00
Nic Klaassen 6eb6b981b3 Split user keys for k8s access (#44779)
* split user keys for k8s access

* remove unnecessary loop

* prevent race when reading/writing key/cert pairs

* reuse RSA keys

* single file for kube key and cert

* update comment with file layout
2024-08-13 17:41:33 +00:00
Nic Klaassen 7906e13952 split user keys for db access (#44718) 2024-08-08 01:10:41 +00:00
Nic Klaassen cbb19fece2 Split user keys for app access (#44609)
* rfd edits

* split keys for app access

* update paths visualization

* godocs

* speed up TestAppCommands

* fix possible panic in test

* fix piv test
2024-08-06 22:40:57 +00:00
Nic Klaassen afca8aefc8 allow EC ssh keys in FIPS mode (#44476)
* allow EC ssh keys in FIPS mode

* fix test
2024-07-19 19:59:54 +00:00
STeve (Xin) Huang f240bfb312 Amazon DocumentDB access part 1 (#43867)
* Amazon DocumentDB access part 1

* fix lint

* make derive
2024-07-16 15:17:06 +00:00
Hugo Shaka 26f9b77948 Support detecting a credential expiry (#43886)
* Support detecting a credential expiry

* Fix Expiry() and add tests

* protect identityFile cred with a lock

* add godoc

* Fix tests
2024-07-11 02:57:14 +00:00
Nic Klaassen fb8ef40e01 remove RSA-specific methods on keys.PrivateKey (#43982) 2024-07-10 18:50:39 +00:00
Nic Klaassen a48c4f7765 configurable key algorithms for proxy to database agent certs (#43329)
* configurable algorithms for proxy to database agent certs

* rfd edit

* use v1 suite in test

* fix typo

* fix bad merge
2024-06-26 23:06:22 +00:00
Nic Klaassen bcb169912d consolidate (un)marshalling of keys to/from PEM format (#43260)
* consolidate (un)marshalling of key PEMs

This commit consolidates various functions we have for marshalling
private and public keys to and from the PEM format, mostly by replacing
functions from lib/utils and lib/tlsca with equivalents in api/utils/keys.

The new functions also support ECDSA and Ed25519 keys, which is
necessary for the implementation of RFD136.

* speed up TestMTLSClientCAs

* fix new use in local proxy middleware
2024-06-21 19:32:11 +00:00
Forrest c653a844f1 add ability to disable unqualified hostname lookups (#42952) 2024-06-20 20:20:16 +00:00
Alan Parra 435a21badc chore: Bump AWS modules (#42316)
* chore: Bump AWS modules

* Tidy all modules

* Accept the "eu-isoe-west-1" AWS region as valid
2024-06-03 19:05:30 +00:00
Gavin Frazar 12c113bc84 add GCP Spanner (#40859) 2024-05-07 22:21:27 +00:00
Alan Parra 72780dce68 fix: Forbid SSO users from logging in using passwordless (#41062)
* Save the WebAuthn UserHandle in the mock Key

* Simplify passwordless tests

* fix: Forbid SSO users from logging in using passwordless

* Rename tests to TestPasswordlessProhibitedForSSO
2024-04-30 19:07:57 +00:00
Marco André Dinis 0ab0909367 Use HandshakeContext instead of Handshake for TLS Connections set up (#40588) 2024-04-29 07:31:31 +00:00
Zac Bergquist 8cd1c429f5 Fix up some poor wording (#40832)
Closes #40294
Closes #39172
2024-04-23 22:01:41 +00:00
Forrest 82281e1191 route based on match quality score (#40559) 2024-04-18 23:02:26 +00:00
Edoardo Spadolini e96f103954 Fix some gRPC-tunneled connections (#40632)
* Fix some gRPC-tunneled connections

* Fix tests checking the return value of dial()
2024-04-18 16:11:00 +00:00
5c930ca9a5 Fix flaky test TestProxySSHJumpHost (#40052)
* Use testServer.MakeTestServer to fix issue with parallel runs using the same ports.

* Add deprecation comments for test server helpers outside of tools/teleport/testenv.

* Update tool/teleport/testenv/test_server.go

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

* Disable SSH resumption

Enable LoadAllCAs

Update comments

* Prevent context.Canceled from being wrapped across transport stream

trail doesn't properly handle conversions to and from errors that
are context.Canceled which results in code paths trying to evaluate
errors.Is(err, context.Canceled) failing. The error recevied is
an interceptors.RemoteError, which wraps a trace.TraceErr, which
contains a status.Status with codes.Canceled. To work around this
until trail is updated the server half of the stream was updated
to return an io.EOF if if encouters a canceled error.

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
Co-authored-by: Tim Ross <tim.ross@goteleport.com>
2024-04-04 21:20:30 +00:00
rosstimothy 8f1522bb34 Convert api to use slog instead of logrus (#39255)
THe use of slog now allows logrus to be removed from the api
module entirely.
2024-03-18 21:20:28 +00:00