question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clock skew is in wrong direction

See original GitHub issue

Describe 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:closed
  • Created 2 years ago
  • Reactions:10
  • Comments:26 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
rasifixcommented, Apr 21, 2022

why has this bug not been fixed so far? Because nobody created a PR? Or does somebody have reservations about fixing this?!

5reactions
Shnecommented, Apr 20, 2022

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:

private get isAccessTokenExpired() {
  // custom check of token expiration to avoid bug in library: https://github.com/manfredsteyer/angular-oauth2-oidc/issues/1135
  const expiresAt = this.oAuthService.getAccessTokenExpiration() as number | null; // can return null https://github.com/manfredsteyer/angular-oauth2-oidc/blob/12.1/projects/lib/src/oauth-service.ts#L2354
  return Date.now() > (expiresAt ?? 0) - (this.oAuthService.clockSkewInSec ?? 0);
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Explanation of Clock Skew Concepts - LinkedIn
On the other hand, positive skew is bad for hold timing. Due to positive skew, the capture edge has shifted to the right....
Read more >
Timing Issues
The clock skew can be positive or negative depending upon the routing direction and position of the clock source. Clock skew is caused...
Read more >
What is Clock Skew? Understanding Clock Skew in a Clock ...
Clock skew becomes a serious problem in digital design as it can violate the timing constraints that the synchronous circuits rely on.
Read more >
Clock Skew - an overview | ScienceDirect Topics
The clock skew TSkew(i, f) of a local data path Ri Rf can be either positive or negative. Note that negative clock skew...
Read more >
Types Of Clock Skew - VLSI Concepts
In the above figure it's clear that Clock tree was good but just because of 2 branches are communicating with each other (which...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found