@@ -18,7 +18,9 @@ import (
1818 "testing"
1919 "time"
2020
21+ "github.com/go-jose/go-jose/v3"
2122 "github.com/go-jose/go-jose/v3/json"
23+ "github.com/go-jose/go-jose/v3/jwt"
2224 "github.com/stretchr/testify/require"
2325
2426 "github.com/livekit/protocol/auth"
@@ -95,6 +97,42 @@ func TestVerifier(t *testing.T) {
9597 require .EqualValues (t , attrs , decoded .Attributes )
9698 })
9799
100+ t .Run ("unknown roomConfig fields are ignored for forward compatibility" , func (t * testing.T ) {
101+ // Simulate a token issued by a newer client whose RoomConfiguration includes
102+ // a field this server's proto does not yet know about. The server should
103+ // still accept the token rather than failing with `unknown field`.
104+ sig , err := jose .NewSigner (
105+ jose.SigningKey {Algorithm : jose .HS256 , Key : []byte (secret )},
106+ (& jose.SignerOptions {}).WithType ("JWT" ),
107+ )
108+ require .NoError (t , err )
109+
110+ claims := map [string ]interface {}{
111+ "iss" : apiKey ,
112+ "sub" : "me" ,
113+ "nbf" : jwt .NewNumericDate (time .Now ()),
114+ "exp" : jwt .NewNumericDate (time .Now ().Add (time .Minute )),
115+ "video" : map [string ]interface {}{
116+ "roomJoin" : true ,
117+ "room" : "myroom" ,
118+ },
119+ "roomConfig" : map [string ]interface {}{
120+ "name" : "myroom" ,
121+ "someFutureFieldName" : "future-value" ,
122+ },
123+ }
124+ token , err := jwt .Signed (sig ).Claims (claims ).CompactSerialize ()
125+ require .NoError (t , err )
126+
127+ v , err := auth .ParseAPIToken (token )
128+ require .NoError (t , err )
129+
130+ _ , decoded , err := v .Verify (secret )
131+ require .NoError (t , err )
132+ require .NotNil (t , decoded .RoomConfig )
133+ require .Equal (t , "myroom" , decoded .RoomConfig .Name )
134+ })
135+
98136 t .Run ("nil permissions are handled" , func (t * testing.T ) {
99137 grant := & auth.VideoGrant {
100138 Room : "myroom" ,
0 commit comments