Skip to content

Commit

Permalink
feat: bump jwt to v5, use inbuilt Validater
Browse files Browse the repository at this point in the history
  • Loading branch information
adhocore committed Apr 13, 2024
1 parent f127ee7 commit 38c0889
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/adhocore/goic

go 1.18

require github.com/golang-jwt/jwt/v4 v4.1.0
require github.com/golang-jwt/jwt/v5 v5.2.1
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/golang-jwt/jwt/v4 v4.1.0 h1:XUgk2Ex5veyVFVeLm0xhusUTQybEbexJXrvPNOKkSY0=
github.com/golang-jwt/jwt/v4 v4.1.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
2 changes: 1 addition & 1 deletion goic.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strings"
"sync"

"github.com/golang-jwt/jwt/v4"
"github.com/golang-jwt/jwt/v5"
)

var (
Expand Down
6 changes: 3 additions & 3 deletions user.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
"strings"

"github.com/golang-jwt/jwt/v4"
"github.com/golang-jwt/jwt/v5"
)

// User represents user from well known user info endpoint
Expand Down Expand Up @@ -68,8 +68,8 @@ func (tok *Token) VerifyClaims(nonce, aud string) (err error) {
return ErrTokenNonce
}

if _, ok = claims["aud"]; ok && !claims.VerifyAudience(aud, true) {
return ErrTokenAud
if err = jwt.NewValidator().Validate(claims); err != nil {
return err
}

tok.Claims = claims // attach only if valid
Expand Down

0 comments on commit 38c0889

Please sign in to comment.