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

Overrides when using hashtag #84

Merged
merged 4 commits into from
Nov 8, 2024
Merged

Conversation

pubalokta
Copy link

@pubalokta pubalokta commented Nov 8, 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

When we introduced elevated rate limits, we also implemented the use of Redis Hashtags to ensure that all keys involved in the elevated rate limits operation are allocated in the same Redis hash slot. This hashtagging process involves adding curly braces around the key.

However, this introduced an issue: overrides typically target keys without the hashtag. As a result, if we use a key with hashtags, the overrides will not be applied.

This PR addresses the issue by sanitizing the received key by removing the hashtag before looking for overrides. If any overrides are found, they will be applied accordingly.

Example:

Given the following configuration

buckets: {
  ip: {
    size: 10,
    per_second: 5,
    overrides: {
      '127.0.0.1': {
        per_second: 100
      }
    },
  }
}

It will apply the overrides for:

  • take('ip', '127.0.0.1')
  • take('ip', '{127.0.0.1}')

It will not apply the overrides for any other combination.

Testing

Describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors.

Please include any manual steps for testing end-to-end or functionality not covered by unit/integration tests.

Also include details of the environment this PR was developed in (language/platform/browser version).

  • 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 requested a review from a team as a code owner November 8, 2024 09:34
kampde
kampde previously approved these changes Nov 8, 2024
@pubalokta pubalokta merged commit 420f692 into master Nov 8, 2024
7 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.

3 participants