9
9
"fmt"
10
10
"reflect"
11
11
12
- "github.com/go-jose/go-jose/v3 "
13
- "github.com/go-jose/go-jose/v3 /jwt"
12
+ "github.com/go-jose/go-jose/v4 "
13
+ "github.com/go-jose/go-jose/v4 /jwt"
14
14
15
15
"github.com/ory/x/errorsx"
16
16
)
@@ -37,6 +37,12 @@ const (
37
37
JWTHeaderTypeValue = "JWT"
38
38
)
39
39
40
+ var SupportedSignatureAlgorithms = []jose.SignatureAlgorithm {
41
+ SigningMethodNone ,
42
+ jose .EdDSA , jose .HS256 , jose .HS384 , jose .HS512 , jose .RS256 , jose .RS384 ,
43
+ jose .RS512 , jose .ES256 , jose .ES384 , jose .ES512 , jose .PS256 , jose .PS384 , jose .PS512 ,
44
+ }
45
+
40
46
type unsafeNoneMagicConstant string
41
47
42
48
// Valid informs if the token was verified against a given verification key
@@ -96,10 +102,10 @@ func (t *Token) SignedString(k interface{}) (rawToken string, err error) {
96
102
97
103
// A explicit conversion from type alias MapClaims
98
104
// to map[string]interface{} is required because the
99
- // go-jose CompactSerialize () only support explicit maps
105
+ // go-jose Serialize () only support explicit maps
100
106
// as claims or structs but not type aliases from maps.
101
107
claims := map [string ]interface {}(t .Claims )
102
- rawToken , err = jwt .Signed (signer ).Claims (claims ).CompactSerialize ()
108
+ rawToken , err = jwt .Signed (signer ).Claims (claims ).Serialize ()
103
109
if err != nil {
104
110
err = & ValidationError {Errors : ValidationErrorClaimsInvalid , Inner : err }
105
111
return
@@ -163,7 +169,7 @@ func Parse(tokenString string, keyFunc Keyfunc) (*Token, error) {
163
169
// If everything is kosher, err will be nil
164
170
func ParseWithClaims (rawToken string , claims MapClaims , keyFunc Keyfunc ) (* Token , error ) {
165
171
// Parse the token.
166
- parsedToken , err := jwt .ParseSigned (rawToken )
172
+ parsedToken , err := jwt .ParseSigned (rawToken , SupportedSignatureAlgorithms )
167
173
if err != nil {
168
174
return & Token {}, & ValidationError {Errors : ValidationErrorMalformed , text : err .Error ()}
169
175
}
0 commit comments