Skip to content

Commit

Permalink
Merge branch 'main' into feat/TT-9555/enhance-process
Browse files Browse the repository at this point in the history
  • Loading branch information
buraksekili committed Nov 21, 2023
2 parents ccfa37c + e2ff090 commit f1f6968
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@ import (
// ValidateDashboardLicense validates if the given license argument is a valid and not expired
// JWT token.
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 f1f6968

Please sign in to comment.