Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement tbot init subcommand and ACL management #10289

Merged
merged 82 commits into from
Mar 10, 2022
Merged

Commits on Jan 14, 2022

  1. 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.
    timothyb89 committed Jan 14, 2022
    Configuration menu
    Copy the full SHA
    0642d9b View commit details
    Browse the repository at this point in the history

Commits on Jan 21, 2022

  1. 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
    timothyb89 committed Jan 21, 2022
    Configuration menu
    Copy the full SHA
    278373b View commit details
    Browse the repository at this point in the history

Commits on Jan 26, 2022

  1. 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.
    timothyb89 committed Jan 26, 2022
    Configuration menu
    Copy the full SHA
    3cb5f41 View commit details
    Browse the repository at this point in the history
  2. 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
    timothyb89 committed Jan 26, 2022
    Configuration menu
    Copy the full SHA
    65997a6 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    ff58ccf View commit details
    Browse the repository at this point in the history

Commits on Jan 27, 2022

  1. 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`
    timothyb89 committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    75ee80b View commit details
    Browse the repository at this point in the history

Commits on Feb 2, 2022

  1. Configuration menu
    Copy the full SHA
    65b4f91 View commit details
    Browse the repository at this point in the history
  2. 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
    timothyb89 committed Feb 2, 2022
    Configuration menu
    Copy the full SHA
    fced606 View commit details
    Browse the repository at this point in the history

Commits on Feb 4, 2022

  1. Address first wave of review feedback

    Fixes the majority of smaller issues caught by reviewers, thanks all!
    timothyb89 committed Feb 4, 2022
    Configuration menu
    Copy the full SHA
    e8b3b0f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    773a4ef View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    34ae6a6 View commit details
    Browse the repository at this point in the history

Commits on Feb 8, 2022

  1. 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.
    timothyb89 committed Feb 8, 2022
    Configuration menu
    Copy the full SHA
    9c5ca57 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    17a1c77 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    bd3152b View commit details
    Browse the repository at this point in the history

Commits on Feb 10, 2022

  1. Implement tbot init subcommand

    This adds a new CLI subcommand to initialize a tbot destination
    directory by creating required files ahead of time and assigning
    proper permissions (and ACLs, where possible).
    timothyb89 committed Feb 10, 2022
    Configuration menu
    Copy the full SHA
    d7c49e7 View commit details
    Browse the repository at this point in the history
  2. Resolve lints

    timothyb89 committed Feb 10, 2022
    Configuration menu
    Copy the full SHA
    12942dd View commit details
    Browse the repository at this point in the history

Commits on Feb 11, 2022

  1. Add config tests

    timothyb89 committed Feb 11, 2022
    Configuration menu
    Copy the full SHA
    8cd83c7 View commit details
    Browse the repository at this point in the history
  2. Remove CreateBotJoinToken endpoint

    Users should instead use the CreateBot/DeleteBot endpoints.
    timothyb89 committed Feb 11, 2022
    Configuration menu
    Copy the full SHA
    28bab88 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    5a71864 View commit details
    Browse the repository at this point in the history

Commits on Feb 15, 2022

  1. Configuration menu
    Copy the full SHA
    d800382 View commit details
    Browse the repository at this point in the history
  2. Hide config subcommand

    timothyb89 committed Feb 15, 2022
    Configuration menu
    Copy the full SHA
    cefe734 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    5003459 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    0b7e7e5 View commit details
    Browse the repository at this point in the history

Commits on Feb 16, 2022

  1. Configuration menu
    Copy the full SHA
    f725b62 View commit details
    Browse the repository at this point in the history
  2. Clean up error handling in custom YAML unmarshallers

    Also, add notes about the supported YAML shapes.
    timothyb89 committed Feb 16, 2022
    Configuration menu
    Copy the full SHA
    4a3a417 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    28f930b View commit details
    Browse the repository at this point in the history

Commits on Feb 17, 2022

  1. Configuration menu
    Copy the full SHA
    00e29b5 View commit details
    Browse the repository at this point in the history

Commits on Feb 18, 2022

  1. Update lib/auth/bot.go

    Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com>
    timothyb89 and zmb3 authored Feb 18, 2022
    Configuration menu
    Copy the full SHA
    a7529b9 View commit details
    Browse the repository at this point in the history
  2. Fix some review comments

    timothyb89 committed Feb 18, 2022
    Configuration menu
    Copy the full SHA
    b1bbcb8 View commit details
    Browse the repository at this point in the history
  3. 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>
    4 people authored Feb 18, 2022
    Configuration menu
    Copy the full SHA
    004b25c View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    c3be5d6 View commit details
    Browse the repository at this point in the history
  5. 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.
    timothyb89 committed Feb 18, 2022
    Configuration menu
    Copy the full SHA
    f004e10 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    77c0803 View commit details
    Browse the repository at this point in the history
  7. Fix lint

    timothyb89 committed Feb 18, 2022
    Configuration menu
    Copy the full SHA
    1f946f9 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    587974d View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    bd5f514 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    01546ec View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    bf1cf3a View commit details
    Browse the repository at this point in the history

Commits on Feb 19, 2022

  1. 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()`
    timothyb89 committed Feb 19, 2022
    Configuration menu
    Copy the full SHA
    c65c56a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0300f52 View commit details
    Browse the repository at this point in the history

Commits on Feb 22, 2022

  1. Merge branch 'timothyb89/tbot' into timothyb89/tbot-init

    Merge note: BotKinds() now includes SSH certificates to support IoT
    joining.
    timothyb89 committed Feb 22, 2022
    Configuration menu
    Copy the full SHA
    73b7ba2 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0ad110e View commit details
    Browse the repository at this point in the history

Commits on Feb 23, 2022

  1. Remove ModeHint

    timothyb89 committed Feb 23, 2022
    Configuration menu
    Copy the full SHA
    cf6406f View commit details
    Browse the repository at this point in the history

Commits on Feb 24, 2022

  1. Configuration menu
    Copy the full SHA
    0f78580 View commit details
    Browse the repository at this point in the history
  2. Add symlinks flag to tbot config

    The optional symlinks flag for directory destinations allows users to
    opt in / out of whichever symlink attack hardening mode is selected
    by default.
    timothyb89 committed Feb 24, 2022
    Configuration menu
    Copy the full SHA
    3e0a05f View commit details
    Browse the repository at this point in the history
  3. Add mostly-working secure implementation of botfs.Create/Write

    This adds symlink mode selection (secure, try-secure, insecure) and
    Linux `Create()`/`Write()` implementations to open files safely.
    timothyb89 committed Feb 24, 2022
    Configuration menu
    Copy the full SHA
    3da96dd View commit details
    Browse the repository at this point in the history

Commits on Mar 1, 2022

  1. Configuration menu
    Copy the full SHA
    f94f724 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5ddfd71 View commit details
    Browse the repository at this point in the history
  3. Initialize destinations at startup and test before renewal

    This initializes destinations at startup (to create directories if
    not using `tbot init`) and tests them to ensure the bot can write
    _before_ attempting to renew certificates; this should prevent most
    accidental generation counter locks.
    timothyb89 committed Mar 1, 2022
    Configuration menu
    Copy the full SHA
    37400dc View commit details
    Browse the repository at this point in the history
  4. Hide watch for now

    timothyb89 committed Mar 1, 2022
    Configuration menu
    Copy the full SHA
    c9fb533 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    4b2fa72 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    40f6d0b View commit details
    Browse the repository at this point in the history

Commits on Mar 2, 2022

  1. Fully implement ACL Verify and Configure

     - Fully implements ACL support for Linux
     - Adds bot-side verification support to ensure ACLs are configured
       properly at runtime.
     - Gracefully falls back to no ACLs if the platform / filesystem
       doesn't support them
     - Clear up outstanding lints
    timothyb89 committed Mar 2, 2022
    Configuration menu
    Copy the full SHA
    9893602 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    048b524 View commit details
    Browse the repository at this point in the history

Commits on Mar 3, 2022

  1. Show init instructions in tctl bots add

    Also:
     - Make --bot-user a flag in init (the tctl instructions were
       confusing otherwise)
     - Handle IsOwnedBy sanely on unsupported platforms
     - Add Bold colorizing support
    timothyb89 committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    25017b4 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7f25b5a View commit details
    Browse the repository at this point in the history
  3. Fix typo

    timothyb89 committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    73bed1a View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    b2460a4 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    1276661 View commit details
    Browse the repository at this point in the history
  6. Actually read and write certs with symlink enforcement

    Also, fix a config loading bug where CheckAndSetDefaults() wasn't
    being called in all cases with CLI destinations.
    timothyb89 committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    202a97d View commit details
    Browse the repository at this point in the history

Commits on Mar 5, 2022

  1. Add workaround for OpenSSH permissions check with ACLs

    OpenSSH has an overly-paranoid permissions check that forces key
    files to be exclusively owner-readable. Unfortunately, for POSIX
    compatibility purposes, when ACLs are set, the ACL mask is set as
    the group permissions. This effectively makes any ACL incompatible
    with OpenSSH.
    
    However, OpenSSH's check does have an escape hatch: it only applies
    if the current user is the owner of the file. Therefore, this change
    tweaks the `tbot init` flow to create files as root, owned by a
    separate user (either `nobody` or even the bot user), with ACL
    permissions granting both the bot and reader user access to the
    certificates. This effectively bypasses OpenSSH's permissions check
    and should preserve our security boundaries.
    timothyb89 committed Mar 5, 2022
    Configuration menu
    Copy the full SHA
    b114926 View commit details
    Browse the repository at this point in the history

Commits on Mar 7, 2022

  1. Fix lints

    timothyb89 committed Mar 7, 2022
    Configuration menu
    Copy the full SHA
    24d066f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6b9223f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    8a8d656 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    3d55e48 View commit details
    Browse the repository at this point in the history
  5. Fix err misuse

    timothyb89 committed Mar 7, 2022
    Configuration menu
    Copy the full SHA
    5ac9aa2 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    7a96daa View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    126162d View commit details
    Browse the repository at this point in the history
  8. Fix typo

    timothyb89 committed Mar 7, 2022
    Configuration menu
    Copy the full SHA
    1994858 View commit details
    Browse the repository at this point in the history

Commits on Mar 8, 2022

  1. Configuration menu
    Copy the full SHA
    9bb139e View commit details
    Browse the repository at this point in the history
  2. Address review feedback

    - Rename ACLOn -> ACLRequired
    - Simplify fs_linux.Read()
    - Add missing fs_other.Read()
    - Hoist renewal loop logic into its own function
    - A few misc bugfixes
    timothyb89 committed Mar 8, 2022
    Configuration menu
    Copy the full SHA
    ca974b8 View commit details
    Browse the repository at this point in the history
  3. Apply suggestions from code review

    Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
    timothyb89 and rosstimothy authored Mar 8, 2022
    Configuration menu
    Copy the full SHA
    8855518 View commit details
    Browse the repository at this point in the history
  4. Address review feedback

    - Only log syscall warning once
    - Formatting and wording changes
    - Improve error handling for `--clean`
    timothyb89 committed Mar 8, 2022
    Configuration menu
    Copy the full SHA
    38c9fcb View commit details
    Browse the repository at this point in the history

Commits on Mar 9, 2022

  1. Fix lint error

    timothyb89 committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    af1908a View commit details
    Browse the repository at this point in the history

Commits on Mar 10, 2022

  1. Configuration menu
    Copy the full SHA
    d9f8ed1 View commit details
    Browse the repository at this point in the history
  2. Fix imports in fs_other

    timothyb89 committed Mar 10, 2022
    Configuration menu
    Copy the full SHA
    26f8fc9 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    19dc449 View commit details
    Browse the repository at this point in the history
  4. Use the bot user as default owner

    This is more likely to be a safe owner choice than `nobody:nobody`.
    timothyb89 committed Mar 10, 2022
    Configuration menu
    Copy the full SHA
    33afc77 View commit details
    Browse the repository at this point in the history
  5. Apply suggestions from code review

    Co-authored-by: Roman Tkachenko <roman@goteleport.com>
    timothyb89 and r0mant authored Mar 10, 2022
    Configuration menu
    Copy the full SHA
    42aee8a View commit details
    Browse the repository at this point in the history
  6. Code review fixes

    timothyb89 committed Mar 10, 2022
    Configuration menu
    Copy the full SHA
    e416fdb View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    8bb8a5c View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    e76777c View commit details
    Browse the repository at this point in the history