Skip to content
New issue

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

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

Already on GitHub? # to your account

Allow users to request database certificates in Machine ID #11904

Merged
merged 6 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 32 additions & 0 deletions tool/tbot/config/config_destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,39 @@ import (
"github.com/gravitational/trace"
)

// DatabaseConfig is the config for a database access request.
type DatabaseConfig struct {
// Service is the service name of the Teleport database. Generally this is
// the name of the Teleport resource.
Service string `yaml:"service,omitempty"`

// Database is the name of the database to request access to.
Database string `yaml:"database,omitempty"`

// Username is the database username to request access as.
Username string `yaml:"username,omitempty"`
}

func (dc *DatabaseConfig) CheckAndSetDefaults() error {
if dc.Service == "" {
return trace.BadParameter("database `service` field must specify a database service name")
}

// Note: tsh has special checks for MongoDB and Redis. We don't know the
// protocol at this point so we'll need to defer those checks.

return nil
}

// DestinationConfig configures a user certificate destination.
type DestinationConfig struct {
DestinationMixin `yaml:",inline"`

Roles []string `yaml:"roles,omitempty"`
Kinds []identity.ArtifactKind `yaml:"kinds,omitempty"`
Configs []TemplateConfig `yaml:"configs,omitempty"`

Database *DatabaseConfig `yaml:"database,omitempty"`
}

// destinationDefaults applies defaults for an output sink's destination. Since
Expand All @@ -42,6 +68,12 @@ func (dc *DestinationConfig) CheckAndSetDefaults() error {
return trace.Wrap(err)
}

if dc.Database != nil {
if err := dc.Database.CheckAndSetDefaults(); err != nil {
return trace.Wrap(err)
}
}

// Note: empty roles is allowed; interpreted to mean "all" at generation
// time

Expand Down
Loading