Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK-1696] Allow caller of cache.get to specify an expiry time adjustment #491

Merged
merged 4 commits into from
Jun 9, 2020

Conversation

stevehobbsdev
Copy link
Contributor

Description

The adjustment value used on the expiry time from the cache can now be configured per call to cache.get. The default is 0.

This allows:

  • Cache expires_at to be the same time as now() + expires_in (no longer includes an adjustment built in)
  • getTokenSilently can itself make a decision about whether to use the cached value, or refresh the token if expires_in - adjustment < now
  • functions like isAuthenticated to return true right up until the expires_in time is reached

References

Fixes #480
Fixes #474

Testing

  • This change adds test coverage for new/changed/fixed functionality

Checklist

  • I have added documentation for new/changed functionality in this PR or in auth0.com/docs
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not master

@stevehobbsdev stevehobbsdev added small CH: Changed PR is changing something labels Jun 1, 2020
@stevehobbsdev stevehobbsdev added this to the vNext milestone Jun 1, 2020
@stevehobbsdev stevehobbsdev requested a review from a team June 1, 2020 21:57
@stevehobbsdev stevehobbsdev changed the title Allow caller of cache.get to specify an expiry time adjustment [SDK-1696] Allow caller of cache.get to specify an expiry time adjustment Jun 1, 2020
src/cache.ts Outdated Show resolved Hide resolved
@adamjmcgrath
Copy link
Contributor

Lgtm, will fix #474

@JonathanHarvey could you see if you can repro #480 with this branch?

Steve Hobbs added 2 commits June 2, 2020 13:32
This allows:

* Cache expires_at to be the same time as now() + expires_in (no longer
includes an adjustment built in)
* getTokenSilently can itself make a decision about whether to use the
cached value, or refresh the token if expires_in - adjustment < now
* functions like isAuthenticated to return `true` right up until the
expires_in time is reached
@stevehobbsdev stevehobbsdev removed this from the vNext milestone Jun 2, 2020
@stevehobbsdev stevehobbsdev added this to the vNext milestone Jun 8, 2020
@stevehobbsdev stevehobbsdev merged commit dbb9cdb into master Jun 9, 2020
@stevehobbsdev stevehobbsdev deleted the fix/gts-leeway branch June 9, 2020 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CH: Changed PR is changing something
Projects
None yet
2 participants