Skip to content
/ incus Public
forked from lxc/incus

Commit

Permalink
Merge pull request lxc#707 from stgraber/main
Browse files Browse the repository at this point in the history
Fixes to JWT handling
  • Loading branch information
hallyn authored Mar 30, 2024
2 parents 0d3c5a6 + cb3ad27 commit a5ed6c0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion internal/server/util/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,16 @@ func CheckJwtToken(r *http.Request, trustedCerts map[string]x509.Certificate) (b
return false, "", nil
}

// Make sure this isn't an OIDC JWT.
issuer, err := token.Claims.GetIssuer()
if err != nil {
return false, "", nil
}

if issuer != "" {
return false, "", nil
}

// Check if the token is valid.
notBefore, err := token.Claims.GetNotBefore()
if err != nil {
Expand All @@ -330,7 +340,7 @@ func CheckJwtToken(r *http.Request, trustedCerts map[string]x509.Certificate) (b
return false, "", nil
}

if time.Now().Before(notBefore.Time) || time.Now().After(expiresAt.Time) {
if (notBefore != nil && time.Now().Before(notBefore.Time)) || (expiresAt != nil && time.Now().After(expiresAt.Time)) {
return false, "", nil
}

Expand Down

0 comments on commit a5ed6c0

Please sign in to comment.