Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/url"
"time"

jwt "github.com/gbrlsnchs/jwt/v2"
"github.com/golang-jwt/jwt/v5"
"github.com/pkg/errors"
"gopkg.in/h2non/gentleman.v2"
"gopkg.in/h2non/gentleman.v2/context"
Expand Down Expand Up @@ -95,16 +95,16 @@ func extractHostFromToken(token string) (string, error) {
return u.Host, nil
}

func extractIssuerFromToken(token string) (string, error) {
payload, _, err := jwt.Parse(token)
func extractIssuerFromToken(tokenStr string) (string, error) {
token, _, err := jwt.NewParser().ParseUnverified(tokenStr, jwt.MapClaims{})
if err != nil {
return "", errors.Wrap(err, MsgErrCannotParse+"."+PrmTokenMsg)
}

var jot Token
if err = jwt.Unmarshal(payload, &jot); err != nil {
return "", errors.Wrap(err, MsgErrCannotUnmarshal+"."+PrmTokenMsg)
issuer, err := token.Claims.GetIssuer()
if err != nil {
return "", errors.Wrap(err, MsgErrCannotGetIssuer+"."+PrmTokenMsg)
}

return jot.Issuer, nil
return issuer, nil
}
2 changes: 1 addition & 1 deletion errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// Constants for error management
const (
MsgErrCannotObtain = "cannotObtain"
MsgErrCannotUnmarshal = "cannotUnmarshal"
MsgErrCannotGetIssuer = "cannotGetIssuer"
MsgErrCannotParse = "cannotParse"
MsgErrUnkownHTTPContentType = "unkownHTTPContentType"
MsgErrUnknownResponseStatusCode = "unknownResponseStatusCode"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/cloudtrust/httpclient
go 1.22

require (
github.com/gbrlsnchs/jwt/v2 v2.0.0
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/golang/mock v1.6.0
github.com/gorilla/mux v1.8.1
github.com/pkg/errors v0.9.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gbrlsnchs/jwt/v2 v2.0.0 h1:4iEVJykJPXrCimVaQJAfBWKAvuzDJi5fDdUBdrdTZ3M=
github.com/gbrlsnchs/jwt/v2 v2.0.0/go.mod h1:7kIj4oeJPffUpLL8RnU5Y3xT1Sm/VuFqjv8T1tqhqc8=
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
Expand Down
4 changes: 3 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
github.com/davecgh/go-spew/spew
# github.com/gbrlsnchs/jwt/v2 v2.0.0
## explicit
github.com/gbrlsnchs/jwt/v2
# github.com/golang-jwt/jwt/v5 v5.2.1
## explicit; go 1.18
github.com/golang-jwt/jwt/v5
# github.com/golang/mock v1.6.0
## explicit; go 1.11
github.com/golang/mock/mockgen/model
Expand Down