Commit Graph
122 Commits
Author SHA1 Message Date
Christopher CooperandNic Klaassen b3800ca500 Ccooper/add proxy ls auth ls 12965 (#14701)
* check if proxy requested already has an active profile that is not expired before relogging the user in

maintain cert reissue

use site name

make client for currently logged in proxy

simplify if

remove cert reissue

simplify and add test

revert comment

explicitly save profile

add initial commands

add better output

* review comments

* Update tool/tctl/common/proxy_command.go

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

* Update tool/tctl/common/proxy_command.go

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

* remove stdout redirect for now

* lint

Co-authored-by: Nic Klaassen <nic@goteleport.com>
2022-10-03 19:01:37 -04:00
Forrest Marshall 50762d7593 rework cmd registration 2022-09-09 11:13:41 -07:00
Forrest Marshall c33c53a2d9 cluster alerts 2022-08-19 13:14:04 -07:00
Edward Dowling be1438aecd tsh: tctl: Add basic recordings ls functionality (#12763) 2022-08-09 11:22:14 +00:00
Zac Bergquist 61463166c1 Remove tctl roletester (#13863)
This code was unmaintained, created issues with our build system,
and didn't actually match the behavior of Teleport's RBAC engine.

We will revisit this functionality in the future when we investigate
"acess policies as code."
2022-06-25 04:01:21 +00:00
Forrest Marshall 31f258fec9 inventory control stream & certs 2022-06-15 22:26:24 -07:00
Krzysztof Skrzętnicki 9377f7c681 New commands: tctl sso test, tctl sso configure for GitHub (#12783)
* Implement `tctl sso` commands for GitHub auth.

* Mark RFDs as implemented.
2022-05-26 23:26:35 +00:00
Andrew LeFevre 40b9b524f2 add --format flag to 'token add' and make the same flag visible for 'token ls' (#12327) 2022-05-09 21:28:15 +00:00
Tim Buckley b70c1d6d63 Add a note to tctl/main.go about updating tctl Enterprise. (#11168) 2022-03-22 23:36:36 +00:00
Alex McGrath cdae4e3ee2 ls consistency: add support for tctl desktop ls
```
Host Public Address       AD Domain   Labels               Version
---- -------------------- ----------- -------------------- ---------
corn 192.168.122.144:3389 example.com teleport..3 (9       9.0.0-dev
corn 192.168.122.51:3389  example.com teleport.rd Evle.com 9.0.0-dev
```

```yaml
kind: windows_desktop
metadata:
  expires: "2022-02-18T16:12:52.422659238Z"
  id: 1645200172423989197
  labels:
    teleport.dev/computer_name: WIN-LA2V0OD7SK0
    teleport.dev/dns_host_name: WIN-LA2V0OD7SK0.example.com
    teleport.dev/is_domain_controller: "true"
    teleport.dev/origin: dynamic
    teleport.dev/os: Windows Server 2012 R2 Standard Evaluation
    teleport.dev/os_version: 6.3 (9600)
    teleport.dev/windows_domain: example.com
  name: WIN-LA2V0OD7SK0-example-com
spec:
  addr: 192.168.122.51:3389
  domain: example.com
  host_id: 2c807641-92ae-4c70-88fe-b93e7b0aa179
version: v3
```
2022-03-15 13:22:45 +00:00
Alex McGrath 1627d79275 ls consistency: add tctl kube ls command
```
Cluster     Labels Version
----------- ------ -------------
minikube           8.0.0-alpha.1
honkcluster        8.0.3
```

```yaml
kind: kube_service
metadata:
  expires: "2021-12-16T16:07:14.898611765Z"
  id: 1639670234899200604
  name: 7b3ca8d8-710c-4305-aa29-e73628ac572c
spec:
  addr: 127.0.0.1:3027
  hostname: ""
  kube_clusters:
  - name: minikube
  rotation:
    current_id: ""
    last_rotated: "0001-01-01T00:00:00Z"
    schedule:
      standby: "0001-01-01T00:00:00Z"
      update_clients: "0001-01-01T00:00:00Z"
      update_servers: "0001-01-01T00:00:00Z"
    started: "0001-01-01T00:00:00Z"
  version: 8.0.0-alpha.1
version: v2
---
kind: kube_service
metadata:
  expires: "2021-12-16T16:10:13.068855399Z"
  id: 1639670413069866294
  name: 9153a5a9-e85e-4972-8c50-6fa8923282b2
spec:
  addr: remote.kube.proxy.teleport.cluster.local
  hostname: ""
  kube_clusters:
  - name: honkcluster
  rotation:
    current_id: ""
    last_rotated: "0001-01-01T00:00:00Z"
    schedule:
      standby: "0001-01-01T00:00:00Z"
      update_clients: "0001-01-01T00:00:00Z"
      update_servers: "0001-01-01T00:00:00Z"
    started: "0001-01-01T00:00:00Z"
  version: 8.0.3
version: v2
```yaml
2022-03-15 13:22:45 +00:00
bb121d7b1e Certificate renewal bot (#10099)
* Add certificate renewal bot

This adds a new `tbot` tool to continuously renew a set of
certificates after registering with a Teleport cluster using a
similar process to standard node joining.

This makes some modifications to user certificate generation to allow
for certificates that can be renewed beyond their original TTL, and
exposes new gRPC endpoints:
 * `CreateBotJoinToken` creates a join token for a bot user
 * `GenerateInitialRenewableUserCerts` exchanges a token for a set of
   certificates with a new `renewable` flag set

A new `tctl` command, `tctl bots add`, creates a bot user and calls
`CreateBotJoinToken` to issue a token. A bot instance can then be
started using a provided command.

* Cert bot refactoring pass

* Use role requests to split renewable certs from end-user certs
* Add bot configuration file
* Use `teleport.dev/bot` label
* Remove `impersonator` flag on initial bot certs
* Remove unnecessary `renew` package
* Misc other cleanup

* Do not pass through `renewable` flag when role requests are set

This adds additional restrictions on when a certificate's `renewable`
flag is carried over to a new certificate. In particular, it now also
denies the flag when either role requests are present, or the
`disallowReissue` flag has been previously set.

In practice `disallow-reissue` would have prevented any undesired
behavior but this improves consistency and resolves a TODO.

* Various tbot UX improvements; render SSH config

* Fully flesh out config template rendering
* Fix rendering for SSH configuration templates
* Added `String()` impls for destination types
* Improve certificate renewal logging; show more detail
* Properly fall back to default (all) roles
* Add mode hints for files
* Add/update copyright headers

* Add stubs for tbot init and watch commands

* Add gRPC endpoints for managing bots

* Add `CreateBot`, `DeleteBot`, and `GetBotUsers` gRPC endpoints
* Replace `tctl bot (add|rm|ls)` implementations with gRPC calls
* Define a few new constants, `DefaultBotJoinTTL`, `BotLabel`,
  `BotGenerationLabel`

* Fix outdated destination flag in example tbot command

* Bugfix pass for demo

* Fixed a few nil pointer derefs when using config from CLI args
* Properly create destination if `--destination-dir` flag is used
* Remove improper default on CLI flag
* `DestinationConfig` is now a list of pointers

* Address first wave of review feedback

Fixes the majority of smaller issues caught by reviewers, thanks all!

* Add doc comments for bot.go functions

* Return the token TTL from CreateBot

* Split initial user cert issuance from `generateUserCerts()`

Issuing initial renewable certificate ended up requiring a lot of
hacks to skip checks that prevented anonymous bots from getting
certs even though we'd verified their identity elsewhere (via token).

This reverts all those hacks and splits initial bot cert logic into a
dedicated `generateInitialRenewableUserCerts()` function which should
make the whole process much easier to follow.

* Set bot traits to silence log messages

* tbot log message consistency pass

* Resolve lints

* Add config tests

* Remove CreateBotJoinToken endpoint

Users should instead use the CreateBot/DeleteBot endpoints.

* Create a fresh private key for every impersonated identity renewal

* Hide `config` subcommand

* Rename bot label prefix to `teleport.internal/`

* Use types.NewRole() to create bot roles

* Clean up error handling in custom YAML unmarshallers

Also, add notes about the supported YAML shapes.

* Fetch proxy host via gRPC Ping() instead of GetProxies()

* Update lib/auth/bot.go

Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com>

* Fix some review comments

* Add renewable certificate generation checks (#10098)

* Add renewable certificate generation checks

This adds a new validation check for renewable certificates that
maintains a renewal counter as both a certificate extension and a
user label. This counter is used to ensure only a single certificate
lineage can exist: for example, if a renewable certificate is stolen,
only one copy of the certificate can be renewed as the generation
counter will not match

When renewing a certificate, first the generation counter presented
by the user (via their TLS identity) is compared to a value stored
with the associated user (in a new `teleport.dev/bot-generation`
label field). If they aren't equal, the renewal attempt fails.
Otherwise, the generation counter is incremented by 1, stored to the
database using a `CompareAndSwap()` to ensure atomicity, and set on
the generated certificate for use in future renewals.

* Add unit tests for the generation counter

This adds new unit tests to exercise the generation counter checks.

Additionally, it fixes two other renewable cert tests that were
failing.

* Remove certRequestGeneration() function

* Emit audit event when cert generations don't match

* Fully implement `tctl bots lock`

* Show bot name in `tctl bots ls`

* Lock bots when a cert generation mismatch is found

* Make CompareFailed respones from validateGenerationLabel() more actionable

* Update lib/services/local/users.go

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

* Backend changes for tbot IoT and AWS joining (#10360)

* backend changes

* add token permission check

* pass ctx from caller

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

* fix comment typo

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

* use UserMetadata instead of Identity in RenewableCertificateGenerationMismatch event

* Client changes for tbot IoT joining (#10397)

* client changes

* delete replaced APIs

* delete unused tbot/auth.go

* add license header

* don't unecessarily fetch host CA

* log fixes

* s/tunnelling/tunneling/

Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com>

* auth server addresses may be proxies

Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com>

* comment typo fix

Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com>

* move *Server methods out of auth_with_roles.go (#10416)

Co-authored-by: Tim Buckley <tim@goteleport.com>

Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com>
Co-authored-by: Tim Buckley <tim@goteleport.com>

Co-authored-by: Roman Tkachenko <roman@goteleport.com>
Co-authored-by: Tim Buckley <tim@goteleport.com>
Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com>

Co-authored-by: Nic Klaassen <nic@goteleport.com>
Co-authored-by: Roman Tkachenko <roman@goteleport.com>
Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com>

* Address another batch of review feedback

* Addres another batch of review feedback

Add `Role.SetMetadata()`, simplify more `trace.WrapWithMessage()`
calls, clear some TODOs and lints, and address other misc feedback
items.

* Fix lint

* Add missing doc comments to SaveIdentity / LoadIdentity

* Remove pam tag from tbot build

* Update note about bot lock deletion

* Another pass of review feedback

Ensure all requestable roles exist when creating a bot, adjust the
default renewable cert TTL down to 1 hour, and check types during
`CompareAndSwapUser()`

Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com>
Co-authored-by: Nic Klaassen <nic@goteleport.com>
Co-authored-by: Roman Tkachenko <roman@goteleport.com>
2022-02-19 02:41:45 +00:00
Rui Li 89440dcfcf Datalog based access tester (#7543)
Created an access tester for troubleshooting access related issues with Teleport RBAC system. This access tester allows admins to answer questions like:

Can user alice SSH into a node node-1 as root?
If not, which role(-s) prevents access?
Which roles allow access to production as login admin?
2021-08-25 14:39:59 -04:00
Andrej Tokarčík 2e419119f8 Introduce tctl lock command (#7809) 2021-08-13 06:24:46 -07:00
Alexander Klizhentas 0028bf93d1 Moves loadCredsFromProfile to OSS (#5891)
With 6.0 OSS migrated to RBAC, OSS tctl can connect
remotely with users credentials.
2021-03-09 20:49:16 -08:00
Roman Tkachenko 8e1865464b Database access (#5005) 2021-01-14 18:21:38 -08:00
Sasha Klizhentas ce8c83d722 Adds support for loading tctl creds from ~/.tsh profile
This commit fixes #4439
2020-11-09 20:24:09 -08:00
Russell Jones 904b0d0488 Added Application Access.
Added support for an identity aware, RBAC enforcing, mutually
authenticated, web application proxy to Teleport.

* Updated services.Server to support an application servers.
* Updated services.WebSession to support application sessions.
* Added CRUD RPCs for "AppServers".
* Added CRUD RPCs for "AppSessions".
* Added RBAC support using labels for applications.
* Added JWT signer as a services.CertAuthority type.
* Added support for signing and verifying JWT tokens.
* Refactored dynamic label and heartbeat code into standalone packages.
* Added application support to web proxies and new "app_service" to
  proxy mutually authenticated connections from proxy to an internal
  application.
2020-11-03 14:32:13 -08:00
Forrest Marshall ec327b6e03 Implment access-request system (workflow API) 2019-12-02 14:05:51 -08:00
Sasha Klizhentas 8356ae6a74 Use in-memory cache for the auth server API.
This commit expands the usage of the caching layer
for auth server API:

* Introduces in-memory cache that is used to serve all
Auth server API requests. This is done to achieve scalability
on 10K+ node clusters, where each node fetches certificate authorities,
roles, users and join tokens. It is not possible to scale
DynamoDB backend or other backends on 10K reads per seconds
on a single shard or partition. The solution is to introduce
an in-memory cache of the backend state that is always used
for reads.

* In-memory cache has been expanded to support all resources
required by the auth server.

* Experimental `tctl top` command has been introduced to display
common single node metrics.

Replace SQLite Memory Backend with BTree

SQLite in memory backend was suffering from
high tail latencies under load (up to 8 seconds
in 99.9%-ile on load configurations).

This commit replaces the SQLite memory caching
backend with in-memory BTree backend that
brought down tail latencies to 2 seconds (99.9%-ile)
and brought overall performance improvement.
2019-04-12 14:23:09 -07:00
Sasha Klizhentas 3e144cb900 Teleport certificate authority rotation.
This commit implements #1860

During the the rotation procedure issuing TLS and SSH
certificate authorities are re-generated and all internal
components of the cluster re-register to get new
credentials.

The rotation procedure is based on a distributed
state machine algorithm - certificate authorities have
explicit rotation state and all parts of the cluster sync
local state machines by following transitions between phases.

Operator can launch CA rotation in auto or manual modes.

In manual mode operator moves cluster bewtween rotation states
and watches the states of the components to sync.

In auto mode state transitions are happening automatically
on a specified schedule.

The design documentation is embedded in the code:

lib/auth/rotate.go
2018-04-30 12:58:57 -07:00
Roman Tkachenko 5dbda4f41b Use plugins mechanism instead of oss/e flag 2017-10-13 17:32:45 -07:00
Ev Kontsevoy d965e9e0a3 Added cleaner way to specify which distribution of Teleport is running 2017-09-06 14:19:54 -07:00
Ev Kontsevoy e301279b5c Finished tctl refactoring
`tctl` can now be compiled for multiple distributions, with different
features (commands) enabled or disabled.
2017-07-25 22:41:19 -07:00
Ev Kontsevoy 94c35298b8 Preparation for 2.3
- Switched to new way of building Enterprise
- Removed `tctl tunnels` command (preparation for new resources)
- Removed `tctl auth ls` command (preparation for new resources)
2017-06-21 20:14:40 -07:00
Sasha Klizhentas 202c3fc0b9 move code around 2017-02-15 18:29:17 -08:00
Ev Kontsevoy e988630783 tsh logout + tctl create
This commit closes #667

- `tsh logout` will now log you out of everything
- `tctl upsert` has been renamed to `tctl create`
2017-01-29 19:26:27 -08:00
Ev Kontsevoy b9605a28c1 Marked in-progress tctl commands as 'hidden' 2017-01-01 19:04:37 -08:00
Sasha Klizhentas 255d6d870e get, upsert, delete commands support new resources 2016-12-31 17:11:00 -08:00
Ev Kontsevoy f6cc2d87f9 Merge branch 'master' into sasha/oidc 2016-12-30 19:36:25 -08:00
Ev Kontsevoy fcbca4821b Removed the error obstruction in tctl
Fixes #659
2016-12-30 19:27:20 -08:00
Sasha Klizhentas 2cc1a548c5 finished changes 2016-12-30 15:13:45 -08:00
Ev Kontsevoy 5df0cf03c7 Merge branch 'master' into sasha/dynamic 2016-12-25 00:37:38 -08:00
Sasha Klizhentas f583403625 set reasonable default TTL 2016-12-24 15:59:33 -08:00
Sasha Klizhentas 8ab3add372 map OIDC scopes to roles, implements #620 2016-12-24 14:42:33 -08:00
Sasha Klizhentas d214f5d5e2 address code review comments 2016-12-22 19:06:07 -08:00
Sasha Klizhentas c8217f6d35 add missing pieces 2016-12-21 14:58:26 -08:00
Sasha Klizhentas 81c69851e2 tctl add upsert, get 2016-12-20 19:19:44 -08:00
Sasha Klizhentas 1c690ea0f4 add tctl 2016-12-20 16:31:40 -08:00
Sasha Klizhentas aa41f032a3 more fixes 2016-12-20 14:01:46 -08:00
Sasha Klizhentas 2dceb42547 Merge branch 'master' into sasha/rbac 2016-12-14 16:36:55 -08:00
Sasha Klizhentas 7e97b10032 add support for namespaces almost everywhere 2016-12-14 15:48:36 -08:00
Ev Kontsevoy 37d77189a0 Updated "tctl auth sign" command
Changes:

- Added a proper help message for `--ttl` flag
- Added `--out` flag to specify where to store the keys
- Removed 3 flags for file names
- File names (keys, cert) are generated using `tsh` naming convention

Fixes #636
2016-12-11 22:30:00 -08:00
Sasha Klizhentas ab19c70032 implement cert gen CLI tool 2016-12-06 10:43:19 -08:00
Ev Kontsevoy 2f9c669d26 Merge branch 'master' into ev/standalone 2016-10-14 00:11:41 -07:00
Ev Kontsevoy 07e8d212ff Minor usability issue with tctl
tctl was doing configuration validation too early, even on "version"
command (which should always succeed)
2016-10-10 16:39:06 -07:00
Ev Kontsevoy baafe3a332 Renamed GetLocalDomain() to GetDomainName() 2016-10-09 17:27:56 -07:00
dmitri 9decde57cc tctl: do not create datadir/host_uuid if none has been found - if the
client runs with elevated permissions and the command fails (for
instance, when the auth server state has not yet been generated), it
will leave the file behind possibly making further attempts to properly
generate content in data directory by a lower-privilege process impossible.
2016-09-22 13:43:58 +02:00
Ev Kontsevoy f235f46b06 Released 1.0.5 2016-08-19 14:54:52 -07:00
Ev Kontsevoy a71af867a0 Merge remote-tracking branch 'origin/master' into ev/tunnels 2016-06-11 20:17:35 -07:00