Skip to content

Commit

Permalink
tctl: add PKI domain flag for tctl auth sign --format=windows
Browse files Browse the repository at this point in the history
This comes in handy for troubleshooting multi-domain setups.
  • Loading branch information
zmb3 committed May 14, 2024
1 parent 98d6e27 commit 43807c0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tool/tctl/common/auth_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ type AuthCommand struct {
dbUser string
windowsUser string
windowsDomain string
windowsPKIDomain string
windowsSID string
signOverwrite bool
password string
Expand Down Expand Up @@ -148,6 +149,7 @@ func (a *AuthCommand) Initialize(app *kingpin.Application, config *servicecfg.Co
a.authSign.Flag("db-name", `Database name placed on the identity file. Only used when "--db-service" is set.`).StringVar(&a.dbName)
a.authSign.Flag("windows-user", `Window user placed on the identity file. Only used when --format is set to "windows"`).StringVar(&a.windowsUser)
a.authSign.Flag("windows-domain", `Active Directory domain for which this cert is valid. Only used when --format is set to "windows"`).StringVar(&a.windowsDomain)
a.authSign.Flag("windows-pki-domain", `Active Directory domain where CRLs will be located. Only used when --format is set to "windows"`).StringVar(&a.windowsPKIDomain)
a.authSign.Flag("windows-sid", `Optional Security Identifier to embed in the certificate. Only used when --format is set to "windows"`).StringVar(&a.windowsSID)

a.authRotate = auth.Command("rotate", "Rotate certificate authorities in the cluster.")
Expand Down Expand Up @@ -340,14 +342,19 @@ func (a *AuthCommand) generateWindowsCert(ctx context.Context, clusterAPI certif
return trace.Wrap(err)
}

domain := a.windowsDomain
if a.windowsPKIDomain != "" {
domain = a.windowsPKIDomain
}

certDER, _, err := windows.GenerateWindowsDesktopCredentials(ctx, &windows.GenerateCredentialsRequest{
CAType: types.UserCA,
Username: a.windowsUser,
Domain: a.windowsDomain,
ActiveDirectorySID: a.windowsSID,
TTL: a.genTTL,
ClusterName: cn.GetClusterName(),
LDAPConfig: windows.LDAPConfig{Domain: a.windowsDomain},
LDAPConfig: windows.LDAPConfig{Domain: domain},
AuthClient: clusterAPI,
})
if err != nil {
Expand Down

0 comments on commit 43807c0

Please sign in to comment.