Commit Graph
1855 Commits
Author SHA1 Message Date
bd4dcab802 Machine ID: Switch to using new tbot ssh-proxy-command by default. (#41482)
* Add warning to previous command

* Hash out basics of new tbot proxying command use

* Avoid passing full botConfig into `tbot ssh-proxy-command`

* wip

* simplify impl

* Set up test suite for ssh config generation

* Add support for checking if ALPNConnUpgrade is required

* Cache the alpn upgrade result

* Americanize Spellings

* Update lib/tbot/config/template_ssh_client.go

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

* Add CHANGELOG.md entry for breaking change

* Update tool/tbot/proxy.go

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

* Update lib/tbot/tbot.go

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

* Switch to `--no` variants rather than `={bool}`

* Use SingleFlight on alpn proxy upgrade cache

* Improve singleflight

* Add rudimentary shell quoting

* Uniformly pad the templating

* Rename shellQuote -> proxyCommandQuote

* Fix imports

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2024-05-15 17:30:54 +00:00
rosstimothy e95f3d3ed5 Start using authclient.Client/ClientI/NewClient (#41539)
Consumes the new auth client created in #41460. The changes introduced
were performed with a series of gofmt rewrite rules.

```bash
$ find ./lib/auth -type f -name '*.go' -exec gofmt -w -l -r "ClientI -> authclient.ClientI" {} \;
$ find ./lib/auth -type f -name '*.go' -exec gofmt -w -l -r "Client -> authclient.Client" {} \;
$ find ./lib/auth -type f -name '*.go' -exec gofmt -w -l -r "NewClient -> authclient.NewClientI" {} \;
$ find . -type f -name '*.go' -exec gofmt -w -l -r "auth.ClientI -> authclient.ClientI" {} \;
$ find . -type f -name '*.go' -exec gofmt -w -l -r "auth.Client -> authclient.Client" {} \;
$ find . -type f -name '*.go' -exec gofmt -w -l -r "auth.NewClient -> authclient.NewClient" {} \;
```
2024-05-15 14:09:14 +00:00
Marco Dinis c90bf7e9a4 AWS OIDC App Access: add PublicAddr to App (#41543)
* AWS OIDC App Access: add PublicAddr to App

This PR adds a missing field to the App created to handle the AWS App
Access when using the AWS OIDC credentials
The PublicAddr is required and was not being set.

* fix identation
2024-05-15 07:11:50 +00:00
Zac Bergquist 5a10566d4b tctl: add PKI domain flag for tctl auth sign --format=windows (#41495)
This comes in handy for troubleshooting multi-domain setups.
2024-05-14 20:07:15 +00:00
rosstimothy 67f499a457 Refactor auth client code into lib/auth/authclient (#41460)
This starts separating the lib/auth client and server code into
distinct packages to reduce the dependency tree of client tools.
For the time being aliases were left to all things moved into
lib/auth/authclient to reduce the changeset and ensure code still
compiles. Future changes will be built off this to convert code
to use lib/auth/authclient where applicable, this was intentionally
left to a minimum amount of changes to facilitate backports.
2024-05-14 13:28:06 +00:00
Trent Clarke fbd0091b9b SCIM only okta (#41125)
* Changes required for implementing a standalone (i.e. without Okta Sync compatibility) SCIM service in teleport.e.

Includes:

 * `tctl plugins delete` and `tctl plugins create scim` tooling
 * Moving some constants from teleport.e to OSS
 * Protobuf message types for standalone SCIM settings
 * UI updates for rendering SCIM users

Changelog: Added plugin management tooling to tctl

* Adds validation to SCIM settigs

* Linter fixup

* linter appeasement
2024-05-14 08:36:11 +00:00
rosstimothyandEdoardo Spadolini 7a7f982ed9 Add tbot ssh-proxy-command (#41346)
The new subcommand is meant to be a replacement for tbot proxy ssh
which does the ssh proxying entirely within tbot to reduce resource
consumption. The old mechanism spawned a tsh process to perform the
proxying which leads to increased CPU and memory consumption - which
can be quite problematic when used as an OpenSSH ProxyCommand for
an ansible playbook.

The new command also deviates in behavior from tsh proxy ssh in that,
for the moment, it requires users to explicitly dictate whether
tls routing, alpn connection upgrades instead of guessing by making a
call to webapi/ping. This again turns out to be quite resource
intensive when tbot is used as an OpenSSH ProxyCommand for an ansible
playbook.

In the future tbot can look this information up out of band and store
it in the proper location so that tbot ssh-proxy-command can consume
it directly without users needing to provide it. The behavior as is
provides a path toward the future while also allowing users to gain
the performance improvements now.

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2024-05-10 21:05:47 +00:00
Alex McGrath 65459e872e Remove support for disabling second factor authentication (#40956)
* dont allow disabling second factor

* update docs for 2fa change

* add environmental variable to work around disabled 2fa

* check if its cloud

* update todos

* add a test

* introduce insecure test mode

* fixes for tests
2024-05-10 11:57:34 +00:00
Gavin Frazar 9723fd096f cleanup after db ca split (#41351)
* remove database client CA event filter injection

* remove tctl database client CA fetch fallback

* remove sqlserver database client CA fetch fallback

* remove database client CA migration

* cleanup tests and mocks
2024-05-09 19:51:27 +00:00
Zac Bergquist 51110ac38b Remove unused format param (#41373)
We were never actually using the passed-in value, and instead
always read the format field of the reciever.

No functional change, as the value we passed in always happened
to be the same as the format field we were using.
2024-05-09 17:51:53 +00:00
Marco DinisandEdward Dowling 0aaf1b21c3 AWS OIDC: Script to configure EC2 Auto Discover with SSM (#41053)
* AWS OIDC: Script to configure EC2 Auto Discover with SSM

There's a new teleport command that adds an inline policy which enables
the AWS OIDC Integration to handle EC2 Auto Discover using the script
mode (SSM).
It also adds the SSM Document used in the teleport installation.

There's also a new endpoint which returns the one off script that uses
that command.

* Update lib/integrations/awsoidc/ec2_ssm_iam_config.go

Co-authored-by: Edward Dowling <EdwardDowling@users.noreply.github.com>

---------

Co-authored-by: Edward Dowling <EdwardDowling@users.noreply.github.com>
2024-05-09 17:20:27 +00:00
Noah Stride 90b761beb3 Remove tsh version check from tbot commands (#41342) 2024-05-08 21:09:36 +00:00
Gavin Frazar ed7d0d223e support gcloud spanner in tsh and web UI (#41129)
* add spanner to tsh and teleterm

* handle spanner events in web ui

* update web audit events test snapshot

* customize web ui connect for spanner

* update ConnectDialog snapshot
2024-05-07 23:17:03 +00:00
Gabriel Coradoandrosstimothy 55e2ea204f Implement debug service and its CLI commands (#39865)
* feat: debug service

* fix(service): lint and test assertion

* refactor: code review suggestions

* chore(service): update change log level log message

* fix(service): wrong error assertion

* fix(service): unable to set trace log level

* chore(utils): rename SupportedLogLevelsString

* refactor(teleport): change `seconds` default value

* fix(teleport): remove trailing line on profiles file

* chore(teleport): add profile examples

* refactor(service): use marshal/unmarshal log level functions

* fix(teleport): fix tarball file timestamps

* refactor: move debug service + constants to a separate package

* test(debug): move request to a helper

* chore(debug): remove leftover file

* chore(log): typo

* refactor: move package from lib/debug to lib/srv/debug

* refactor: code review suggestions

* fix(service): socket file consistency

* test(common): use one temporary directory per socket test

* chore(tool): update debug service connection error message

* refactor(debug): use enhanced serve mux

* chore(teleport): fix usage examples

* Apply suggestions from code review

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

* refactor: code review suggestions

* refactor(debug): move marshal/unmarshal text log level to debug

* refactor: code review suggestions

* refactor: move debug service client to lib/client/debug/

* refactor: code review changes

* feat(debug): progress on collect profiles

* refactor: code review suggestions

* chore(gomod): update

* fix(debug): set log level validations

* refactor(debug): move client interface

* feat(debug): add limit reader for collect profiles

* refactor(debug): remove progress bar

* Revert "chore(gomod): update"

This reverts commit 8dbebbf69f.

* refactor: remove debug service endpoints constants

* test(service): fix wrong constant

* refactor(debug): remove collect profiles limit reader

* chore(debug): make client struct public

* refactor(debug): change collect time to 0

* test(service): deflake test

* test(service): add missing auth config

* test(debug): fix missing assertion

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2024-05-07 19:41:55 +00:00
Jakub NyckowskiandTiago Silva bc53a8235c Add Crown Jewel resource (#40914)
* Update labels datatype in Teleport crownjewel proto

This commit modifies the labels from a map to repeated TeleportLabel in CrownJewel proto, and accordingly updates the getter function in proto generated code. The newly introduced TeleportLabel type contains a Key and repeated values for improved flexibility.

Clean up

Update and restructure CrownJewel service proto

The code modifications include renaming and restructuring several types and altering various functions in the CrownJewel service proto. Major changes involve renaming DeleteCrownJewel

Rename 'kind' to 'kinds' in crownjewel API

This commit changes the 'kind' field to 'kinds' in the crownjewel API to better reflect its purpose of holding multiple resource types. Changes are made across several files - 'crownjewel.go', 'crownjewel.pb.go' and 'crownjewel.proto'.

After rebase fixes

Remove CrownJewel type from several files

This commit represents the removal of the CrownJewel type from several files. CrownJewel type references are deleted in certain Go files, and imports of CrownJewel in multiple files are being adjusted. The specifics of why this type is removed is not evident from the diffs, but the deletions will affect the related functionalities.

Add CrownJewel update functionality

This update enables the 'UpdateCrownJewel' functionality. If a 'CrownJewel' resource already exists, it can now be updated instead of returning an error. This enhances flexibility when dealing with resource management. It also introduces the ARN field into the 'AWSMatcher' service.

Update CrownJewel service with pagination and improve matchers

This update adds pagination to the CrownJewel service for more efficient data handling. It also improves the matching capabilities with the inclusion of Teleport and AWS matchers and allows for selective querying with these matchers. Additionally, it includes various changes to structure and naming for better clarity and ease of use.

Refactor CrownJewel protos to use ResourceHeader

This refactoring replaces the previous structure of CrownJewel proto's fields Kind, Sub_kind, Version, and Metadata with a single object called Header (ResourceHeader). It simplifies the code structure and harmonizes it with other protos. Now, Header contains the essential attributes that were previously distributed across multiple separate fields.

Add GetCrownJewels method to cache and accessgraph

The function GetCrownJewels has been added to the cache and the accessgraph. It retrieves all CrownJewel instances from the cache. Additionally, CrownJewel retrieval functionality has been removed from auth server and existing usages have been refactored.

Implement Crown Jewel creation feature

Updated the method `createCrownJewel` in the resources command to handle Crown Jewel creation. Introduced a new gRPC service `crownjewelv1` to handle client-server interactions for Crown Jewel objects. Crown Jewel expiry configuration has now also been enabled.

Add missing files

I have no words...

Update authentication and event handling

Refactored the argument from 'auth.ClientI' to '*auth.Client' in 'createCrownJewel' function in 'resource_command.go'. Removed unused import 'durationpb' in 'auth_with_roles.go'. Added a new event code 'AccessGraphAccessPathChangedCode' in 'codes.go' and 'AccessGraphAccessPathChanged' in 'api.go' for better monitoring and logging of access path changes.

Add access path changed event and relevant changes.

 update api

add grpc

update api

add cache support

add protos

* Fixes after rebase

* Refactor Crown Jewel resource methods

Updated API methods related to the Crown Jewel resource to improve clarity and consistency. Renamed `GetCrownJewels` to `ListCrownJewels`, added pagination parameters, and ensured uniform handling of the Crown Jewel resource across different parts of the codebase. Updated relevant comments for better code understanding.

* Removed CrownJewel converter, updated CrownJewel references

This commit removes the CrownJewel converter and updates references from the old CrownJewel type to the new protobuf-defined CrownJewel type, streamlining the codebase. The commit also disables CrownJewel deletion since it is not supported yet. Some minor errors were fixed regarding CrownJewel resource names.

* Implement Crown Jewel deletion functionality

The crown jewel deletion feature has been enabled by uncommenting and simplifying the code block. Now, the delete action is directly performed on the specific 'crown jewel' mentioned based on its name. The previously unsupported action returns an informative success message after the deletion.

* Refactored function 'allCombinations' and added authorization checks

Moved 'allCombinations' function into 'utils' package, renamed it to 'Combinations', and updated its references in 'dbobjectimportrulev1' and 'dbobjectv1' tests. Additionally, introduced admin authorization checks to 'CreateCrownJewels', 'UpdateCrownJewels', and 'DeleteCrownJewels'. Created corresponding tests for these changes.

* Add CrownJewel service to cache tests

The CrownJewel service has been added to the cache test file. The service creation is implemented and assigned to new fields in multiple methods within the cache tests. A new test function `TestCrownJewel` has also been added to validate CRUD operations for the service.

* Add access path changed event and update Crown Jewel tests

Added a new event code for when an access path changes in the access graph, and introduced new API calls to handle these situations. Also, updated crown jewel related tests and fixed copyright year in several files.

* Update protobuf import path

The protobuf import path was updated from "github.com/golang/protobuf/proto" to "google.golang.org/protobuf/proto" to ensure correct use and to prevent potential issues, while maintaining functionality in crown_jewels.go.

* Refactor CrownJewel and AccessGraph services

This commit optimizes the ListCrownJewelsResponse in the CrownJewel service by directly assigning the response instead of using an extra loop. Additionally, the EventsStream in the AccessGraph service and related tests have been updated to EventsStreamV2, reflecting the implementation of new versions of these methods.

* Add CrownJewel resource in access controls and tests

In both the cache test and access control files, CrownJewel resource has been included. This provides the system's ability to manage and test CrownJewel resources. Additionally, it allows the handling of CrownJewel resources in client events.

* Simplify implementation

* Update copyright dates and add license headers

Updated the copyright dates in several files to reflect the new year. Additionally, license headers have been added to some files where they were previously missing, ensuring the proper copyrights and GPL notice are visible.

* Refactor CrownJewel codebase for better readability

Fixed various typographical errors in CrownJewel's related functions and removed a TODO comment. Improved function and function calls' names that were incorrectly referring to different modules, making the code easier to read and understand across different CrownJewel services.

* Add validation for Teleport and AWS matchers in service

The validation has been added for Teleport and AWS matchers in the service layer to ensure that essential details are not missed when setting matchers. This includes checks to ensure that kinds and labels for Teleport, and types and tags for AWS matchers are properly set.

* gci

* Add CrownJewel update functionality and refactor related services

This commit adds the ability to update a CrownJewel resource within the ResourceCommand. It also includes refactoring of related services, condensed code logic, and improved utilization of existing methods for marshaling/unmarshaling CrownJewel. Specific changes in service.go and crown_jewels.go files have reduced code redundancy and enhanced the code structure.

* Relocate and update crown_jewels_test file

This commit moves the crown_jewels_test from the local to the services library and adds test cases for unmarshalling Crown Jewels data. Also, import statements for labelv1 and utils were introduced to support these changes.

* Update crown jewels test with AWS matchers

Revised the crown jewels test file by including AWS matchers section in the CrownJewel object. The change ensures to specifically match AWS infrastructure following certain parameters, thus enhancing the specificity and flexibility of our matchers. Apart from this, minor reordering of objects has also been done for better code organization.

* Added upsertCrownJewel function and related proto message

The commit adds the UpsertCrownJewel function in the service.go file, which enables upsert operations on crown jewel resources. Alongside, the UpsertCrownJewelRequest proto message is added to the crownjewel_service.pb.go file to handle such requests.

* Refactor CrownJewelsClient to use upsert

This change refactors the CrownJewelsClient to use the upsert method when the force flag is on. The code has been streamlined by eliminating the need for 'already exist' error checking and separate create and update methods.

* Add GetCrownJewel functionality and refactor validation

A GetCrownJewel function has been added to the Service, which retrieves a specific CrownJewel resource. Also, the CrownJewel validation process has been refactored, moving the validateCrownJewel function from service.go into the crownjewel library and renaming it to ValidateCrownJewel. These changes improve modularity and code organization.

* Add VerbCreate check and test for CrownJewel validation

The checkAccessToKind function now also checks for the VerbCreate permission. Additionally, a new test file, object_test.go, was added to validate the functionality of the CrownJewel object. This includes various validation checks such as "NilCrownJewel", "ValidCrownJewel", "MissingMatchers", among others.

* Refactor CrownJewel resource handling and validation

The codebase was updated to improve CrownJewel resources handling. This includes modifications to list, get, create, update, upsert, and delete functions in several files. Additionally, a validation function has been implemented for CrownJewel objects, ensuring required fields are present. Depreciated logger service has also been removed.

* Add cache implementation to CrownJewel service

The CrownJewel service has been enhanced by integrating it with cache. The main changes include adding "Cache" as part of ServiceConfig and using cache to fetch crown jewels instead of directly using the backend services. The cache interface with the methods "ListCrownJewels" and "GetCrownJewel" has been added to handle these operations.

* Add Cache to service configuration in crownjewelv1 tests

In this commit, we added the Cache field to the service configuration used in the tests for the crownjewelv1 service. This ensures that the service configuration used in the tests matches the expected real-world configuration.

* Update CrownJewelsService to use ConditionalUpdateResource

This commit changes the CrownJewelsService's `UpdateCrownJewel` method to use the `ConditionalUpdateResource` method instead of the `UpdateResource` method. This change will provide a more appropriate update strategy for the specific needs of the CrownJewelsService.

* Replace 'Cache' with 'Reader' in crownjewel service & remove DeleteAllCrownJewelsRequest

The 'Cache' in crownjewel service has been replaced with 'Reader' to improve code readability and to match with its functionality. Also, the DeleteAllCrownJewelsRequest functionality was removed as it posed a high risk potential for data loss and it wasn

* Update tests for Crown Jewel service

This commit updates the test suite of the Crown Jewel service. An object is fetched from the backend before updating its expiry time, ensuring the revision is populated. In addition, a new test is introduced to handle the scenario where the revision is missing when updating a Crown Jewel.

* Refactor protobuf marshaling with utils

This commit replaces the usage of the `protojson` method for marshaling and unmarshaling protobuf objects in `crown_jewel.go` with the `FastMarshal` and `FastUnmarshal` methods from `utils`.
protojson is failing to unmarshal resources.

* Update CrownJewel test and serialization methods

Updated the test condition in crown_jewels_test.go to use Proto.Equal for object comparisons. Also, swapped out the FastMarshal and FastUnmarshal methods with protojson's Marshal and Unmarshal in the CrownJewels service.

* Add missing license

---------

Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>
2024-05-07 15:48:24 +00:00
6ce4fdd966 [vnet][1] setup TUN and IPv6 on MacOS (#40893)
* [vnet] setup TUN and IPv6 on MacOS

* edit error message

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>

* add comment on running vnet as root

* better context cancellation handling

* pass context to manager.Run

* remove unnecessary slog.With

* Apply suggestions from code review

Co-authored-by: Isaiah Becker-Mayer <isaiah@goteleport.com>

* rename notimplemented error

* return aggregate of all errors

* stop abusing os.CreateTemp

* reliably terminate on context cancellation

* fix lint

* terminate conn signal notifier goroutine when conn is already closed

* add comments

* fix typo in comment

* skip stats handler on windows

* remove stats handler

---------

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>
Co-authored-by: Isaiah Becker-Mayer <isaiah@goteleport.com>
2024-05-07 02:10:47 +00:00
Brian Joerger 8c328a880b MFA for App Access - tsh proxy app and Teleport Connect (#40857)
* Add key.DBTLSCert and key.AppTLSCert helper methods.

* Add TSH_APP_LOCAL_PROXY user certs requester option.

* Break up app login into multiple methods.

* Generalize cert checker local proxy middleware and add an app cert implementation.

* Use AppCertChecker for tsh proxy app.

* Add test check for proxy mfa certs being kept off disk.

* Apply changes to Teleport Connect.

* Addressed bl-nero's comments.

* Address comments from ravicious.

* Add proxy app cert ttl test.

* Restore v15 fallback for tsh proxy app session creation; Minor naming refactors.

* Add cluster flag to app logout.

* Refactor teleterm test to cleanup session MFA requirement.

* Address comments.
2024-05-06 19:29:53 +00:00
Brian Joerger ac4870cacd MFA for App Access - tsh app login (#40846)
* Generate MFA verified certs with tsh app login.

* Add TestAppCommands with per-session MFA tests.

* Add --cluster flag to tsh proxy app; Add tsh proxy app tests with per session MFA subtests.

* Clean up test cases.

* Fix unit tests.

* Disable session recording and use shorter poll_stream_period by default for tests.

* Resolve comments; Fix tsh app config --cluster=leaf.

* Resolve comment.

* Fix TestFormatAppConfig.
2024-05-02 20:20:44 +00:00
Michael 80f314a550 Add DisableIncludeRequestableRequests to UIConfig (#41064) 2024-05-02 16:53:13 +00:00
Marco André Dinis dcb5e435b5 API for creating AppServer that uses AWS OIDC Integration (#40581)
* API for creating AppServer that uses AWS OIDC Integration

This PR adds two new APIs:
- web api endpoint
- `tctl create` for AppServers

This allows the client to create AppServer which use the integration
credentials.

This also updates the `editor` role so that they are able to upsert the
AppServer.

* return ui.App after creation

* improve comment
2024-05-02 15:28:16 +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
rosstimothy 3c0e27b4f8 Update proxy templates to support resource filtering (#40918)
Historically proxy templates have only supported an exact hostname
match via the `Host` field defined. This limits some of the benefits
of using proxy templates and forces users to do a bunch of extra
work in their ssh config. For example, if a user today wanted to
leverage proxy templates to connect to a host via a label, predicate
expression, or fuzzy match, they would be required to use tsh ls,
find the matching UUID or hostname and provide that to tsh for
evaluation with the template expression.

SSH Config:
```
Match Host *.example.com
    ProxyCommand tsh proxy ssh  %r@$(tsh ls --search=$(echo %h | cut -d. -f1) -f json | jq -r '.[0].metadata.name'):%p
```

The above requires multiple subshells, a connection to the Auth
server, and jq to be installed on the client machine in order to
work.

To reduce the amount of effort required to connect to a resource
proxy templates have been updated with a `Search` and a `Query`
field to support fuzzy search and predicate expressions much like
`tsh ls --search` and `tsh ls --query`. The order of operations
for matching the target host is: 1) Host, 2) Predicate Expression,
3) Query.

In addition to the proxy template changes, tsh proxy ssh
has also been updated to allow resolving the target via
searching or querying -- though ONLY via proxy templates.
There are no additional `--query` or `--search` flags added
to tsh proxy ssh for the time being. This is mostly for CLI UX
reasons since neither tsh ssh or tsh proxy ssh support those
flags today, and only allow filtering by label via supplying
key value pairs in the hostname  (tsh ssh alice@foo=bar,env=dev).

tsh proxy ssh is however still limited to connecting to a single
host at a time. If there are no matches, or multiple matches found
as a result of target resolution, then an error is returned.

With the new functionality, the above example can be simplified to
the following.

SSH Config:
```
Match Host *.example.com
    ProxyCommand tsh proxy ssh  %r@%h
```

Proxy Template:
```
- template: '^(.*).example.com:\d+$'
  search: "$1"
```

This shifts the resposibility of host resolution from the caller
to tsh. It allows resolution to happen in the same process that
will initiate the connection, reducing a dial to the cluster, and
eliminating the need for any subshells, or extra tools outside
of tsh to be present.
2024-04-26 19:44:47 +00:00
Brian Joerger ce242ae40d Support agentless connections with hardware key support (#39267) 2024-04-25 22:45:00 +00:00
Brian Joerger 12c7689df5 Refactor GenerateUserCerts to create App Sessions (#39970)
* Add CreateAppSessionFromReq.

* Deprecate passing route_to_app.session_id in cert requests.

* Automatically create app sessions for app cert requests.

* Deprecate client use of CreateAppSession for app cert requests.

* Fix affected tests.

* Use traits and roles from existing user certificate for app sessions.

* Fix app access integration tests.

* go mod tidy.

* Fix TestTCP.

* Fix TestALPNSNIProxyAppAccess.

* Revert "go mod tidy."

This reverts commit cc6caa2485.
2024-04-25 05:13:55 +00:00
Zac Bergquist 8cd1c429f5 Fix up some poor wording (#40832)
Closes #40294
Closes #39172
2024-04-23 22:01:41 +00:00
Marco André Dinis 932be62d12 Move teleport integration configure commands to their own file (#40634)
* Move teleport integration configure commands to their own file

* remove pointers for requests
2024-04-23 14:56:47 +00:00
STeve (Xin) Huang 26bdf3d0b7 Fix an issue tsh db ls shows one entry per db server instead of db name (#40784) 2024-04-22 20:21:40 +00:00
Noah Stride 8f391fe781 Switch tbot to use slog.Logger from logrus (#40606)
* Switch `tbot` to use `slog.Logger` from logrus

* Pick up a few spots I forgot to convert

* Fix tctl logging

* Avoid using Context-less variants of logger

* Convert logpoints in tool/tbot to use context based loggers

* Fix use of multiline string

* Move tbot log initialization before first logging message

* Switch "err" to "error" in log attributes

* Use `NewPackageLogger`
2024-04-22 12:47:58 +00:00
Marco André Dinis dc5975ea37 AWS OIDC: IAM set up for AWS App Access (#40575)
* AWS OIDC: IAM set up for AWS App Access

AWS App Access using AWS OIDC Integration requires a new policy in the
AWS OIDC Role.
This PR adds a one-off script that executes the configuration command
that adds said policy.

* improved comments, remove dead code, improve logging

* improve comment and http client var name

* move back to interface

* remove default client

* rename role to rolename

* enable fips endpoint support

* restrict target roles by their tags

* use true for tag value
2024-04-19 14:56:44 +00:00
rosstimothy d181a7ddeb Cleanup tctl subcommands (#40663)
tctl enterprise is no longer a thing so the split of OSS commands
that get overwritten by ent can be removed.
2024-04-18 22:23:56 +00:00
9062d62aff Add access monitoring rules cache and tctl interactions (#40218)
* Add access monitoring rules cache and tctl interactions

* Swap access monitoring rules collections to use upsert

* Update accessmonitoringrules cache test

* Readd missing err check

* Update lib/auth/grpcserver.go

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

* Update lib/auth/grpcserver.go

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

* Update tool/tctl/common/resource_command.go

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

* Add tctl isForced behaviour for access monitoring rules

* Add missing methods to cache interface for access monitoring rules

* Add info messages to tctl commands for accessmonitoring rule edits

* Add missing user message for forced rule creation

* Appease linter

---------

Co-authored-by: Marco André Dinis <marco.dinis@goteleport.com>
Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2024-04-17 13:05:01 +00:00
Noah Stride 764d9b1a0a Add teleport tpm identify and tbot tpm identify commands (#40418)
* Add func for tbot tpm identify command

* Add `tbot tpm identify` command

* Move helper to `tpm` package and add tests

* Add tpm identify command to `teleport`
2024-04-15 11:55:55 +00:00
rosstimothy 5a64d1fb8d Convert tsh recursive listing to connect to Proxy via gRPC (#40268)
* Convert recursive listing to use Proxy gRPC API

Removes deprecated usage of ProxyClient in getClusterClients used
for tsh ls -R and tsh db ls -R.

* Remove unsued helper functions

* Replace removed test

* Remove unused db listing function

* convert tsh apps ls -R and tsh kube ls -R

* remove unused function and tweak IsExpired

* create common testcase for listing resources
2024-04-12 20:19:11 +00:00
Tiago Silva 58d48436dc Add ability to re-exec into shell when using tsh proxy kube. (#40246)
* Add ability to re-exec into shell when using `tsh proxy kube`.

This PR introduces the `tsh proxy kube --exec` mode which spawns the
kube proxy in the background and re-execs the user shell with the
configured kubeconfig file.

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

* rename

* fix printed message

---------

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
2024-04-10 11:09:36 +00:00
Bartosz Leper 06fce3f449 Keep track of whether the user has a real password set (#39576)
* Keep track of whether the user has a real password set

* lint

* Some comments

* Fix TestCreateResources

* Fix e/ link

* Review

* Review

* Review

* Use early return on error in DeletePassword

* Fix the broken teleterm test
2024-04-10 10:28:05 +00:00
Jakub Nyckowski b234bfeffc Pin now time during the access request creation (#40325)
* Remove clockwork dependency and handle time internally

The `clockwork` package was removed and handling of time elements has been refactored in codebase. The current time was set once and then passed as an argument to the functions that need it, reducing calls to retrieve the current time. This change simplifies the code and makes it more robust against time drifts.

* Build fix

* Remove usage of fake clock in tests

Removed the use of fake clock in tsh_test.go and kube_test.go to imitate real-world behavior more accurately. This change is aimed at improving the credibility and reliability of those test cases.

* Refine grammar and punctuation in comments.

This commit updates the comments in `access_request.go` and `access_request_test.go` files to improve grammar and punctuation for better readability and understanding of the code. This includes correction of typographical errors, addition of punctuation where necessary, and clarification of some comments for more precise descriptions.

* Update TTL validation error messages

The code changes refine messages for validation errors related to TTL. The error messages returned when requested TTLs exceed the maximum allowed amounts are improved. Time is no longer rounded to minutes, providing more precise error messages.
2024-04-08 19:01:03 +00:00
Noah Stride 7825c652d9 Disable session recording/audit to prevent tempdir flakiness in tbot tests (#40253)
* Disable session recording/audit to prevent tempdir flakiness

* Fix another test I broke by fixing a different test
2024-04-08 09:24:57 +00:00
Andrew Burke d0a68fd824 Add automatic role access requests (#39003)
* Add automatic role requests

This change adds the optioin to automatically make a role access request
during tsh ssh instead of a resource access request.

* Speed up TestSSHAccessRequest
2024-04-05 19:40:35 +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
Krzysztof Skrzętnicki 0f5f6124c5 Change the tctl format for database_object_import_rule resource (#39764)
* Fix incorrect expiry when using resource153ToLegacyAdapter

* Change the `tctl` format for database_object_import_rule resource.

Prior to this change the resource wouldn't round-trip through `tctl get ... | tctl create` because of header incompatibilities.

In general, all resources must be compatible with services.UnknownResource for their `tctl` storage format.

* Lint fix
2024-04-04 11:10:40 +00:00
rosstimothy 55c5cbab2b Add equivalent of (ProxyClient) IssueUserCertsWithMFA to ClusterClient (#40081)
Updates the ClusterClient to support issuing user certificates,
possibly with MFA, for all protocols. This should be the last
bit of functionality required to allow Connect to convert to
using the ClusterClient. Once that is done the deprecated
ProxyClient should be one step closer to deletion.

Updates #38239
2024-04-03 14:15:52 +00:00
Krzysztof SkrzętnickiandAnton Miniailo 24021556c4 Implement persistence for database_object resource (#39756)
* Implement persistence for database_object resource

* Split monolithic service test

* Add `t.Parallel()` to the tests

* lint fix

* Update copyright year

Co-authored-by: Anton Miniailo <anton@goteleport.com>

* `make grpc`

---------

Co-authored-by: Anton Miniailo <anton@goteleport.com>
2024-04-03 08:28:11 +00:00
Michael Wilson 49c540caf1 Introduce plugins cleanup command line function. (#40035)
* Introduce plugins cleanup command line function.

tctl can now explicitly issue a plugins cleanup command, which will allow
admins to remove any extra artifacts that a plugin may have left behind
after being deleted.

* Add in a dry run command, list resources.

* GCI.

* Code cleanup, use ResourceID instead of string.

* Only allow okta cleanup, default to dry-run on.
2024-04-01 18:00:08 +00:00
Brian Joerger 4690eeab10 Keep App Session secrets secret (#39853)
* Don't reveal app session secrets to users.

* Fix panic in WebSessionV2.WithoutSecrets.

* Use client's key for azure jwt tokens

Proxy verifies and signs jwt tokens

Ensure backwards compatibility

* Remove unused GetAppSession methods.

* Move azure jwt token resigning logic into the session transport's
rewriteRequest method with an improved Azure app check

Fix GetAppSession backward compatibility check

* Add test.

* Address lint comments.

* Address parseBearerToken comment.

* apply suggestion about indentation.
2024-03-29 23:31:31 +00:00
rosstimothy 1916027587 Migrate logging via cfg.Log to cfg.Logger (#39980)
Converts logging via the servicecfg.Config to use slog instead of
logrus.
2024-03-29 13:16:07 +00:00
Noah Stride 56ac818561 Add tls-spiffe support to tctl auth export and /webapi/auth/export (#39879) 2024-03-29 09:46:49 +00:00
Zac Bergquist ec28ab5441 keygen: removed unused context (#39922)
* keygen: removed unused context

* Remove keygen.Close
2024-03-28 22:53:01 +00:00
rosstimothy bf19d11755 Add tctl sso configure and tctl sso test support for OIDC and SAML (#39899)
* Add tctl sso configure and tctl sso test support for OIDC and SAML

Migrates the tctl sso configure and tctl sso test commands for
SAML and OIDC connectors from tctl enterprise to OSS. This will
allow the enterprise tctl binary to be removed.

* Guard CreateOIDCAuthRequest and CreateSAMLAuthRequest

Prevent the RPCs from being called in the open source version of
teleport. Now that the tctl sso test commands are in OSS we want
to ensure that the commands will only function if communicating
with an enterprise Auth server.

* fix: license

* update e ref
2024-03-28 18:11:05 +00:00
Sakshyam Shah b71b02b07b feat: adds samlidp gcp-workforce command to teleport cli (#39820)
* configure GCP workforce api client

* add 'integration configure samlidp gcp-workforce' command to teleport ctl

* update api to fetch metadata file from remote Teleport prox.
- minor comment copy and log copy edits

* gcp resource name validation, checkandsetdefault funcs

* use gcp-workforce subcommand path, rename gcpworkforce config as APIParams

* return early on pending provider status

* update comments and godoc

* use slog

* apply review suggestions:
- use 2*minute instead of 120*seconds
- use default http client and add redirect to the client
- NewGCPWorkforceService test

* update logger to use InfoContext. improve wait message, run fix-imports

* update ticker to 5 second from 1 second

* use underscore in log field instead of space. add missing trace.Wrap in waitForPoolStatus

* update NewGCPWorkforceService comment

* review suggestions:
- increase wait timer to 5 mins
- iamv1 migration comment
- move http redirect checker to checkAndSet default

* check for 409 response so that pool provider create op can continue if we timedout after creating pool

* fix package import comment style to make linter happy

* move default http client to gcpworkforce service checkandset defaults. update tests to relax on httpclient input param
2024-03-27 21:16:39 +00:00
rosstimothy 10da1b3b9e Display available allowed logins for leaf resources in root web ui (#39579)
The Proxy web api now requests that Auth include allowed logins
per resource instead of guessing logins per resource based on the
information it has cached. However, due to the way SSH sessions
are authorized, the logins are not provide to users verbatim.

Any sessions created via the root web ui to a leaf resource will use
the SSH certificate created for that user in the root cluster. New
certificates are not minted per leaf cluster. This is important
because the nodes only allow os logins for a session if they are
present in the valid prinicpals of the SSH certificate. So even
though we are now capabale of displaying all allowed logins for
leaf SSH servers in the root web ui, the user is only able to use
a subset of them. To avoid any odd UX, the Proxy will filter out
any allowed logins which do not exist in the principals of the
root SSH certificate.

The above only holds for SSH, windows desktops are not as strict
and any allowed login from a leaf cluster is now visible in the
root web ui.

Fixes https://github.com/gravitational/teleport/issues/5041
2024-03-25 16:34:51 +00:00