Jelajahi Sumber

Move type to the first position of the struct.

Mariano Cano 7 tahun lalu
induk
melakukan
0b4cde1ad3
2 mengubah file dengan 7 tambahan dan 7 penghapusan
  1. 5 7
      authority/provisioner/jwk.go
  2. 2 0
      authority/provisioner/oidc.go

+ 5 - 7
authority/provisioner/jwk.go

@@ -18,9 +18,9 @@ type jwtPayload struct {
 // JWK is the default provisioner, an entity that can sign tokens necessary for
 // signature requests.
 type JWK struct {
-	Name         string           `json:"name,omitempty"`
-	Type         string           `json:"type,omitempty"`
-	Key          *jose.JSONWebKey `json:"key,omitempty"`
+	Type         string           `json:"type"`
+	Name         string           `json:"name"`
+	Key          *jose.JSONWebKey `json:"key"`
 	EncryptedKey string           `json:"encryptedKey,omitempty"`
 	Claims       *Claims          `json:"claims,omitempty"`
 	audiences    []string
@@ -50,12 +50,10 @@ func (p *JWK) GetEncryptedKey() (string, string, bool) {
 // Init initializes and validates the fields of a JWK type.
 func (p *JWK) Init(config Config) (err error) {
 	switch {
-	case p.Name == "":
-		return errors.New("provisioner name cannot be empty")
-
 	case p.Type == "":
 		return errors.New("provisioner type cannot be empty")
-
+	case p.Name == "":
+		return errors.New("provisioner name cannot be empty")
 	case p.Key == nil:
 		return errors.New("provisioner key cannot be empty")
 	}

+ 2 - 0
authority/provisioner/oidc.go

@@ -87,6 +87,8 @@ func (o *OIDC) GetEncryptedKey() (kid string, key string, ok bool) {
 // Init validates and initializes the OIDC provider.
 func (o *OIDC) Init(config Config) (err error) {
 	switch {
+	case o.Type == "":
+		return errors.New("type cannot be empty")
 	case o.Name == "":
 		return errors.New("name cannot be empty")
 	case o.ClientID == "":