55 "strings"
66 "time"
77
8- "github.com/golang-jwt/jwt"
8+ "github.com/golang-jwt/jwt/v5 "
99)
1010
1111// Session stores a User and their OIDC options across requests
@@ -29,7 +29,7 @@ type SessionStore struct {
2929// should use in their jwt.Claims building.
3030type IDTokenClaims struct {
3131 Nonce string `json:"nonce,omitempty"`
32- * jwt.StandardClaims
32+ * jwt.RegisteredClaims
3333}
3434
3535// NewSessionStore initializes the SessionStore for this server
@@ -84,23 +84,23 @@ func (ss *SessionStore) GetSessionByToken(token *jwt.Token) (*Session, error) {
8484// AccessToken returns the JWT token with the appropriate claims for
8585// an access token
8686func (s * Session ) AccessToken (config * Config , kp * Keypair , now time.Time ) (string , error ) {
87- claims := s .standardClaims (config , config .AccessTTL , now )
87+ claims := s .registeredClaims (config , config .AccessTTL , now )
8888 return kp .SignJWT (claims )
8989}
9090
9191// RefreshToken returns the JWT token with the appropriate claims for
9292// a refresh token
9393func (s * Session ) RefreshToken (config * Config , kp * Keypair , now time.Time ) (string , error ) {
94- claims := s .standardClaims (config , config .RefreshTTL , now )
94+ claims := s .registeredClaims (config , config .RefreshTTL , now )
9595 return kp .SignJWT (claims )
9696}
9797
9898// IDToken returns the JWT token with the appropriate claims for a user
9999// based on the scopes set.
100100func (s * Session ) IDToken (config * Config , kp * Keypair , now time.Time ) (string , error ) {
101101 base := & IDTokenClaims {
102- StandardClaims : s .standardClaims (config , config .AccessTTL , now ),
103- Nonce : s .OIDCNonce ,
102+ RegisteredClaims : s .registeredClaims (config , config .AccessTTL , now ),
103+ Nonce : s .OIDCNonce ,
104104 }
105105 claims , err := s .User .Claims (s .Scopes , base )
106106 if err != nil {
@@ -110,14 +110,14 @@ func (s *Session) IDToken(config *Config, kp *Keypair, now time.Time) (string, e
110110 return kp .SignJWT (claims )
111111}
112112
113- func (s * Session ) standardClaims (config * Config , ttl time.Duration , now time.Time ) * jwt.StandardClaims {
114- return & jwt.StandardClaims {
115- Audience : config .ClientID ,
116- ExpiresAt : now .Add (ttl ). Unix ( ),
117- Id : s .SessionID ,
118- IssuedAt : now . Unix ( ),
113+ func (s * Session ) registeredClaims (config * Config , ttl time.Duration , now time.Time ) * jwt.RegisteredClaims {
114+ return & jwt.RegisteredClaims {
115+ Audience : jwt. ClaimStrings { config .ClientID } ,
116+ ExpiresAt : jwt . NewNumericDate ( now .Add (ttl )),
117+ ID : s .SessionID ,
118+ IssuedAt : jwt . NewNumericDate ( now ),
119119 Issuer : config .Issuer ,
120- NotBefore : now . Unix ( ),
120+ NotBefore : jwt . NewNumericDate ( now ),
121121 Subject : s .User .ID (),
122122 }
123123}
0 commit comments