This repository has been archived by the owner on Nov 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Secret): Check session and user_id match or not in jwt payload
In commit `36f49a0`, we verity $jti is force expired or not by call redis->sIsMember(Constant::invalidUserSessionSet, $payload['jti']), However redis cache is not reliable. When user has a force-expired jwt-token and the $payload['jti'] in not record in Constant::invalidUserSessionSet (for example, the key is delete or flushdb ), the jwt-token will pass our force-expired check. Since both `sIsMember` and `zScore` will be called and both cost o(1), we revert to use zSet Constant::mapUserSessionToId to store the relationship of session to user_id. if zScore return false , it means the cache through, check this in database and restore the user_id or 0 (it means the session is not exist or is expired) in redis cache. if zScore return other float , for example, (double) 0 means this session is marked as valid, so we compare with $payload['user_id'] to (loose)check if the relationship of session to user_id is matched or not.
- Loading branch information
Showing
6 changed files
with
26 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters