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

Add TemplateData to SSHSignRequest.

Add some omitempty tags.
Mariano Cano 6 жил өмнө
parent
commit
3b19bb9796
2 өөрчлөгдсөн 11 нэмэгдсэн , 9 устгасан
  1. 3 3
      api/sign.go
  2. 8 6
      api/ssh.go

+ 3 - 3
api/sign.go

@@ -14,9 +14,9 @@ import (
 type SignRequest struct {
 	CsrPEM       CertificateRequest `json:"csr"`
 	OTT          string             `json:"ott"`
-	NotAfter     TimeDuration       `json:"notAfter"`
-	NotBefore    TimeDuration       `json:"notBefore"`
-	TemplateData json.RawMessage    `json:"templateData"`
+	NotAfter     TimeDuration       `json:"notAfter,omitempty"`
+	NotBefore    TimeDuration       `json:"notBefore,omitempty"`
+	TemplateData json.RawMessage    `json:"templateData,omitempty"`
 }
 
 // Validate checks the fields of the SignRequest and returns nil if they are ok

+ 8 - 6
api/ssh.go

@@ -36,12 +36,13 @@ type SSHSignRequest struct {
 	PublicKey        []byte             `json:"publicKey"` // base64 encoded
 	OTT              string             `json:"ott"`
 	CertType         string             `json:"certType,omitempty"`
+	KeyID            string             `json:"keyID,omitempty"`
 	Principals       []string           `json:"principals,omitempty"`
 	ValidAfter       TimeDuration       `json:"validAfter,omitempty"`
 	ValidBefore      TimeDuration       `json:"validBefore,omitempty"`
 	AddUserPublicKey []byte             `json:"addUserPublicKey,omitempty"`
-	KeyID            string             `json:"keyID"`
 	IdentityCSR      CertificateRequest `json:"identityCSR,omitempty"`
+	TemplateData     json.RawMessage    `json:"templateData,omitempty"`
 }
 
 // Validate validates the SSHSignRequest.
@@ -275,11 +276,12 @@ func (h *caHandler) SSHSign(w http.ResponseWriter, r *http.Request) {
 	}
 
 	opts := provisioner.SignSSHOptions{
-		CertType:    body.CertType,
-		KeyID:       body.KeyID,
-		Principals:  body.Principals,
-		ValidBefore: body.ValidBefore,
-		ValidAfter:  body.ValidAfter,
+		CertType:     body.CertType,
+		KeyID:        body.KeyID,
+		Principals:   body.Principals,
+		ValidBefore:  body.ValidBefore,
+		ValidAfter:   body.ValidAfter,
+		TemplateData: body.TemplateData,
 	}
 
 	ctx := provisioner.NewContextWithMethod(r.Context(), provisioner.SSHSignMethod)