[v9] Add new config templates to tbot
for databases and identity files (#11596)
#12500
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #11596 for branch/v9
identityfile
config template totbot
This adds a new
identityfile
config template to tbot whichgenerates an identity file from any of the formats supported by
tctl auth sign
.It can be used by specifying one or more formats in the configuration
like so:
It requires both SSH and TLS certificates to work properly. App,
Kubernetes, and Database certs are unlikely to work as they have
additional cert requirements that will be added in separate PRs.
Multiple formats can be specified, and each will be written to its
own subdirectory within the destination using the name of the format.
The particular files written inside this directory depend on the
particular format selected, but n the above example, this means a
file named
/foo/file/identity
is written.The files all have an
identity
prefix at the moment. This could bemade configurable if desired.
The
file
format can be used in conjunction withtsh -i
andtctl -i
to use those tools with a tbot-generated identity.Fixes #10812
This promotes most of the important identityfile formats to proper
config templates. User-facing
kinds
are removed to reduce confusionand several config templates are now required.
ssh_client
template is now required and will be addedautomatically in all cases if not specified.
tls_cas
template is added to always exportthe current Teleport server CAs in a usable format.
identity
template is added to always export anidentity file usable with tsh/tctl.
cockroach
,mongo
, andtls
templates can exportspecifically-formatted TLS certs for various databases and apps.
Additionally some other changes were caught during testing:
botfs
now allows users to specify if files should be opened forreading or for writing; previously, written files were never
truncated when opened for writing leading to garbage at the end of
files if the length changed. Truncation isn't sane for reading so
the two use-cases are now split.
Update lib/client/identityfile/identity.go
Co-authored-by: Jakub Nyckowski [email protected]
Tweaked the
botfs.openStandard
andbotfs.openSecure
functions toaccept a plain file mode, and removed a ton of boilerplate in
configtemplate.go
.Fix problematic nil interface check in configtemplate
Clarify comment about
client.Key
DB certsAddress review feedback
DatabaseCA
for database specific templates; make thetls
template's CA configurable; write the database CA alongside the
others.
Co-authored-by: Jakub Nyckowski [email protected]