-
Notifications
You must be signed in to change notification settings - Fork 24
chore: migrate from lestrrat-go/jwx v2 (EOL) to v3 #4391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
2a85bbb
f931a5b
e1db007
765c8e6
3770cad
ee0432e
dba8853
705e5da
e687d23
ed35e89
4134403
2d0b3b8
c38aba3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,12 +23,13 @@ import ( | |
| "context" | ||
| "crypto" | ||
| "errors" | ||
| "github.com/lestrrat-go/jwx/v2/jwk" | ||
| "github.com/lestrrat-go/jwx/v2/jwt" | ||
| "github.com/lestrrat-go/jwx/v3/jwk" | ||
| "github.com/lestrrat-go/jwx/v3/jwt" | ||
| "github.com/nuts-foundation/go-did/did" | ||
| "github.com/nuts-foundation/nuts-node/auth" | ||
| "github.com/nuts-foundation/nuts-node/auth/oauth" | ||
| cryptoNuts "github.com/nuts-foundation/nuts-node/crypto" | ||
| "github.com/nuts-foundation/nuts-node/crypto/jwx" | ||
| "github.com/nuts-foundation/nuts-node/vdr/resolver" | ||
| "net/url" | ||
| "time" | ||
|
|
@@ -183,7 +184,7 @@ func (j jar) validate(ctx context.Context, rawToken string, clientId string) (oa | |
| if err != nil { | ||
| return nil, oauth.OAuth2Error{Code: oauth.InvalidRequestObject, Description: "request signature validation failed", InternalError: err} | ||
| } | ||
| claimsAsMap, err := token.AsMap(ctx) | ||
| claimsAsMap, err := jwx.AsMap(token) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The audience check in
The existing unit test doesn't catch this because it puts |
||
| if err != nil { | ||
| // very unlikely | ||
| return nil, oauth.OAuth2Error{Code: oauth.InvalidRequestObject, Description: "invalid request parameter", InternalError: err} | ||
|
|
@@ -213,7 +214,7 @@ func compareThumbprint(configurationKey jwk.Key, publicKey crypto.PublicKey) err | |
| if err != nil { | ||
| return err | ||
| } | ||
| signerKey, err := jwk.FromRaw(publicKey) | ||
| signerKey, err := jwk.Import(publicKey) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| * Copyright (C) 2024 Nuts community | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| package iam | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestOauthParameters_get(t *testing.T) { | ||
| params := oauthParameters{ | ||
| "string": "value", | ||
| "stringSlice": []string{"value"}, | ||
| "interfaceSlice": []interface{}{"value"}, | ||
| "multiSlice": []interface{}{"a", "b"}, | ||
| "nonStringSlice": []interface{}{1}, | ||
| "number": 1, | ||
| } | ||
| assert.Equal(t, "value", params.get("string")) | ||
| assert.Equal(t, "value", params.get("stringSlice")) | ||
| // JWT claims decoded from JSON (e.g. the "aud" claim via jwx.AsMap) arrive as []interface{}. | ||
| assert.Equal(t, "value", params.get("interfaceSlice")) | ||
| assert.Empty(t, params.get("multiSlice")) | ||
| assert.Empty(t, params.get("nonStringSlice")) | ||
| assert.Empty(t, params.get("number")) | ||
| assert.Empty(t, params.get("absent")) | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.