Merge pull request #289 from strukturag/jwt-v4

Update to Go module version of github.com/golang-jwt/jwt
This commit is contained in:
Joachim Bauch 2022-07-07 17:16:53 +02:00 committed by GitHub
commit a9517feebb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 15 additions and 15 deletions

View file

@ -25,7 +25,7 @@ import (
"encoding/json"
"fmt"
"github.com/golang-jwt/jwt"
"github.com/golang-jwt/jwt/v4"
)
type ProxyClientMessage struct {
@ -127,7 +127,7 @@ func (r *ProxyServerMessage) CloseAfterSend(session Session) bool {
// Type "hello"
type TokenClaims struct {
jwt.StandardClaims
jwt.RegisteredClaims
}
type HelloProxyClientMessage struct {

2
go.mod
View file

@ -4,7 +4,7 @@ go 1.17
require (
github.com/dlintw/goconf v0.0.0-20120228082610-dcc070983490
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/golang-jwt/jwt/v4 v4.4.2
github.com/google/uuid v1.3.0
github.com/gorilla/mux v1.8.0
github.com/gorilla/securecookie v1.1.1

4
go.sum
View file

@ -130,8 +130,8 @@ github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zV
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs=
github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=

View file

@ -41,7 +41,7 @@ import (
"time"
"github.com/dlintw/goconf"
"github.com/golang-jwt/jwt"
"github.com/golang-jwt/jwt/v4"
"github.com/gorilla/websocket"
clientv3 "go.etcd.io/etcd/client/v3"
@ -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,
},
}

View file

@ -39,7 +39,7 @@ import (
"time"
"github.com/dlintw/goconf"
"github.com/golang-jwt/jwt"
"github.com/golang-jwt/jwt/v4"
"github.com/google/uuid"
"github.com/gorilla/mux"
"github.com/gorilla/securecookie"
@ -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
}

View file

@ -31,7 +31,7 @@ import (
"time"
"github.com/dlintw/goconf"
"github.com/golang-jwt/jwt"
"github.com/golang-jwt/jwt/v4"
"github.com/gorilla/mux"
signaling "github.com/strukturag/nextcloud-spreed-signaling"
)
@ -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,
},
}

View file

@ -31,7 +31,7 @@ import (
"time"
"github.com/dlintw/goconf"
"github.com/golang-jwt/jwt"
"github.com/golang-jwt/jwt/v4"
signaling "github.com/strukturag/nextcloud-spreed-signaling"
)

View file

@ -29,7 +29,7 @@ import (
"sync/atomic"
"github.com/dlintw/goconf"
"github.com/golang-jwt/jwt"
"github.com/golang-jwt/jwt/v4"
)
type tokensStatic struct {