Skip to content

Commit

Permalink
Merge pull request #27 from TykTechnologies/fix/TT-10544/empty-licens…
Browse files Browse the repository at this point in the history
…e-panic

[TT-10544] - Fix panics while no license is provided
  • Loading branch information
singhpr committed Nov 21, 2023
2 parents aec32cd + e6e0333 commit e2ff090
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions license/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@ import (
)

func ValidateDashboardLicense(license string) (bool, error) {
if license == "" {
return false, fmt.Errorf("empty license")
}

token, _ := jwt.Parse(license, func(token *jwt.Token) (interface{}, error) { // nolint:errcheck
return []byte(""), nil
})

if token == nil {
return false, fmt.Errorf("failed to parse license %v\n", license)
}

if strings.ToLower(fmt.Sprint(token.Header["typ"])) == "jwt" {
exp := strings.Split(fmt.Sprintf("%f", token.Claims.(jwt.MapClaims)["exp"]), ".")[0]

Expand Down

0 comments on commit e2ff090

Please sign in to comment.