Clock skew is in wrong direction
See original GitHub issueDescribe the bug Unless the intent is to consider an access/id token valid for 10 minutes (by default) after it has expired, the clock skew calculation is in the wrong direction.
This, somewhat recent, commit seems to be the culprit: https://github.com/manfredsteyer/angular-oauth2-oidc/commit/68238fb6ea4a2f88ada97b03b13663d1454b001c#diff-685e26c24f3c008856834f8b4a350d5472b6aea01a623c31a8513f6cc599c57fR2391 The pluses should not have been changed to minuses.
It causes the current time to be considered 10 minutes (by default) in the past, causing the token to be considered valid for longer. I.e.: with the current code, the current time needs to be 10 minutes after the token expiration time for the comparison to turn true and the return value (indicating validity of token) to become false. Perhaps it could be worth refactoring this code for readability. At least, I had some difficulty understanding it.
Expected behavior Tokens should be considered expired once they expire.
Versions Library version 12.1.0
Additional context
I was experiencing problems with access tokens considered valid by the hasValidAccessToken()
method, where I knew they were expired.
I can’t even use negative values to fix it, because of these lines: https://github.com/manfredsteyer/angular-oauth2-oidc/blob/12.1/projects/lib/src/oauth-service.ts#L2233 that will throw ‘Token has expired’ Errors if I use a reasonable, but negative, value for clockSkewInSec.
I also consider it a bug that setting the clock skew to 0 causes the default to be used, because the value is checked for truthiness, instead of compared against undefined and/or null. This is also a new change, here: https://github.com/manfredsteyer/angular-oauth2-oidc/commit/68238fb6ea4a2f88ada97b03b13663d1454b001c#diff-685e26c24f3c008856834f8b4a350d5472b6aea01a623c31a8513f6cc599c57fR2121
Issue Analytics
- State:
- Created 2 years ago
- Reactions:10
- Comments:26 (5 by maintainers)
Top GitHub Comments
why has this bug not been fixed so far? Because nobody created a PR? Or does somebody have reservations about fixing this?!
Yeah, I’m surprised this hasn’t been fixed yet.
I ended up writing my own short method for checking whether access token is expired: