4
0
Эх сурвалжийг харах

add linkedca support for EST

need for db migration and authority startup

use replace in go.mod to use a linkedca version compatible (need for the build)
Jean-Baptiste Pin 8 сар өмнө
parent
commit
955a9c52e5

+ 2 - 0
authority/admin/db.go

@@ -46,6 +46,8 @@ func UnmarshalProvisionerDetails(typ linkedca.Provisioner_Type, data []byte) (*l
 		v.Data = new(linkedca.ProvisionerDetails_SCEP)
 	case linkedca.Provisioner_NEBULA:
 		v.Data = new(linkedca.ProvisionerDetails_Nebula)
+	case linkedca.Provisioner_EST:
+		v.Data = new(linkedca.ProvisionerDetails_EST)
 	default:
 		return nil, fmt.Errorf("unsupported provisioner type %s", typ)
 	}

+ 21 - 22
authority/provisioner/est.go

@@ -16,28 +16,27 @@ import (
 // EST is the EST provisioner type, an entity that can authorize the EST flow.
 type EST struct {
 	*base
-	ID                                 string   `json:"-"`
-	Type                               string   `json:"type"`
-	Name                               string   `json:"name"`
-	EnableTLSClientCertificate         *bool    `json:"enableTLSClientCertificate,omitempty"`
-	EnableHTTPBasicAuth                *bool    `json:"enableHTTPBasicAuth,omitempty"`
-	BasicAuthUsername                  string   `json:"basicAuthUsername,omitempty"`
-	BasicAuthPassword                  string   `json:"basicAuthPassword,omitempty"`
-	ClientCertificateRoots             []byte   `json:"clientCertificateRoots,omitempty"`
-	ForceCN                            bool     `json:"forceCN,omitempty"`
-	Capabilities                       []string `json:"capabilities,omitempty"`
-	IncludeRoot                        bool     `json:"includeRoot,omitempty"`
-	ExcludeIntermediate                bool     `json:"excludeIntermediate,omitempty"`
-	MinimumPublicKeyLength             int      `json:"minimumPublicKeyLength,omitempty"`
-	CSRAttrs                           []byte   `json:"csrAttrs,omitempty"`
-	Options                            *Options `json:"options,omitempty"`
-	Claims                             *Claims  `json:"claims,omitempty"`
-	ctl                                *Controller
-	signer                             crypto.Signer
-	signerCertificate                  *x509.Certificate
-	challengeValidationController      *challengeValidationController
-	notificationController             *notificationController
-	clientCertificateRootPool          *x509.CertPool
+	ID                            string   `json:"-"`
+	Type                          string   `json:"type"`
+	Name                          string   `json:"name"`
+	EnableTLSClientCertificate    *bool    `json:"enableTLSClientCertificate,omitempty"`
+	EnableHTTPBasicAuth           *bool    `json:"enableHTTPBasicAuth,omitempty"`
+	BasicAuthUsername             string   `json:"basicAuthUsername,omitempty"`
+	BasicAuthPassword             string   `json:"basicAuthPassword,omitempty"`
+	ClientCertificateRoots        []byte   `json:"clientCertificateRoots,omitempty"`
+	ForceCN                       bool     `json:"forceCN,omitempty"`
+	IncludeRoot                   bool     `json:"includeRoot,omitempty"`
+	ExcludeIntermediate           bool     `json:"excludeIntermediate,omitempty"`
+	MinimumPublicKeyLength        int      `json:"minimumPublicKeyLength,omitempty"`
+	CSRAttrs                      []byte   `json:"csrAttrs,omitempty"`
+	Options                       *Options `json:"options,omitempty"`
+	Claims                        *Claims  `json:"claims,omitempty"`
+	ctl                           *Controller
+	signer                        crypto.Signer
+	signerCertificate             *x509.Certificate
+	challengeValidationController *challengeValidationController
+	notificationController        *notificationController
+	clientCertificateRootPool     *x509.CertPool
 }
 
 // GetID returns the provisioner unique identifier.

+ 47 - 0
authority/provisioners.go

@@ -1004,6 +1004,25 @@ func ProvisionerToCertificates(p *linkedca.Provisioner) (provisioner.Interface,
 			s.DecrypterKeyPassword = string(decrypter.KeyPassword)
 		}
 		return s, nil
+	case *linkedca.ProvisionerDetails_EST:
+		cfg := d.EST
+		enableTLSClientCertificate := cfg.EnableTlsClientCertificate
+		enableHTTPBasicAuth := cfg.EnableHttpBasicAuth
+		return &provisioner.EST{
+			ID:                         p.Id,
+			Type:                       p.Type.String(),
+			Name:                       p.Name,
+			EnableTLSClientCertificate: &enableTLSClientCertificate,
+			EnableHTTPBasicAuth:        &enableHTTPBasicAuth,
+			BasicAuthUsername:          cfg.BasicAuthUsername,
+			BasicAuthPassword:          cfg.BasicAuthPassword,
+			ClientCertificateRoots:     provisionerPEMToCertificates(cfg.ClientCertificateRoots),
+			ForceCN:                    cfg.ForceCn,
+			IncludeRoot:                cfg.IncludeRoot,
+			MinimumPublicKeyLength:     int(cfg.MinimumPublicKeyLength),
+			Claims:                     claims,
+			Options:                    options,
+		}, nil
 	case *linkedca.ProvisionerDetails_Nebula:
 		var roots []byte
 		for i, root := range d.Nebula.GetRoots() {
@@ -1279,6 +1298,34 @@ func ProvisionerToLinkedca(p provisioner.Interface) (*linkedca.Provisioner, erro
 			SshTemplate:  sshTemplate,
 			Webhooks:     webhooks,
 		}, nil
+	case *provisioner.EST:
+		x509Template, sshTemplate, webhooks, err := provisionerOptionsToLinkedca(p.Options)
+		if err != nil {
+			return nil, err
+		}
+		return &linkedca.Provisioner{
+			Id:   p.ID,
+			Type: linkedca.Provisioner_EST,
+			Name: p.GetName(),
+			Details: &linkedca.ProvisionerDetails{
+				Data: &linkedca.ProvisionerDetails_EST{
+					EST: &linkedca.ESTProvisioner{
+						ForceCn:                    p.ForceCN,
+						EnableTlsClientCertificate: p.EnableTLSClientCertificate != nil && *p.EnableTLSClientCertificate,
+						EnableHttpBasicAuth:         p.EnableHTTPBasicAuth != nil && *p.EnableHTTPBasicAuth,
+						MinimumPublicKeyLength:      cast.Int32(p.MinimumPublicKeyLength),
+						IncludeRoot:                 p.IncludeRoot,
+						BasicAuthUsername:           p.BasicAuthUsername,
+						BasicAuthPassword:           p.BasicAuthPassword,
+						ClientCertificateRoots:      provisionerPEMToLinkedca(p.ClientCertificateRoots),
+					},
+				},
+			},
+			Claims:       claimsToLinkedca(p.Claims),
+			X509Template: x509Template,
+			SshTemplate:  sshTemplate,
+			Webhooks:     webhooks,
+		}, nil
 	case *provisioner.Nebula:
 		x509Template, sshTemplate, webhooks, err := provisionerOptionsToLinkedca(p.Options)
 		if err != nil {

+ 2 - 0
go.mod

@@ -173,3 +173,5 @@ require (
 	google.golang.org/genproto/googleapis/rpc v0.0.0-20260803160001-6ac0973c030d // indirect
 	google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.2 // indirect
 )
+
+replace github.com/smallstep/linkedca => github.com/jbpin/linkedca v0.0.0-20251224103807-5e7deb3d4d49

+ 2 - 2
go.sum

@@ -261,6 +261,8 @@ github.com/jackc/pgx/v5 v5.9.2 h1:3ZhOzMWnR4yJ+RW1XImIPsD1aNSz4T4fyP7zlQb56hw=
 github.com/jackc/pgx/v5 v5.9.2/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
 github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
 github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
+github.com/jbpin/linkedca v0.0.0-20251224103807-5e7deb3d4d49 h1:rFx5O4hmVJ3fQ90n1PP8fjBWIQoSuBSqbdts6UfnaVk=
+github.com/jbpin/linkedca v0.0.0-20251224103807-5e7deb3d4d49/go.mod h1:bUm0HgkgtOjbnwShtNKu3XPuQ6AA/o680sxTfy9vdYk=
 github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
 github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
 github.com/jmespath/go-jmespath v0.4.1-0.20220621161143-b0104c826a24 h1:liMMTbpW34dhU4az1GN0pTPADwNmvoRSeoZ6PItiqnY=
@@ -360,8 +362,6 @@ github.com/smallstep/cli-utils v0.12.2 h1:lGzM9PJrH/qawbzMC/s2SvgLdJPKDWKwKzx9do
 github.com/smallstep/cli-utils v0.12.2/go.mod h1:uCPqefO29goHLGqFnwk0i8W7XJu18X3WHQFRtOm/00Y=
 github.com/smallstep/go-attestation v0.4.4-0.20260814222900-a849f4e2cd68 h1:KcK2guFXrE5sX/nvF1b+atHP6DjRB1gCv3ppyTXB2Zk=
 github.com/smallstep/go-attestation v0.4.4-0.20260814222900-a849f4e2cd68/go.mod h1:vNAduivU014fubg6ewygkAvQC0IQVXqdc8vaGl/0er4=
-github.com/smallstep/linkedca v0.26.0 h1:NsxTVo3zI3KwOFFiVodeHtuGgKq0b5kOUXVLjjNTvXY=
-github.com/smallstep/linkedca v0.26.0/go.mod h1:Z8c7EgVrSHNhshIhRnUGfKfE796+TwF2eyErhqANmJQ=
 github.com/smallstep/nosql v0.8.0 h1:FBTCUfKPmWYbrozW+RBKu+fnvbn+zr5rVli/XB4Jp4A=
 github.com/smallstep/nosql v0.8.0/go.mod h1:5dUpNotHLHhOUapP0PLBVVfp3tG1DFC31VRccg+Cqwo=
 github.com/smallstep/pkcs7 v0.2.1/go.mod h1:RcXHsMfL+BzH8tRhmrF1NkkpebKpq3JEM66cOFxanf0=