Skip to content

Commit

Permalink
Fix ctxSetSession signature for sitekey change
Browse files Browse the repository at this point in the history
  • Loading branch information
ARUNANGSHU CHATTERJEE committed Mar 31, 2023
1 parent 9597cdb commit ffd13ec
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions gateway/mw_jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ func (k *JWTMiddleware) getSecretToVerifySignature(r *http.Request, token *jwt.T
session, rawKeyExists := k.CheckSessionAndIdentityForValidKey(tykId, r)
tykId = session.KeyID
if !rawKeyExists {
//Cisco change to try search "sitekey-<kid>"
// Cisco change to try search "sitekey-<kid>"
sitekey := "sitekey-" + tykId
session, siteKeyExists := k.CheckSessionAndIdentityForValidKey(&sitekey, r)
session, siteKeyExists := k.CheckSessionAndIdentityForValidKey(sitekey, r)
if !siteKeyExists {
return nil, errors.New("token invalid, key not found")
} else {
Expand Down Expand Up @@ -654,16 +654,16 @@ func (k *JWTMiddleware) processOneToOneTokenMap(r *http.Request, token *jwt.Toke
tykId = session.KeyID

if !exists {
//Cisco change to try search "sitekey-<kid>"
// Cisco change to try search "sitekey-<kid>"
sitekey := "sitekey-" + tykId
k.Logger().Debug("Using sitekey ID: ", sitekey)
session, siteKeyExists := k.CheckSessionAndIdentityForValidKey(&sitekey, r)
session, siteKeyExists := k.CheckSessionAndIdentityForValidKey(sitekey, r)
if !siteKeyExists {
k.reportLoginFailure(tykId, r)
return errors.New("Key not authorized"), http.StatusForbidden
} else {
k.Logger().Debug("sitekey ID found.")
ctxSetSession(r, &session, sitekey, false)
ctxSetSession(r, &session, false, k.Gw.GetConfig().HashKeys)
ctxSetJWTContextVars(k.Spec, r, token)
return nil, http.StatusOK
}
Expand Down

0 comments on commit ffd13ec

Please sign in to comment.