Add user ID based allowlist for Rack::Attack
What does this MR do?
For gitlab-com/gl-infra&341 (closed) we are finding that in order to tighten rate limiting, it would help us to have an allowlist for a small number of existing users that currently exceed the limits.
This implements gitlab-com/gl-infra/scalability#697 (closed).
"Screenshots"
At startup, this feature will log the current allowlist in auth.log
.
{"severity":"INFO","time":"2020-12-03T17:05:14.096Z","correlation_id":null,"gitlab_throttle_user_allowlist":[1,53,217]}
Requests that bypass rate limiting because of the user allowlist get marked as such in the structured logs with "throttle_safelist":"throttle_user_allowlist"
:
{"time":"2020-12-03T17:03:26.567Z","severity":"INFO","duration_s":0.05236,"db_duration_s":0.01356,"view_duration_s":0.0388,"status":200,"method":"GET","path":"/api/v4/projects/7","params":[],"host":"localhost","remote_ip":"127.0.0.1","ua":"curl/7.64.1","route":"/api/:version/projects/:id","user_id":1,"username":"root","queue_duration_s":0.196763,"redis_calls":7,"redis_duration_s":0.001245,"redis_read_bytes":804,"redis_write_bytes":329,"redis_cache_calls":7,"redis_cache_duration_s":0.001245,"redis_cache_read_bytes":804,"redis_cache_write_bytes":329,"throttle_safelist":"throttle_user_allowlist","correlation_id":"nUBaysbbe6a","meta.user":"root","meta.project":"root/gitlab2","meta.root_namespace":"root","meta.caller_id":"/api/:version/projects/:id","meta.feature_category":"projects"}
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Edited by Jacob Vosmaer