-
Notifications
You must be signed in to change notification settings - Fork 80
Specify rate_limit.blocked event #5466
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
Conversation
|
Moved url into audit_context in 885e7b3 For other fields of |
|
|
Updated:
|
|
Added one more commit to update the hook spec, which reference the rate limit names. |
docs/specs/event.md
Outdated
| "rate_limit_group": "authentication.password", | ||
| "rate_limit_name": "authentication.password.per_ip", |
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.
A second thought:
Maybe we can change this to an object:
{
"rate_limit": {
"name": "authentication.password.per_ip",
"group": "authentication.password"
}
}
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.
Sorry for late reply. 🙇🏻♀️ This payload looks good to me.
At the same time, I think we should also find out where we expose rate_limit in the public API. I believe it should be here: error.go. We currently expose bucket there, and we should consider proposing some adjustments. One idea is to add rate_limit.name and rate_limit.group to the payload, and mark rate_limit_name and bucket_name as legacy while keeping them to avoid a breaking change. However, this would make the payload look a bit confusing.🫤
{
"name": "TooManyRequest",
"reason": "RateLimited",
"message": "request rate limited",
"code": 429,
"info": {
"FlowType": "login",
"bucket_name": "AccountEnumerationPerIP",
"rate_limit_name": "authentication.account_enumeration",
"rate_limit": {
"name": "authentication.account_enumeration",
"group": "authentication.account_enumeration.per_ip"
}
}
}
Also check if anywhere else have similar problems.
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.
I have checked we only use bucket_name at the moment. rate_limit_name should be safe to remove.
The place that actually uses the rate limit group name is hook. You can see this commit: c1eaa57
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.
I have checked we only use bucket_name at the moment. rate_limit_name should be safe to remove.
But is there any chance we return this error in our APIs that users might reference? Is it the Custom UI API?
The place that actually uses the rate limit group name is hook.
We’re using the group name as the key there, not something like rate_limit_name, so it looks fine, 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.
But is there any chance we return this error in our APIs that users might reference? Is it the Custom UI API?
I would not say there is no chance, but this thing is introduced recently, and I've also checked custom UI codes which I have access to and do not see any usage of the key. I think it should be safe to remove. And actually the original key is rate_limit_name but it is a group, which is more confusing if we do not remove it.
We’re using the group name as the key there, not something like rate_limit_name, so it looks fine, right?
It is named rate_limits. An example:
{
"is_allowed": true,
"rate_limits": {
"authentication.account_enumeration": {
"weight": 2
}
}
}It is designed in this way because we do not want the user to list all related rate limits when he need to modify the weight.
102e84f to
fb52052
Compare
carmenlau
left a comment
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.
The rest looks fine
docs/specs/hook.md
Outdated
| ## Using Blocking Event with Rate Limits | ||
|
|
||
| The `rate_limits` property in a blocking event response allows you to dynamically override rate limit weights. The value of this property is an object where keys are rate limit names. For a list of available rate limit names, see [the rate limit spec](./rate-limit.md). | ||
| The `rate_limits` property in a blocking event response allows you to dynamically override rate limit weights. The value of this property is an object where keys are rate limit group names. For a list of available rate limit groups, see [the rate limit spec](./rate-limit.md). |
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.
's/rate limit group names/rate limit groups/g'
|
Updated, thanks! |
ref DEV-3253
@fungc-io @carmenlau Please see the design of the new rate limit blocked event, and let me know if you think any other additional information is needed in the payload.