|
@@ -18,7 +18,6 @@ import (
|
|
|
"encoding/json"
|
|
"encoding/json"
|
|
|
"errors"
|
|
"errors"
|
|
|
"fmt"
|
|
"fmt"
|
|
|
- "gopkg.in/square/go-jose.v2/jwt"
|
|
|
|
|
"io"
|
|
"io"
|
|
|
"net"
|
|
"net"
|
|
|
"net/url"
|
|
"net/url"
|
|
@@ -30,6 +29,8 @@ import (
|
|
|
"strings"
|
|
"strings"
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
|
|
+ "gopkg.in/square/go-jose.v2/jwt"
|
|
|
|
|
+
|
|
|
"github.com/fxamacker/cbor/v2"
|
|
"github.com/fxamacker/cbor/v2"
|
|
|
"github.com/google/go-tpm/legacy/tpm2"
|
|
"github.com/google/go-tpm/legacy/tpm2"
|
|
|
"github.com/smallstep/go-attestation/attest"
|
|
"github.com/smallstep/go-attestation/attest"
|
|
@@ -537,7 +538,6 @@ func wireDPOP01Validate(ctx context.Context, ch *Challenge, db DB, jwk *jose.JSO
|
|
|
return WrapErrorISE(err, "error updating challenge")
|
|
return WrapErrorISE(err, "error updating challenge")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //var access := wireChallengePayload.AccessToken
|
|
|
|
|
parsedAccessToken, err := jwt.ParseSigned(wireChallengePayload.AccessToken)
|
|
parsedAccessToken, err := jwt.ParseSigned(wireChallengePayload.AccessToken)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return WrapErrorISE(err, "Invalid access token")
|
|
return WrapErrorISE(err, "Invalid access token")
|
|
@@ -549,6 +549,29 @@ func wireDPOP01Validate(ctx context.Context, ch *Challenge, db DB, jwk *jose.JSO
|
|
|
|
|
|
|
|
ctx = context.WithValue(ctx, "access", access)
|
|
ctx = context.WithValue(ctx, "access", access)
|
|
|
|
|
|
|
|
|
|
+ rawDpop, ok := access["proof"].(string)
|
|
|
|
|
+ if !ok {
|
|
|
|
|
+ return WrapErrorISE(err, "Invalid dpop proof format in access token")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ parsedDpopToken, err := jwt.ParseSigned(rawDpop)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return WrapErrorISE(err, "Invalid DPoP token")
|
|
|
|
|
+ }
|
|
|
|
|
+ dpop := make(map[string]interface{})
|
|
|
|
|
+ if err := parsedAccessToken.UnsafeClaimsWithoutVerification(&parsedDpopToken); err != nil {
|
|
|
|
|
+ return WrapErrorISE(err, "Failed parsing dpop token")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ order, err := db.GetOrdersByAccountID(ctx, ch.AccountID)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return WrapErrorISE(err, "Could not find current order by account id")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if err := db.CreateDpop(ctx, order[0], dpop); err != nil {
|
|
|
|
|
+ return WrapErrorISE(err, "Failed storing DPoP token")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return nil
|
|
return nil
|
|
|
}
|
|
}
|
|
|
|
|
|