Skip to content
Draft
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
2 changes: 1 addition & 1 deletion command/ca/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ multiple SANs. The '--san' flag and the '--token' flag are mutually exclusive.`,
},
flags.TemplateSet,
flags.TemplateSetFile,
flags.CaConfig,
flags.CaConfig(),
flags.CaURL,
flags.Root,
flags.Token,
Expand Down
2 changes: 1 addition & 1 deletion command/ca/provisioner/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ SCEP
flags.CaURL,
flags.Root,
flags.Context,
flags.CaConfig,
flags.CaConfig(),
},
Description: `**step ca provisioner add** adds a provisioner to the CA configuration.

Expand Down
2 changes: 1 addition & 1 deletion command/ca/provisioner/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func removeCommand() cli.Command {
flags.CaURL,
flags.Root,
flags.Context,
flags.CaConfig,
flags.CaConfig(),
},
Description: `**step ca provisioner remove** removes a provisioner from the CA configuration.

Expand Down
2 changes: 1 addition & 1 deletion command/ca/provisioner/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ SCEP
flags.CaURL,
flags.Root,
flags.Context,
flags.CaConfig,
flags.CaConfig(),
},
Description: `**step ca provisioner update** updates a provisioner in the CA configuration.

Expand Down
2 changes: 1 addition & 1 deletion command/ca/provisioner/webhook/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func addCommand() cli.Command {
flags.CaURL,
flags.Root,
flags.Context,
flags.CaConfig,
flags.CaConfig(),
},
Description: `**step ca provisioner webhook add** adds a webhook to a provisioner.

Expand Down
2 changes: 1 addition & 1 deletion command/ca/provisioner/webhook/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func removeCommand() cli.Command {
flags.CaURL,
flags.Root,
flags.Context,
flags.CaConfig,
flags.CaConfig(),
},
Description: `**step ca provisioner webhook remove** removes a webhook from a provisioner.

Expand Down
2 changes: 1 addition & 1 deletion command/ca/provisioner/webhook/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func updateCommand() cli.Command {
flags.CaURL,
flags.Root,
flags.Context,
flags.CaConfig,
flags.CaConfig(),
},
Description: `**step ca provisioner webhook update** updates a webhook attached to a provisioner.

Expand Down
2 changes: 1 addition & 1 deletion command/ca/rekey.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".`,
flags.PasswordFile,
flags.Root,
flags.CaURL,
flags.CaConfig,
flags.CaConfig(),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion command/ca/renew.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ $ step ca renew --offline internal.crt internal.key
Usage: `Use mTLS to renew a certificate. Use --mtls=false to force the token
authorization flow instead.`,
},
flags.CaConfig,
flags.CaConfig(),
flags.Force,
flags.Offline,
flags.PasswordFile,
Expand Down
2 changes: 1 addition & 1 deletion command/ca/revoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ attribute certificate have been compromised (reasonCode=10).
`,
},
flags.Token,
flags.CaConfig,
flags.CaConfig(),
flags.Offline,
flags.CaURL,
flags.Root,
Expand Down
2 changes: 1 addition & 1 deletion command/ca/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ $ step ca sign foo.csr foo.crt \
acmeContactFlag,
acmeHTTPListenFlag,
flags.K8sSATokenPathFlag,
flags.CaConfig,
flags.CaConfig(),
flags.CaURL,
flags.Root,
flags.Context,
Expand Down
2 changes: 1 addition & 1 deletion command/ca/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ extra names. Use the '--principal' flag multiple times to configure
multiple principals.`,
},
sshHostFlag,
flags.CaConfig,
flags.CaConfig(),
flags.Force,
cli.StringFlag{
Name: "not-before",
Expand Down
2 changes: 1 addition & 1 deletion command/ssh/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ $ step ssh certificate --kty OKP --curve Ed25519 mariano@work id_ed25519
Usage: "Set minimum required length for password used to encrypt private key. The default value is '0'. Values <=0 are interpreted as if no minimum value is set.",
Value: 0,
},
flags.CaConfig,
flags.CaConfig(),
flags.CaURL,
flags.Root,
flags.Context,
Expand Down
2 changes: 1 addition & 1 deletion command/ssh/checkHost.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ $ step ssh check-host internal.smallstep.com
Name: "verbose, v",
Usage: `Return "true" or "false" in the terminal.`,
},
flags.CaConfig,
flags.CaConfig(),
flags.Offline,
flags.CaURL,
flags.Root,
Expand Down
2 changes: 1 addition & 1 deletion command/ssh/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ times to set multiple variables.`,
flags.Console,
flags.DryRun,
flags.Force,
flags.CaConfig,
flags.CaConfig(),
flags.CaURL,
flags.Root,
flags.Offline,
Expand Down
2 changes: 1 addition & 1 deletion command/ssh/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ $ step ssh hosts
flags.TemplateSetFile,
flags.Console,
flags.Offline,
flags.CaConfig,
flags.CaConfig(),
flags.CaURL,
flags.Root,
flags.Context,
Expand Down
2 changes: 1 addition & 1 deletion command/ssh/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ $ step ssh certificate --kty OKP --curve Ed25519 mariano@work id_ed25519
flags.Console,
flags.Force,
flags.Offline,
flags.CaConfig,
flags.CaConfig(),
flags.CaURL,
flags.Root,
flags.Context,
Expand Down
2 changes: 1 addition & 1 deletion command/ssh/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ $ step ssh logout --all
},
flags.Identity,
flags.Offline,
flags.CaConfig,
flags.CaConfig(),
flags.CaURL,
flags.Root,
flags.Context,
Expand Down
2 changes: 1 addition & 1 deletion command/ssh/proxycommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ This command will add the user to the ssh-agent if necessary.
flags.TemplateSetFile,
flags.Console,
flags.Offline,
flags.CaConfig,
flags.CaConfig(),
flags.CaURL,
flags.Root,
flags.Context,
Expand Down
2 changes: 1 addition & 1 deletion command/ssh/rekey.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ $ step ssh rekey --out id2_ecdsa id_ecdsa-cert.pub id_ecdsa
flags.SSHPOPCert,
flags.SSHPOPKey,
flags.Offline,
flags.CaConfig,
flags.CaConfig(),
flags.CaURL,
flags.Root,
flags.Context,
Expand Down
2 changes: 1 addition & 1 deletion command/ssh/renew.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ $ step ssh renew -out new-id_ecdsa-cer.pub id_ecdsa-cert.pub id_ecdsa
flags.SSHPOPKey,
flags.Force,
flags.Offline,
flags.CaConfig,
flags.CaConfig(),
flags.CaURL,
flags.Root,
flags.Context,
Expand Down
2 changes: 1 addition & 1 deletion command/ssh/revoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ attribute certificate have been compromised (reasonCode=10).
`,
},
flags.Offline,
flags.CaConfig,
flags.CaConfig(),
flags.CaURL,
flags.Root,
flags.Context,
Expand Down
26 changes: 19 additions & 7 deletions flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,11 @@ uses the configuration, certificates, and keys created with **step ca init**,
but can accept a different configuration file using **--ca-config** flag.`,
}

// CaConfig is a cli.Flag used to pass the CA configuration file.
CaConfig = cli.StringFlag{
Name: "ca-config",
Usage: `The certificate authority configuration <file>. Defaults to
$(step path)/config/ca.json`,
Value: filepath.Join(step.Path(), "config", "ca.json"),
}
// CaConfig is now a function (see the CaConfig func below). Defining it as a
// package var made its default value call step.Path() at package
// initialization, which caches the step configuration path from $HOME before
// a program has a chance to set STEPPATH (e.g. an SSH/PAM session hook where
// PAM exports the target user's HOME). Resolving it lazily fixes that.

// AdminCert is a cli.Flag used to pass the x5c header certificate for a JWT.
AdminCert = cli.StringFlag{
Expand Down Expand Up @@ -728,3 +726,17 @@ func FirstStringOf(ctx *cli.Context, flags ...string) (string, string) {

return "", name
}

// CaConfig returns the --ca-config flag. It is a function rather than a package
// var so its default value, which calls step.Path(), is resolved when the
// command is constructed instead of at package initialization. As a var,
// importing this package would call step.Path() at load time and cache the
// step configuration path from $HOME before a program could set STEPPATH.
func CaConfig() cli.Flag {
return cli.StringFlag{
Name: "ca-config",
Usage: `The certificate authority configuration <file>. Defaults to
$(step path)/config/ca.json`,
Value: filepath.Join(step.Path(), "config", "ca.json"),
}
}
Loading