Quellcode durchsuchen

Replace field access by accessor functions

Stefan Berthold vor 3 Jahren
Ursprung
Commit
83ba0bdc51

+ 4 - 10
acme/api/order.go

@@ -5,7 +5,6 @@ import (
 	"context"
 	"crypto/x509"
 	"encoding/base64"
-	"encoding/hex"
 	"encoding/json"
 	"net"
 	"net/http"
@@ -275,7 +274,7 @@ func newAuthorization(ctx context.Context, az *acme.Authorization) error {
 			continue
 		}
 
-		var target = ""
+		var target string
 		switch az.Identifier.Type {
 		case acme.WireID:
 			wireId, err := wire.ParseID([]byte(az.Identifier.Value))
@@ -286,18 +285,13 @@ func newAuthorization(ctx context.Context, az *acme.Authorization) error {
 			}
 			clientID := wireId.ClientID
 			deviceId := strings.Split(strings.Split(clientID, "@")[0], "/")[1]
-			decoded, err := hex.DecodeString(deviceId)
-			if err != nil {
-				return acme.NewError(acme.ErrorMalformedType, "DeviceId is not hexadecimal")
-			}
-			_ = decoded
 
-			var targetTemplate = ""
+			var targetTemplate string
 			switch typ {
 			case acme.WIREOIDC01:
-				targetTemplate = prov.GetOptions().GetOIDCOptions().Provider.IssuerURL
+				targetTemplate = prov.GetOptions().GetOIDCOptions().GetProviderIssuerURL()
 			case acme.WIREDPOP01:
-				targetTemplate = prov.GetOptions().GetDPOPOptions().DpopTarget
+				targetTemplate = prov.GetOptions().GetDPOPOptions().GetDPOPTarget()
 			default:
 			}
 

+ 1 - 1
acme/challenge.go

@@ -471,7 +471,7 @@ func wireDPOP01Validate(ctx context.Context, ch *Challenge, db DB, jwk *jose.JSO
 		return WrapErrorISE(err, "error unmarshalling challenge data")
 	}
 
-	issuer := dpopOptions.DpopTarget
+	issuer := dpopOptions.GetDPOPTarget()
 
 	expiry := strconv.FormatInt(time.Now().Add(time.Hour*24*365).Unix(), 10)
 	cmd := exec.CommandContext(

+ 7 - 0
authority/provisioner/dpop_options.go

@@ -23,3 +23,10 @@ func (o *DPOPOptions) GetSigningKey() string {
 	}
 	return o.SigningKey
 }
+
+func (o *DPOPOptions) GetDPOPTarget() string {
+	if o == nil {
+		return ""
+	}
+	return o.DpopTarget
+}

+ 7 - 0
authority/provisioner/oidc_options.go

@@ -38,6 +38,13 @@ func (o *OIDCOptions) GetProvider(ctx context.Context) *oidc.Provider {
 	return toProviderConfig(o.Provider).NewProvider(ctx)
 }
 
+func (o *OIDCOptions) GetProviderIssuerURL() string {
+	if o == nil {
+		return ""
+	}
+	return o.Provider.IssuerURL
+}
+
 func (o *OIDCOptions) GetConfig() *oidc.Config {
 	if o == nil {
 		return &oidc.Config{}