Commit Graph
54 Commits
Author SHA1 Message Date
Tiago Silva 674a3a1ec1 Removes deprecated KindKubeService objects (#22663)
This PR removes the `types.KindKubeService` objects that were
deprecated in Teleport 11.

Teleport 12 removed the double heartbeat and for Teleport 13 we can
safely drop the support of the old hearbeat based on `types.Server`
objects.

Clients older than Teleport 12 connecting to a Teleport 13 server will
fail since they cannot heartbeat using the old mechanism.
2023-03-13 10:55:39 +00:00
Nic Klaassen d77fb5bee4 fix: improve tsh logs when skipping auto Access Request (#22048)
Currently the `tsh` debug log is polluted with "errors" created by the
[automatic access request feature](https://goteleport.com/docs/access-controls/access-requests/resource-requests/?scope=enterprise#automatically-request-access-for-ssh)
even in completely expected scenarios, e.g. when the user has no
permission to create Resource Access Requests.

Before this change:
```
$ tsh ssh -d alice@one-auth
...<omitted>...
2023-02-17T15:30:16-08:00 DEBU [TSH]       unable to request access to node error:[
ERROR REPORT:
Original Error: *trace.BadParameterError user attempted a resource request but does not have any &#34;search_as_roles&#34;
Stack Trace:
        github.com/gravitational/teleport/api@v0.0.0/client/client.go:880 github.com/gravitational/teleport/api/client.(*Client).CreateAccessRequest
        github.com/gravitational/teleport/tool/tsh/tsh.go:2896 main.accessRequestForSSH.func1
        github.com/gravitational/teleport/lib/client/api.go:1351 github.com/gravitational/teleport/lib/client.(*TeleportClient).WithRootClusterClient
        github.com/gravitational/teleport/tool/tsh/tsh.go:2895 main.accessRequestForSSH
        github.com/gravitational/teleport/tool/tsh/tsh.go:2916 main.retryWithAccessRequest
        github.com/gravitational/teleport/tool/tsh/tsh.go:2993 main.onSSH
        github.com/gravitational/teleport/tool/tsh/tsh.go:1086 main.Run
        github.com/gravitational/teleport/tool/tsh/tsh.go:482 main.main
        runtime/proc.go:250 runtime.main
        runtime/asm_amd64.s:1598 runtime.goexit
User Message: user attempted a resource request but does not have any &#34;search_as_roles&#34;] tsh/tsh.go:2920

ERROR REPORT:
Original Error: *trace.AccessDeniedError access denied to alice connecting to one-auth:0@default@cluster-one
Stack Trace:
        github.com/gravitational/teleport/lib/client/client.go:1633 github.com/gravitational/teleport/lib/client.NewNodeClient
        github.com/gravitational/teleport/lib/client/client.go:1563 github.com/gravitational/teleport/lib/client.(*ProxyClient).ConnectToNode
        github.com/gravitational/teleport/lib/client/api.go:1451 github.com/gravitational/teleport/lib/client.(*TeleportClient).ConnectToNode
        github.com/gravitational/teleport/lib/client/api.go:1525 github.com/gravitational/teleport/lib/client.(*TeleportClient).runShellOrCommandOnSingleNode
        github.com/gravitational/teleport/lib/client/api.go:1408 github.com/gravitational/teleport/lib/client.(*TeleportClient).SSH
        github.com/gravitational/teleport/tool/tsh/tsh.go:2995 main.onSSH.func1.1
        github.com/gravitational/teleport/lib/client/api.go:504 github.com/gravitational/teleport/lib/client.RetryWithRelogin
        github.com/gravitational/teleport/tool/tsh/tsh.go:2994 main.onSSH.func1
        github.com/gravitational/teleport/tool/tsh/tsh.go:2907 main.retryWithAccessRequest
        github.com/gravitational/teleport/tool/tsh/tsh.go:2993 main.onSSH
        github.com/gravitational/teleport/tool/tsh/tsh.go:1086 main.Run
        github.com/gravitational/teleport/tool/tsh/tsh.go:482 main.main
        runtime/proc.go:250 runtime.main
        runtime/asm_amd64.s:1598 runtime.goexit
User Message: access denied to alice connecting to one-auth:0@default@cluster-one
```

After:
```
$ tsh ssh -d alice@one-auth
...<omitted>...
2023-02-17T16:42:29-08:00 DEBU [TSH]       Not attempting to automatically request access, reason: Resource Access Requests require usable "search_as_roles", none found for user "nklaassen" tsh/tsh.go:2922

ERROR REPORT:
Original Error: *trace.AccessDeniedError access denied to alice connecting to one-auth:0@default@cluster-one
Stack Trace:
        github.com/gravitational/teleport/lib/client/client.go:1633 github.com/gravitational/teleport/lib/client.NewNodeClient
        github.com/gravitational/teleport/lib/client/client.go:1563 github.com/gravitational/teleport/lib/client.(*ProxyClient).ConnectToNode
        github.com/gravitational/teleport/lib/client/api.go:1451 github.com/gravitational/teleport/lib/client.(*TeleportClient).ConnectToNode
        github.com/gravitational/teleport/lib/client/api.go:1525 github.com/gravitational/teleport/lib/client.(*TeleportClient).runShellOrCommandOnSingleNode
        github.com/gravitational/teleport/lib/client/api.go:1408 github.com/gravitational/teleport/lib/client.(*TeleportClient).SSH
        github.com/gravitational/teleport/tool/tsh/tsh.go:2997 main.onSSH.func1.1
        github.com/gravitational/teleport/lib/client/api.go:504 github.com/gravitational/teleport/lib/client.RetryWithRelogin
        github.com/gravitational/teleport/tool/tsh/tsh.go:2996 main.onSSH.func1
        github.com/gravitational/teleport/tool/tsh/tsh.go:2907 main.retryWithAccessRequest
        github.com/gravitational/teleport/tool/tsh/tsh.go:2995 main.onSSH
        github.com/gravitational/teleport/tool/tsh/tsh.go:1086 main.Run
        github.com/gravitational/teleport/tool/tsh/tsh.go:482 main.main
        runtime/proc.go:250 runtime.main
        runtime/asm_amd64.s:1598 runtime.goexit
User Message: access denied to alice connecting to one-auth:0@default@cluster-one
```
2023-02-21 17:36:02 +00:00
Edward Dowling 9ac550af2d Reject access requests with invalid cluster names (#20472) 2023-01-25 12:31:46 +00:00
Alan Parra 11d58e25c7 Refactor AccessMFAParams and MFAParams to allow additional data (#20300)
Refactor `services.AccessMFAParams` and the accompanying `MFAParams` methods so
they may be extended to carry additional data (eg, information required to
perform device trust checks).

This PR refactors existing code without adding any new functionality, so it may
be backported to older branches to alleviate eventual conflicts. Follow up
changes will take advantage of it to add support for device trust.

Related to gravitational/teleport.e#514.
2023-01-17 20:02:38 +00:00
Tiago Silva 071e36acf1 tsh, tctl support for creating Pod access requests (#20272)
This PR introduces support for creating resource access requests to `pod` resources to `tsh` and their approval from `tsh` and `tctl`. 

Adds support `tsh request create --resource /<cluster>/pod/<kube_cluster>/<namespace>/<podname>`.

Part of #18434
2023-01-17 17:12:31 +00:00
Michael Wilson 6fa75978e4 Add an access request watcher. (#19626)
An accesss request watcher has been added to support access requests that
will require downstream reconciliation based on access request approval. This
will be useful for requests that trigger external APIs in other Teleport
services once they've been approved. This will be useful for the upcoming
Okta integration work.
2023-01-03 14:23:54 +00:00
Michael 1b5bd9824d [Connect] Add server hostnames in access request responses (#19258) 2022-12-20 14:33:47 -06:00
Russell Jones 7895fddc57 Added the ability to supply Access Request TTLs
Added the ability to specify two CLI flags for Access Requests:
"--request-ttl" and "--session-ttl".

Updated "CreateAccessRequest" to adhere to the following rules.

If an Access Request does not have a TTL set (expiration time
types.AccessRequest resource itself), a default of 1 hour is used. Next,
the request value is truncated by the lifetime of the certificate,
requested expiration, and then strictest session TTL on all roles
requested.

Similar logic is followed for the expiration time of the elevated
certificate that will be issued if the Access Request is approved. First
the requested value is truncated by the lifetime of the certificate,
requested expiration, and then strictest session TTL on all roles
requested.

The output of "tsh requests ls" and "tctl requests ls" has been updated
to display the TTL values.
2022-12-14 15:18:33 -08:00
Zac Bergquist da7680ad0b Use x/exp/slices instead of home grown utilities (#18524)
We were inconsistent throughout the codebase and would sometimes
use the slices package and other times use our own equivalents
in api/.

This removes our versions in favor of the golang.org/x package that
does the same, which has the added benefit of reducing the surface
area of the public API module.

Note: despite existing uses of the slices package, for some reason
it didn't show up in go.mod or go.sum. Fixed that too.
2022-11-17 15:25:46 +00:00
Yassine Bounekhla 44c19d0665 Allow for specifying roles when making Resource Access Requests in the UI (#18036) 2022-11-16 23:11:10 +00:00
Jakub Nyckowski 0ee91f6c37 Enable GCI linter (#17894) 2022-10-28 20:20:28 +00:00
Nic Klaassen 23bf2e18c3 feat: add preview_as_roles for access request reviewers (#17357) 2022-10-19 18:45:51 +00:00
Lisa Kim bc81db4655 Use field hostname for node resource for predicate expr using "name" identifier (#16902)
* Predicate expressions using the "name" identifier will now use
  field "hostname" when `ls` querying for nodes, as expected by
  the user
* Change predicate expression for access request that use
  name identifier to using the actual json field names
2022-10-04 00:20:04 +00:00
Nic Klaassen a35848d9ce feat: include hostnames of requested servers in access request API outputs (#16483)
* add WithCluserClientProvider

* export GetResourcesByResourceIDs
2022-09-23 21:29:08 +00:00
Alan Parra a75fcc21d8 Update golangci-lint to 1.49.0 (#16507)
Update metalinter, fix a few lint warnings and replace deprecated linters.

`deadcode`, `structcheck` and `varcheck` are abandoned and now replaced by [`unused`][1].

Since 1.19, `go fmt` reformats godocs according to https://go.dev/doc/comment. I've done a bulk-reformatting of the codebase to keep the linter happy. Backporting is mostly harmless (the exception being `lib/services/role_test.go`, that for some reason breaks the _old_ linter using the new format).

[1]: https://golangci-lint.run/usage/linters/

* Bump golangci-lint version
* Replace abandoned linters
* Fix bodyclose on lib/auth/github.com
* Fix bodyclose on lib/kube/proxy/streamproto/proto_test.go
* Fix bodyclose on lib/srv/alpnproxy/proxy_test.go
* Fix bodyclose on lib/web/conn_upgrade_test.go
* Silence staticcheck on lib/kube/proxy/forwarder_test.go
* Silence staticcheck on lib/utils/certs_test.go
* Address BuildNameToCertificate deprecation warnings
* Run `go fmt ./...`
* Run `go fmt ./...` on api/
* Ignore formatting in role_test.go
* Remove redundant initializers in lib/srv/uacc/
* Update e/
2022-09-19 22:38:59 +00:00
Tiago Silva 037daad083 Introduce dedicated server type for Kubernetes resources (#14389)
## What

First part of the Kubernetes [Discovery RFD](https://github.com/gravitational/teleport/pull/13376/) to introduce a Kubernetes server per cluster. 

This PR introduces a separate Kubernetes server that uses the already introduced `KubernetesClusterV3`. 

## Compatibility

In previous versions, Kubernetes Clusters were part of regular `ServerV2` resource and this refactoring deprecates the `ServerV2` usage but keeps them for compatibility with previous version.

Everything is backward compatible, so v10 kubernetes agents and trusted clusters can connect fine.

## Next steps

Once this is merged, a new PR will introduce dynamic registration for Kubernetes Clusters discovered through EKS Discovery.
2022-08-04 14:21:11 +00:00
Nic Klaassen ce29a0c244 Fix Resource Request approvals (#14434) 2022-07-13 20:32:07 +00:00
Nic Klaassen 9ca9082cb0 Fix resource access requests for apps (#13955) 2022-06-30 20:42:09 +00:00
Nic Klaassen f4eb28223e Check if resource request is possible before attempting (#13586) 2022-06-17 16:57:44 +00:00
Michael a152441f64 ensure created timestamp for reviews (#13395)
* added created to tsh/tcl review_request and reason to the tctl portion

* setting review created time during database apply

* fixed formatting
2022-06-13 18:27:16 -05:00
Nic Klaassen 27a1f1c3d6 Prune roles for Resource Access Requests (#13323) 2022-06-10 16:50:55 +00:00
2717c1d2e0 Security fixes (#13298)
* Add CSRF mitigations

This commit includes two fixes:

1. Enforce an application/json Content-Type server-side.
2. When checking the bearer token, verify that the user
   associated with the token matches the user associated
   with the cookie.

* Fix TEL-Q122-13: Access Requests Denial Of Service Via Request Reason (#125) (#127)

* Ignore input when data flow is off in TermManager

When data flow is disabled in TermManager (at the beginning or when TermManager.Off was called) we should ignore all input we receive (currently we buffer it)

* Agent forwarding socket security fix.

Co-authored-by: Lisa Kim <lisa@goteleport.com>
Co-authored-by: Joel <jwejdenstal@icloud.com>
Co-authored-by: Przemko Robakowski <przemko@przemko-robakowski.pl>
2022-06-08 18:12:45 +00:00
Nic Klaassen 814664ab66 [Search-based access requests] Enforce resource access restrictions (#12651) 2022-06-03 00:04:44 +00:00
Nic Klaassen b55320f806 [Search-based access requests] Include allowed resource IDs in user certs (#12494) 2022-05-27 16:23:18 +00:00
Nic Klaassen c379b174f0 Scope requested resource IDs by cluster and resource kind (#12490) 2022-05-12 00:18:50 +00:00
Nic Klaassen 176d01ca3e Support creation of search-based access requests (#12307) 2022-05-02 17:41:10 +00:00
JoelandZac Bergquist 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
Brian Joerger 2c8342c9de Remove RoleConditions type alias from lib/services. (#8441) 2021-10-05 14:04:18 -07:00
Brian Joerger 9b8b9d6d0c rollback - Upgrade api version. (#7751) 2021-07-30 15:34:19 -07:00
Brian Joerger c040aca4c1 Upgrade api version. (#7609) 2021-07-28 13:51:21 -07:00
Brian Joerger bd07d7be20 CheckAndSetDefaults sets all defaults. (#6846) 2021-06-18 12:57:29 -07:00
Brian Joerger 4d36870ff0 Remove remaining API aliases (#7137) 2021-06-08 12:08:55 -07:00
Brian Joerger 7bff7c41bd Remove API aliases (#6983) 2021-06-04 13:29:31 -07:00
jane quin 5c78f1f756 Improve Access Request Events (#6863) 2021-06-03 14:28:38 -07:00
Andrew Lytvynov cd2f4fceb7 Remove JSON schema validation (#6685)
* Remove JSON schema validation

Removing JSON schema validation from all resource unmarshalers.

--- what JSON schema gets us

Looking at the JSON schema spec and our usage, here are the supposed benefits:
- type validation - make sure incoming data uses the right types for the right fields
- required fields - make sure that mandatory fields are set
- defaulting - set defaults for fields
- documentation - schema definition for our API objects

Note that it does _not_ do:
- fail on unknown fields in data
- fail on a required field with an empty value

--- what replaces it

Based on the above, it may seem like JSON schema provides value.
But it's not the case, let's break it down one by one:
- type validation - unmarshaling JSON into a typed Go struct does this
- required fields - only checks that the field was provided, doesn't actually check that a value is set (e.g. `"name": ""` will pass the `required` check)
  - so it's pretty useless for any real validation
  - and we already have a separate place for proper validation - `CheckAndSetDefaults` methods
- defaulting - done in `CheckAndSetDefaults` methods
  - `Version` is the only annoying field, had to add it in a bunch of objects
- documentation - protobuf definitions are the source of truth for our API schema

--- the benefits

- performance - schema validation does a few rounds of `json.Marshal/Unmarshal` in addition to actual validation; now we simply skip all that
- maintenance - no need to keep protobuf and JSON schema definitions in sync anymore
- creating new API objects - one error-prone step removed
- (future) fewer dependencies - we can _almost_ remove the Go libraries for schema validation (one transient dependency keeping them around)

* Remove services.SkipValidation

No more JSON schema validation so this option is a noop.
2021-06-01 15:27:20 -07:00
Andrew Lytvynov ac9ba539ce Use cmp.Equal instead of manual Equals methods (#5828)
* Use cmp.Equal instead of manual Equals methods

Equals methods can get out-of-sync with the fields added in structs they
compare. Using `cmp.Equal` handles that, removes a ton of code and makes
it more explicit when specific fields are excluded from comparison.

* Use gogoproto equal plugin for comparing proto values

This will be faster than reflect-based go-cmp.
2021-05-06 11:47:31 -07:00
Roman Tkachenko db6fb57dae Add app access headers rewrite (#6601) 2021-05-06 11:24:49 -07:00
Brian Joerger 06d252ffca gRPC conversions - OIDCConnector (#6067) 2021-03-26 15:52:16 -07:00
Brian Joerger 31ee2a4c04 Move usage of predicate package out of api. (#6136) 2021-03-24 18:48:07 -07:00
Forrest Marshall 59d2379b94 custom approval conditions 2021-03-24 14:33:40 -07:00
Brian Joerger 6f7333244d Add version header check in Marshalers (#5768) 2021-03-11 10:48:38 -08:00
Brian Joerger 494782fe12 Convert Role endpoints to gRPC. (#5458) 2021-03-10 17:54:08 -08:00
Brian Joerger ce6e08c438 api dependency reduction - uuid (#5386)
Move uuid generation for access requests to /lib/services.
2021-02-01 11:12:49 -08:00
Brian Joerger ce87251ea0 api dependency reduction - marshalers (#5384)
Refactor Marshal logic on types, and move it into /lib/services to reduce dependencies in /api.
2021-02-01 10:26:50 -08:00
Brian Joerger 76b6b6d84d Refactor lib/utils/parse dependency in api package. (#5261) 2021-01-19 11:32:07 -08:00
Brian Joerger 3c3ce160d9 Move API types and functionality from lib/services to api/types. (#5143) 2021-01-11 10:02:34 -08:00
Forrest Marshall f5c62fcc20 add dynamic access oracle 2020-12-31 09:57:05 -08:00
Forrest Marshall af05ce3eeb extended dynamic access API
Various improvements related to extending the dynamic access
API, including:

- Support for users with no statically defined roles.

- Unify trait mapping logic (e.g. claims_to_roles) across
the connector types.

- Support for matcher syntax and claims_to_roles mappings when
configuring which roles a user is able to request.

- Allow tsh or the web UI to automatically generate wildcard
access requests when dictated by role configuration.

- Allow RBAC configuration to attach annotations to pending
access requests which can be consumed by plugins.

- Allow plugins to attach annotations to approvals/denials
which appear in the audit log, and may also be looked up
later to determine additional info about a resolution.

- Support prompts, request reasons, and approval/denial
reasons for access requests.
2020-11-05 12:18:26 -08:00
Andrew Lytvynov 1d9e01bb80 errcheck: add missing error checks in lib/service* 2020-06-01 17:00:07 +00:00
Andrew Lytvynov 44cfbd4b6d Fix common misspellings detected by misspell linter 2020-05-11 16:44:27 +00:00