@@ -17,8 +17,7 @@ import (
1717 "code.cloudfoundry.org/cli/v8/api/cloudcontroller/wrapper"
1818 "code.cloudfoundry.org/cli/v8/command/commandfakes"
1919 "code.cloudfoundry.org/cli/v8/integration/helpers"
20- "github.com/SermoDigital/jose/crypto"
21- "github.com/SermoDigital/jose/jws"
20+ jwtv5 "github.com/golang-jwt/jwt/v5"
2221 . "github.com/onsi/ginkgo/v2"
2322 . "github.com/onsi/gomega"
2423 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -146,11 +145,13 @@ var _ = Describe("KubernetesAuthentication", func() {
146145 checkBearerTokenInAuthHeader := func () {
147146 actualReq := checkCalls ()
148147
149- token , err := jws .ParseJWTFromRequest (actualReq .Request )
148+ token , err := jwtv5 .Parse (strings .TrimPrefix (actualReq .Header .Get ("Authorization" ), "Bearer " ), func (_ * jwtv5.Token ) (interface {}, error ) {
149+ return keyPair .Public (), nil
150+ }, jwtv5 .WithValidMethods ([]string {jwtv5 .SigningMethodRS256 .Alg ()}))
150151 Expect (err ).NotTo (HaveOccurred ())
151- Expect (token .Validate ( keyPair . Public (), crypto . SigningMethodRS256 )). To (Succeed ())
152+ Expect (token .Valid ). To (BeTrue ())
152153
153- claims := token .Claims ( )
154+ claims := token .Claims .(jwtv5. MapClaims )
154155 Expect (claims ).To (HaveKeyWithValue ("another" , "thing" ))
155156 }
156157
@@ -178,13 +179,13 @@ var _ = Describe("KubernetesAuthentication", func() {
178179 var token []byte
179180
180181 BeforeEach (func () {
181- jwt := jws . NewJWT (jws. Claims {
182+ claims := jwtv5. MapClaims {
182183 "exp" : time .Now ().Add (time .Hour ).Unix (),
183184 "another" : "thing" ,
184- }, crypto .SigningMethodRS256 )
185- var err error
186- token , err = jwt .Serialize (keyPair )
185+ }
186+ tokenString , err := jwtv5 .NewWithClaims (jwtv5 .SigningMethodRS256 , claims ).SignedString (keyPair )
187187 Expect (err ).NotTo (HaveOccurred ())
188+ token = []byte (tokenString )
188189
189190 kubeConfig .AuthInfos ["auth-test" ] = & api.AuthInfo {
190191 AuthProvider : & api.AuthProviderConfig {
@@ -368,13 +369,13 @@ var _ = Describe("KubernetesAuthentication", func() {
368369 var token []byte
369370
370371 BeforeEach (func () {
371- jwt := jws . NewJWT (jws. Claims {
372+ claims := jwtv5. MapClaims {
372373 "exp" : time .Now ().Add (time .Hour ).Unix (),
373374 "another" : "thing" ,
374- }, crypto .SigningMethodRS256 )
375- var err error
376- token , err = jwt .Serialize (keyPair )
375+ }
376+ tokenString , err := jwtv5 .NewWithClaims (jwtv5 .SigningMethodRS256 , claims ).SignedString (keyPair )
377377 Expect (err ).NotTo (HaveOccurred ())
378+ token = []byte (tokenString )
378379 })
379380
380381 Context ("inline tokens" , func () {
0 commit comments