Skip to content

Conversation

@dschom
Copy link
Contributor

@dschom dschom commented Jun 2, 2025

Because

  • We are getting ready to swap in the new rate limiting service

This pull request

  • Recreates the policies current held in the customs server, but in a flat file config format.

Issue that this pull request solves

Closes: FXA-11608

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).

Screenshots (Optional)

Please attach the screenshots of the changes made in case of change in user interface.

Other information (Optional)

@dschom dschom force-pushed the configure-remaining-ratelimit-rules branch 8 times, most recently from c20f7d6 to 4eb714d Compare June 3, 2025 22:59
@dschom dschom marked this pull request as ready for review June 3, 2025 23:01
@dschom dschom requested a review from a team as a code owner June 3, 2025 23:01
* @param action - Optional action to target. If nothing is provided, all counts are cleared.
* @returns Number of keys deleted.
*/
async resetCounts(action?:string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Surprising that isn't auto-formatted by prettier on pre-commit.

Copy link
Contributor Author

@dschom dschom Jun 4, 2025

Choose a reason for hiding this comment

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

Somehow it got turned off. I'll have to look into this.

request,
sessionToken.uid,
'passwordChange'
'authenticatedPasswordChanged'
Copy link
Contributor

Choose a reason for hiding this comment

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

That's not a defined action in the customs server.

Copy link
Contributor Author

@dschom dschom Jun 4, 2025

Choose a reason for hiding this comment

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

I've added a v2 check here and fallback accordingly.

await customs.check(request, email, 'passwordForgotVerifyOtp');

// Daily limit, will be checked if and only if the default limit above passes
await customs.check(request, email, 'passwordForgotVerifyOtpPerDay');
Copy link
Contributor

Choose a reason for hiding this comment

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

Also not a defined action in customs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to guard this with a check about if v2 is enabled.

request,
checkAuthenticatedUid,
'accountLogin'
'authenticatedAccountLogin'
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same

Copy link
Contributor

@chenba chenba left a comment

Choose a reason for hiding this comment

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

A few customs calls were changed to pass actions that are not defined in customs. I don't think that'll work since customs checks grouped known actions.

@dschom dschom force-pushed the configure-remaining-ratelimit-rules branch from 4eb714d to 535e953 Compare June 4, 2025 15:23
@dschom
Copy link
Contributor Author

dschom commented Jun 4, 2025

@chenba I've adjusted the few actions names where this was problematic to be conditional depending on v1 vs v2. Thanks for catching this. In my testing it didn't actually appear problematic, but none the less. I'll update it.

The reason these names were changed is that v2 is stricter about what you supply. So if there's a rule that checks UID on a given action, you must supply a UID when checking that action. Same goes for email or IP.

I thought about relaxing this requirement at the library level, but this strict behavior actually saved my bacon in a couple spots when customs wasn't properly invoked. So for now, I'll keep the behavior and just decide what to do based on the version of customs being used.

Because:
- We are getting ready to swap in the new rate limiting service

This Commit:
- Recreates the policies current held in the customs server, but in a flat file config format.
@dschom dschom force-pushed the configure-remaining-ratelimit-rules branch from 535e953 to 2068eb9 Compare June 4, 2025 16:35
@dschom dschom requested a review from chenba June 4, 2025 16:42
@dschom dschom merged commit 4fe4611 into main Jun 4, 2025
19 checks passed
@dschom dschom deleted the configure-remaining-ratelimit-rules branch June 4, 2025 17:27
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