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: rate limiting #231

Merged
merged 18 commits into from
Dec 11, 2023
Merged

feat: rate limiting #231

merged 18 commits into from
Dec 11, 2023

Conversation

chris13524
Copy link
Member

@chris13524 chris13524 commented Nov 29, 2023

Description

Adds rate limiting.

  • Re-enable other SIWE statement tests
  • Refactor and add limits to subscriber notifications
  • Test subscriber rate limit & multiple subscribers
  • Test responses in detail: not subscribed, not subscribed to scope, subscribed but rate limited
  • Attempt refactoring of notify endpoint to reduce complexity
    • Couldn't think of an obvious way to simplify
  • Add rate limits to other endpoints
  • Rate limit data export for each endpoint call, containing the project and remaining tokens
    • Can do in follow-up PR

Resolves #14

How Has This Been Tested?

Automated tests

Due Diligence

  • Breaking change
  • Requires a documentation update
  • Requires a e2e/integration test update

@chris13524 chris13524 self-assigned this Nov 29, 2023
@@ -539,6 +525,24 @@ pub async fn verify_identity(
})
}

fn parse_cacao_statement(statement: &str, domain: &str) -> Result<AuthorizedApp> {
Copy link
Contributor

Choose a reason for hiding this comment

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

should be in a different PR as it seems is not related to the rate limiting

Copy link
Member Author

@chris13524 chris13524 Nov 29, 2023

Choose a reason for hiding this comment

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

It's related because the rate limit prevents more than 5 /notify calls in a single second, and the tests all use the same project ID. So had to refactor the type of tests to allow them to pass. This was also tech-debt already.

@chris13524 chris13524 marked this pull request as ready for review December 8, 2023 00:08
@chris13524 chris13524 mentioned this pull request Dec 8, 2023
3 tasks
Copy link
Contributor

@geekbrother geekbrother left a comment

Choose a reason for hiding this comment

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

Looks good and I trust your tests in integration.rs.

@chris13524 chris13524 merged commit 264aefe into main Dec 11, 2023
@chris13524 chris13524 deleted the feat/rate-limiting branch December 11, 2023 15:15
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.

feat: spam protection
2 participants