Skip to content

Commit

Permalink
Stop using deprecated "jwt.StandardClaims".
Browse files Browse the repository at this point in the history
  • Loading branch information
fancycode committed Jul 7, 2022
1 parent 8a97fa7 commit 924fce6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion api_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (r *ProxyServerMessage) CloseAfterSend(session Session) bool {
// Type "hello"

type TokenClaims struct {
jwt.StandardClaims
jwt.RegisteredClaims
}

type HelloProxyClientMessage struct {
Expand Down
4 changes: 2 additions & 2 deletions mcu_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -951,8 +951,8 @@ func (c *mcuProxyConnection) sendHello() error {
msg.Hello.ResumeId = c.sessionId
} else {
claims := &TokenClaims{
jwt.StandardClaims{
IssuedAt: time.Now().Unix(),
jwt.RegisteredClaims{
IssuedAt: jwt.NewNumericDate(time.Now()),
Issuer: c.proxy.tokenId,
},
}
Expand Down
2 changes: 1 addition & 1 deletion proxy/proxy_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ func (s *ProxyServer) NewSession(hello *signaling.HelloProxyClientMessage) (*Pro
}

minIssuedAt := time.Now().Add(-maxTokenAge)
if issuedAt := time.Unix(claims.IssuedAt, 0); issuedAt.Before(minIssuedAt) {
if issuedAt := claims.IssuedAt; issuedAt != nil && issuedAt.Before(minIssuedAt) {
statsTokenErrorsTotal.WithLabelValues("expired").Inc()
return nil, TokenExpired
}
Expand Down
4 changes: 2 additions & 2 deletions proxy/proxy_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ func TestTokenInFuture(t *testing.T) {
server, key := newProxyServerForTest(t)

claims := &signaling.TokenClaims{
StandardClaims: jwt.StandardClaims{
IssuedAt: time.Now().Add(time.Hour).Unix(),
RegisteredClaims: jwt.RegisteredClaims{
IssuedAt: jwt.NewNumericDate(time.Now().Add(time.Hour)),
Issuer: TokenIdForTest,
},
}
Expand Down

0 comments on commit 924fce6

Please sign in to comment.