mirror of
https://github.com/pocketbase/pocketbase.git
synced 2026-11-03 18:47:25 +01:00
added eager alg error check to minimize misuse
This commit is contained in:
1 parent
db88253aac
commit
d153553d52
2 files changed
+8
-2
No files matched your search
@@ -114,12 +114,12 @@ func Fetch(ctx context.Context, jwksURL string, kid string) (*JWK, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, key := range jwks.Keys {
|
for _, key := range jwks.Keys {
|
||||||
if key.Kid == kid {
|
if key.Kid == kid && key.Alg != "" {
|
||||||
return key, nil
|
return key, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, fmt.Errorf("JWK with kid %q was not found", kid)
|
return nil, fmt.Errorf("missing JWK with kid %q and non-empty alg", kid)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateTokenSignature validates the signature of a token with the
|
// ValidateTokenSignature validates the signature of a token with the
|
||||||
|
|||||||
@@ -168,6 +168,12 @@ func TestFetch(t *testing.T) {
|
|||||||
true,
|
true,
|
||||||
nil,
|
nil,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"matching kid (no alg)",
|
||||||
|
"abc",
|
||||||
|
true,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"matching kid",
|
"matching kid",
|
||||||
"def",
|
"def",
|
||||||
|
|||||||
Reference in new issue
Block a user