Skip to content

Commit

Permalink
Fix panics while no license is provided
Browse files Browse the repository at this point in the history
Signed-off-by: Burak Sekili <buraksekili@gmail.com>
  • Loading branch information
buraksekili committed Nov 16, 2023
1 parent aec32cd commit e6e0333
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 e6e0333

Please sign in to comment.