|
|
@@ -9,6 +9,7 @@ import (
|
|
|
|
|
|
"github.com/pkg/errors"
|
|
|
"github.com/smallstep/certificates/errs"
|
|
|
+ "github.com/smallstep/certificates/policy"
|
|
|
"go.step.sm/crypto/jose"
|
|
|
"go.step.sm/crypto/sshutil"
|
|
|
"go.step.sm/crypto/x509util"
|
|
|
@@ -26,15 +27,17 @@ type x5cPayload struct {
|
|
|
// signature requests.
|
|
|
type X5C struct {
|
|
|
*base
|
|
|
- ID string `json:"-"`
|
|
|
- Type string `json:"type"`
|
|
|
- Name string `json:"name"`
|
|
|
- Roots []byte `json:"roots"`
|
|
|
- Claims *Claims `json:"claims,omitempty"`
|
|
|
- Options *Options `json:"options,omitempty"`
|
|
|
- claimer *Claimer
|
|
|
- audiences Audiences
|
|
|
- rootPool *x509.CertPool
|
|
|
+ ID string `json:"-"`
|
|
|
+ Type string `json:"type"`
|
|
|
+ Name string `json:"name"`
|
|
|
+ Roots []byte `json:"roots"`
|
|
|
+ Claims *Claims `json:"claims,omitempty"`
|
|
|
+ Options *Options `json:"options,omitempty"`
|
|
|
+ claimer *Claimer
|
|
|
+ audiences Audiences
|
|
|
+ rootPool *x509.CertPool
|
|
|
+ x509Policy policy.X509NamePolicyEngine
|
|
|
+ sshPolicy policy.SSHNamePolicyEngine
|
|
|
}
|
|
|
|
|
|
// GetID returns the provisioner unique identifier. The name and credential id
|
|
|
@@ -87,7 +90,6 @@ func (p *X5C) GetEncryptedKey() (string, string, bool) {
|
|
|
|
|
|
// Init initializes and validates the fields of a X5C type.
|
|
|
func (p *X5C) Init(config Config) error {
|
|
|
- p.base = &base{} // prevent nil pointers
|
|
|
switch {
|
|
|
case p.Type == "":
|
|
|
return errors.New("provisioner type cannot be empty")
|
|
|
@@ -127,12 +129,12 @@ func (p *X5C) Init(config Config) error {
|
|
|
}
|
|
|
|
|
|
// Initialize the x509 allow/deny policy engine
|
|
|
- if p.x509PolicyEngine, err = newX509PolicyEngine(p.Options.GetX509Options()); err != nil {
|
|
|
+ if p.x509Policy, err = newX509PolicyEngine(p.Options.GetX509Options()); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
// Initialize the SSH allow/deny policy engine
|
|
|
- if p.sshPolicyEngine, err = newSSHPolicyEngine(p.Options.GetSSHOptions()); err != nil {
|
|
|
+ if p.sshPolicy, err = newSSHPolicyEngine(p.Options.GetSSHOptions()); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
@@ -240,7 +242,7 @@ func (p *X5C) AuthorizeSign(ctx context.Context, token string) ([]SignOption, er
|
|
|
defaultSANsValidator(claims.SANs),
|
|
|
defaultPublicKeyValidator{},
|
|
|
newValidityValidator(p.claimer.MinTLSCertDuration(), p.claimer.MaxTLSCertDuration()),
|
|
|
- newX509NamePolicyValidator(p.x509PolicyEngine),
|
|
|
+ newX509NamePolicyValidator(p.x509Policy),
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
@@ -324,6 +326,6 @@ func (p *X5C) AuthorizeSSHSign(ctx context.Context, token string) ([]SignOption,
|
|
|
// Require all the fields in the SSH certificate
|
|
|
&sshCertDefaultValidator{},
|
|
|
// Ensure that all principal names are allowed
|
|
|
- newSSHNamePolicyValidator(p.sshPolicyEngine),
|
|
|
+ newSSHNamePolicyValidator(p.sshPolicy),
|
|
|
), nil
|
|
|
}
|