Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
35f9f3c
Move `CertificateTTL` and `RenewalInterval` into a `CertificateLifeti…
boxofrad Feb 7, 2025
0267b0c
Support custom `certificate_ttl` and `renewal_interval` on identity o…
boxofrad Feb 7, 2025
c631721
Support custom `certificate_ttl` and `renewal_interval` on applicatio…
boxofrad Feb 7, 2025
07d85d5
Support custom `certificate_ttl` and `renewal_interval` on applicatio…
boxofrad Feb 7, 2025
21f69b1
Support custom `certificate_ttl` and `renewal_interval` on Kubernetes…
boxofrad Feb 7, 2025
0a106f3
Support custom `certificate_ttl` and `renewal_interval` on Kubernetes…
boxofrad Feb 7, 2025
a2b0935
Support custom `certificate_ttl` and `renewal_interval` on database t…
boxofrad Feb 7, 2025
5f9b697
Support custom `certificate_ttl` and `renewal_interval` on SSH host o…
boxofrad Feb 7, 2025
06c64fa
Support custom `certificate_ttl` and `renewal_interval` on SSH multip…
boxofrad Feb 7, 2025
0e075b0
Support custom `certificate_ttl` and `renewal_interval` on SPIFFE SVI…
boxofrad Feb 10, 2025
e640b0d
Support custom `certificate_ttl` and `renewal_interval` on database o…
boxofrad Feb 10, 2025
fefc20e
Support custom `certificate_ttl` and `renewal_interval` on workload API
boxofrad Feb 10, 2025
3890304
Support custom `certificate_ttl` and `renewal_interval` on workload i…
boxofrad Feb 10, 2025
0e32224
Add `GetCertificateLifetime` to service config interface
boxofrad Feb 10, 2025
62f42d1
Update the docs
boxofrad Feb 10, 2025
c75a797
Add more examples to the standard config
boxofrad Feb 10, 2025
4593fa2
Rename `CertificateLifetime` to `CredentialLifetime`
boxofrad Feb 11, 2025
ed87157
Deprecate `certificate_ttl` option and replace it with `credential_ttl`
boxofrad Feb 11, 2025
ab6d621
Return TTL warnings as errors and let the caller decide what to do wi…
boxofrad Feb 11, 2025
438d716
Add `CredentialLifetime` to the "full" service config tests
boxofrad Feb 11, 2025
2628443
Support `credential_ttl` and `renewal_interval` in workload-identity-…
boxofrad Feb 11, 2025
3380cef
Silence sloglint
boxofrad Feb 11, 2025
80f54e7
Replace duplicated helper with `cmp.Or`
boxofrad Feb 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/pages/enroll-resources/machine-id/faq.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Machine ID.
## Can Machine ID be used to generate long-lived certificates?

Machine ID cannot currently be used to generate certificates valid for longer
than 24 hours, and requests for longer certificates using the `certificate_ttl`
than 24 hours, and requests for longer certificates using the `credential_ttl`
parameter will be reduced to this 24 hour limit.

This limit serves multiple purposes. For one, it encourages security best
Expand Down
10 changes: 10 additions & 0 deletions docs/pages/includes/machine-id/common-output-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,13 @@ destination:
# if no roles are specified, all roles the bot is allowed to impersonate are used.
roles:
- editor

# credential_ttl and renewal_interval override the credential TTL and renewal
# interval for this specific output, so that you can make its certificates valid
# for shorter than `tbot`'s internal certificates.
#
# This is particularly useful when using `tbot` in one-shot as part of a cron job
# where you need `tbot`'s internal certificate to live long enough to be renewed
# on the next invocation, but don't want long-lived workload certificates on-disk.
credential_ttl: 30m
renewal_interval: 15m
12 changes: 9 additions & 3 deletions docs/pages/reference/machine-id/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,23 @@ auth_server: "teleport.example.com:3025"
# Teleport Cloud, the address of your Teleport Cloud instance.
proxy_server: "teleport.example.com:443" # or "example.teleport.sh:443" for Teleport Cloud

# certificate_ttl specifies how long certificates generated by `tbot` should
# credential_ttl specifies how long certificates generated by `tbot` should
# live for. It should be a positive, numeric value with an `m` (for minutes) or
# `h` (for hours) suffix. By default, this value is `1h`.
# This has a maximum value of `24h`.
certificate_ttl: "1h"
#
# It can be overridden for most outputs and services to give them a shorter TTL
# than `tbot`'s internal certificates.
credential_ttl: "1h"

# renewal_interval specifies how often `tbot` should aim to renew the
# outputs it has generated. It should be a positive, numeric value with an
# `m` (for minutes) or `h` (for hours) suffix. The default value is `20m`.
# This value must be lower than `certificate_ttl`.
# This value must be lower than `credential_ttl`.
# This value is ignored when using `tbot` is running in one-shot mode.
#
# It can be overridden for most outputs and services to give them a shorter
# renewal interval than `tbot`'s internal certificates.
renewal_interval: "20m"

# oneshot configures `tbot` to exit immediately after generating the outputs.
Expand Down
12 changes: 7 additions & 5 deletions integrations/lib/embeddedtbot/bot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,13 @@ func TestBotJoinAuth(t *testing.T) {
TokenValue: tokenName,
JoinMethod: types.JoinMethodToken,
},
AuthServer: authAddr.Addr,
CertificateTTL: defaultCertificateTTL,
RenewalInterval: defaultRenewalInterval,
Oneshot: true,
Debug: true,
AuthServer: authAddr.Addr,
CredentialLifetime: config.CredentialLifetime{
TTL: defaultCertificateTTL,
RenewalInterval: defaultRenewalInterval,
},
Oneshot: true,
Debug: true,
}
bot, err := New(botConfig)
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions integrations/lib/embeddedtbot/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func (c *BotConfig) BindFlags(fs *flag.FlagSet) {
fs.StringVar(&c.AuthServer, "auth-server", "127.0.0.1:3025", "Address of the Teleport Auth Server or Proxy Server")
fs.StringVar(&c.Onboarding.TokenValue, "token", "teleport-operator", "A bot join token or path to file with token value.")
fs.StringVar((*string)(&c.Onboarding.JoinMethod), "join-method", string(types.JoinMethodKubernetes), "Method to use to join the Teleport cluster.")
fs.DurationVar(&c.CertificateTTL, "certificate-ttl", defaultCertificateTTL, "TTL of short-lived machine certificates.")
fs.DurationVar(&c.RenewalInterval, "renewal-interval", defaultRenewalInterval, "Interval at which short-lived certificates are renewed; must be less than the certificate TTL.")
fs.DurationVar(&c.CredentialLifetime.TTL, "certificate-ttl", defaultCertificateTTL, "TTL of short-lived machine certificates.")
fs.DurationVar(&c.CredentialLifetime.RenewalInterval, "renewal-interval", defaultRenewalInterval, "Interval at which short-lived certificates are renewed; must be less than the certificate TTL.")
caPinsFlag := StringListVar{
list: &c.Onboarding.CAPins,
}
Expand Down
6 changes: 4 additions & 2 deletions integrations/terraform/provider/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,10 @@ See https://goteleport.com/docs/reference/join-methods for more details.`)
AudienceTag: audienceTag,
},
},
CertificateTTL: time.Hour,
RenewalInterval: 20 * time.Minute,
CredentialLifetime: tbotconfig.CredentialLifetime{
TTL: time.Hour,
RenewalInterval: 20 * time.Minute,
},
}
bot, err := embeddedtbot.New(botConfig)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions lib/tbot/cli/start_identity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func TestIdentityCommand(t *testing.T) {
require.Equal(t, "foo", token)

require.ElementsMatch(t, cfg.Onboarding.CAPins, []string{"bar"})
require.Equal(t, time.Minute*10, cfg.CertificateTTL)
require.Equal(t, time.Minute*5, cfg.RenewalInterval)
require.Equal(t, time.Minute*10, cfg.CredentialLifetime.TTL)
require.Equal(t, time.Minute*5, cfg.CredentialLifetime.RenewalInterval)
require.Equal(t, types.JoinMethodGitHub, cfg.Onboarding.JoinMethod)
require.True(t, cfg.Oneshot)
require.Equal(t, "0.0.0.0:8080", cfg.DiagAddr)
Expand Down
12 changes: 6 additions & 6 deletions lib/tbot/cli/start_legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,29 +188,29 @@ func (c *LegacyCommand) ApplyConfig(cfg *config.BotConfig, l *slog.Logger) error
}

if c.CertificateTTL != 0 {
if cfg.CertificateTTL != 0 {
if cfg.CredentialLifetime.TTL != 0 {
log.WarnContext(
context.TODO(),
"CLI parameters are overriding configuration",
"flag", "certificate-ttl",
"config_value", cfg.CertificateTTL,
"config_value", cfg.CredentialLifetime.TTL,
"cli_value", c.CertificateTTL,
)
}
cfg.CertificateTTL = c.CertificateTTL
cfg.CredentialLifetime.TTL = c.CertificateTTL
}

if c.RenewalInterval != 0 {
if cfg.RenewalInterval != 0 {
if cfg.CredentialLifetime.RenewalInterval != 0 {
log.WarnContext(
context.TODO(),
"CLI parameters are overriding configuration",
"flag", "renewal-interval",
"config_value", cfg.RenewalInterval,
"config_value", cfg.CredentialLifetime.RenewalInterval,
"cli_value", c.RenewalInterval,
)
}
cfg.RenewalInterval = c.RenewalInterval
cfg.CredentialLifetime.RenewalInterval = c.RenewalInterval
}

// DataDir overrides any previously-configured storage config
Expand Down
4 changes: 2 additions & 2 deletions lib/tbot/cli/start_legacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func TestLegacyCommand(t *testing.T) {
require.Equal(t, "foo", token)

require.ElementsMatch(t, cfg.Onboarding.CAPins, []string{"bar"})
require.Equal(t, time.Minute*10, cfg.CertificateTTL)
require.Equal(t, time.Minute*5, cfg.RenewalInterval)
require.Equal(t, time.Minute*10, cfg.CredentialLifetime.TTL)
require.Equal(t, time.Minute*5, cfg.CredentialLifetime.RenewalInterval)
require.Equal(t, types.JoinMethodGitHub, cfg.Onboarding.JoinMethod)
require.True(t, cfg.Oneshot)
require.Equal(t, "0.0.0.0:8080", cfg.DiagAddr)
Expand Down
12 changes: 6 additions & 6 deletions lib/tbot/cli/start_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,29 +153,29 @@ func (s *sharedStartArgs) ApplyConfig(cfg *config.BotConfig, l *slog.Logger) err
}

if s.CertificateTTL != 0 {
if cfg.CertificateTTL != 0 {
if cfg.CredentialLifetime.TTL != 0 {
l.WarnContext(
context.TODO(),
"CLI parameters are overriding configuration",
"flag", "certificate-ttl",
"config_value", cfg.CertificateTTL,
"config_value", cfg.CredentialLifetime.TTL,
"cli_value", s.CertificateTTL,
)
}
cfg.CertificateTTL = s.CertificateTTL
cfg.CredentialLifetime.TTL = s.CertificateTTL
}

if s.RenewalInterval != 0 {
if cfg.RenewalInterval != 0 {
if cfg.CredentialLifetime.RenewalInterval != 0 {
l.WarnContext(
context.TODO(),
"CLI parameters are overriding configuration",
"flag", "renewal-interval",
"config_value", cfg.RenewalInterval,
"config_value", cfg.CredentialLifetime.RenewalInterval,
"cli_value", s.RenewalInterval,
)
}
cfg.RenewalInterval = s.RenewalInterval
cfg.CredentialLifetime.RenewalInterval = s.RenewalInterval
}

if s.DiagAddr != "" {
Expand Down
4 changes: 2 additions & 2 deletions lib/tbot/cli/start_shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ func TestSharedStartArgs(t *testing.T) {
require.Equal(t, "foo", token)

require.ElementsMatch(t, cfg.Onboarding.CAPins, []string{"bar"})
require.Equal(t, time.Minute*10, cfg.CertificateTTL)
require.Equal(t, time.Minute*5, cfg.RenewalInterval)
require.Equal(t, time.Minute*10, cfg.CredentialLifetime.TTL)
require.Equal(t, time.Minute*5, cfg.CredentialLifetime.RenewalInterval)
require.Equal(t, types.JoinMethodGitHub, cfg.Onboarding.JoinMethod)
require.True(t, cfg.Oneshot)
require.Equal(t, "0.0.0.0:8080", cfg.DiagAddr)
Expand Down
Loading