Skip to content

Commit

Permalink
fix: maintain backward compatibility for asymmetric JWTs (#1695)
Browse files Browse the repository at this point in the history
## What kind of change does this PR introduce?
* #1690
  • Loading branch information
kangmingtay authored Jul 31, 2024
1 parent 7de0cb3 commit cbb84b8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 3 additions & 2 deletions internal/api/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,9 @@ func (a *API) generateAccessToken(r *http.Request, tx *storage.Connection, user
}

if _, ok := token.Header["kid"]; !ok {
kid := signingJwk.KeyID()
token.Header["kid"] = kid
if kid := signingJwk.KeyID(); kid != "" {
token.Header["kid"] = kid
}
}

// this serializes the aud claim to a string
Expand Down
6 changes: 1 addition & 5 deletions internal/conf/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,11 +713,7 @@ func (config *GlobalConfiguration) ApplyDefaults() error {

if config.JWT.Keys == nil || len(config.JWT.Keys) == 0 {
// transform the secret into a JWK for consistency
bytes, err := base64.StdEncoding.DecodeString(config.JWT.Secret)
if err != nil {
bytes = []byte(config.JWT.Secret)
}
privKey, err := jwk.FromRaw(bytes)
privKey, err := jwk.FromRaw([]byte(config.JWT.Secret))
if err != nil {
return err
}
Expand Down

0 comments on commit cbb84b8

Please sign in to comment.