mirror of
https://forgejo.merr.is/annika/jwtauth.git
synced 2025-12-11 11:16:32 -05:00
Can this use a keyset?
This commit is contained in:
parent
a77c65043f
commit
7e7e71ba74
1 changed files with 5 additions and 2 deletions
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/lestrrat-go/jwx/v2/jwa"
|
"github.com/lestrrat-go/jwx/v2/jwa"
|
||||||
|
"github.com/lestrrat-go/jwx/v2/jwk"
|
||||||
"github.com/lestrrat-go/jwx/v2/jwt"
|
"github.com/lestrrat-go/jwx/v2/jwt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -33,7 +34,7 @@ var (
|
||||||
ErrAlgoInvalid = errors.New("algorithm mismatch")
|
ErrAlgoInvalid = errors.New("algorithm mismatch")
|
||||||
)
|
)
|
||||||
|
|
||||||
func New(alg string, signKey interface{}, verifyKey interface{}, validateOptions ...jwt.ValidateOption) *JWTAuth {
|
func New(alg string, signKey interface{}, verifyKey interface{}, jwkSet jwk.Set, validateOptions ...jwt.ValidateOption) *JWTAuth {
|
||||||
ja := &JWTAuth{
|
ja := &JWTAuth{
|
||||||
alg: jwa.SignatureAlgorithm(alg),
|
alg: jwa.SignatureAlgorithm(alg),
|
||||||
signKey: signKey,
|
signKey: signKey,
|
||||||
|
|
@ -41,7 +42,9 @@ func New(alg string, signKey interface{}, verifyKey interface{}, validateOptions
|
||||||
validateOptions: validateOptions,
|
validateOptions: validateOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ja.verifyKey != nil {
|
if jwkSet != nil {
|
||||||
|
ja.verifier = jwt.WithKeySet(jwkSet)
|
||||||
|
} else if ja.verifyKey != nil {
|
||||||
ja.verifier = jwt.WithKey(ja.alg, ja.verifyKey)
|
ja.verifier = jwt.WithKey(ja.alg, ja.verifyKey)
|
||||||
} else {
|
} else {
|
||||||
ja.verifier = jwt.WithKey(ja.alg, ja.signKey)
|
ja.verifier = jwt.WithKey(ja.alg, ja.signKey)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue