-
Notifications
You must be signed in to change notification settings - Fork 32
Add configuration for rate-limiting of logins, replacing hardcoded limits #3090
Conversation
b2e24f3
to
11abd7a
Compare
Deploying matrix-authentication-service-docs with Cloudflare Pages
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good, thanks!
// period must be at least 1 nanosecond according to the governor library | ||
if recip < 1.0e-9 || !recip.is_finite() { | ||
return Some(figment::error::Error::custom( | ||
"`per_second` must be a number that is more than zero and less than 1_000_000_000 (1e9)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm that error message doesn't look right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aah, recip < 1.0e-9
is 'more than zero' and !recip.is_finite()
is 'less than 1e9'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heheh, not quite, recip < 1.0e-9
means that per_second > 1e9
, and is_finite
guards against infinities and NaNs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe I should apply the validation on the input, I just didn't want to misthink the divisions and have it fail to create a quota with the numbers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually I think what you did is fine, since it's closer to what governor does internally, I just missed the .recip()
df967f6
to
8df3ec4
Compare
Follow up to #3013 to make it configurable.