Ver Fonte

Add K8sSA SSH user policy back

According to the docs, the K8sSA provisioner can be configured
to issue SSH user certs.
Herman Slatman há 4 anos atrás
pai
commit
d8776d8f7f
2 ficheiros alterados com 8 adições e 2 exclusões
  1. 7 1
      authority/provisioner/k8sSA.go
  2. 1 1
      policy/options_test.go

+ 7 - 1
authority/provisioner/k8sSA.go

@@ -56,6 +56,7 @@ type K8sSA struct {
 	ctl           *Controller
 	x509Policy    policy.X509Policy
 	sshHostPolicy policy.HostPolicy
+	sshUserPolicy policy.UserPolicy
 }
 
 // GetID returns the provisioner unique identifier. The name and credential id
@@ -148,6 +149,11 @@ func (p *K8sSA) Init(config Config) (err error) {
 		return err
 	}
 
+	// Initialize the SSH allow/deny policy engine for user certificates
+	if p.sshUserPolicy, err = policy.NewSSHUserPolicyEngine(p.Options.GetSSHOptions()); err != nil {
+		return err
+	}
+
 	// Initialize the SSH allow/deny policy engine for host certificates
 	if p.sshHostPolicy, err = policy.NewSSHHostPolicyEngine(p.Options.GetSSHOptions()); err != nil {
 		return err
@@ -298,7 +304,7 @@ func (p *K8sSA) AuthorizeSSHSign(ctx context.Context, token string) ([]SignOptio
 		// Require and validate all the default fields in the SSH certificate.
 		&sshCertDefaultValidator{},
 		// Ensure that all principal names are allowed
-		newSSHNamePolicyValidator(p.sshHostPolicy, nil),
+		newSSHNamePolicyValidator(p.sshHostPolicy, p.sshUserPolicy),
 	), nil
 }
 

+ 1 - 1
policy/options_test.go

@@ -135,7 +135,7 @@ func Test_normalizeAndValidateEmailConstraint(t *testing.T) {
 		},
 		{
 			name:       "fail/idna-internationalized-domain",
-			constraint: `mail@xn--bla.local`,
+			constraint: "mail@xn--bla.local",
 			want:       "",
 			wantErr:    true,
 		},