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

feat: adding delta_reset_ms to TAKE and TAKEELEVATED responses #80

Merged
merged 4 commits into from
Oct 7, 2024

Conversation

pubalokta
Copy link

@pubalokta pubalokta commented Sep 30, 2024

By submitting a PR to this repository, you agree to the terms within the Auth0 Code of Conduct. Please see the contributing guidelines for how to create and submit a high-quality PR for this repo.

Description

Adds a new delta_reset_ms response attribute to TAKE and TAKEELEVATED, to indicate the number of ms until the bucket resets. Unlike the reset attribute which represents a unix timestamp, this attribute represents a delta from the current time expressed in ms in order to avoid clock skew issues.

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 the default branch

@pubalokta pubalokta changed the title adding delta_reset_ms to TAKE and TAKEELEVATED responses feat:adding delta_reset_ms to TAKE and TAKEELEVATED responses Sep 30, 2024
@pubalokta pubalokta changed the title feat:adding delta_reset_ms to TAKE and TAKEELEVATED responses feat: adding delta_reset_ms to TAKE and TAKEELEVATED responses Sep 30, 2024
@pubalokta pubalokta marked this pull request as ready for review September 30, 2024 15:30
@pubalokta pubalokta requested a review from a team as a code owner September 30, 2024 15:30
ecita
ecita previously approved these changes Oct 7, 2024
Copy link

@ecita ecita left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tentatively approving - only semi-blocking thing would be the question about the test where + 1800 is added in a previous assert

test/db.tests.js Show resolved Hide resolved
@@ -446,6 +450,7 @@ module.exports.tests = (clientCreator) => {
assert.ok(result.conformant);
assert.equal(result.remaining, 0);
assert.closeTo(result.reset, now / 1000 + 1800, 1);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why they added an extra 1800 here (maybe because of an override?)

Wondering whether we should consider and incorporate it for delta_reset_ms assertion too

Copy link
Author

@pubalokta pubalokta Oct 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the bucket is configured at 2 tokens per hour. As it's a sliding window it calculates it needs to add 1 token every 30 minutes (1800 secs).
And it's indirectly set in the delta_reset_ms. After the calculations, it'll be 1800 secs as well.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't fully understand why we are considering "half an hour" here. Can we :watercooler: on it after this sometime?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you have a good way to describe it in text. :D

test/db.tests.js Outdated Show resolved Hide resolved
lib/db.js Show resolved Hide resolved
@pubalokta pubalokta merged commit 2d4009e into master Oct 7, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants