Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
09b01c75
Commit
09b01c75
authored
Oct 17, 2017
by
Michael Kozono
Committed by
Francisco Lopez
Nov 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't add methods to Rack::Attack
parent
a7243fc1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
config/initializers/rack_attack_global.rb
config/initializers/rack_attack_global.rb
+12
-10
No files found.
config/initializers/rack_attack_global.rb
View file @
09b01c75
class
Rack::Attack
module
Gitlab::Throttle
def
self
.
settings
def
self
.
settings
Gitlab
::
CurrentSettings
.
current_application_settings
Gitlab
::
CurrentSettings
.
current_application_settings
end
end
def
self
.
throttle_
unauthenticated_options
def
self
.
unauthenticated_options
limit_proc
=
proc
{
|
req
|
settings
.
throttle_unauthenticated_requests_per_period
}
limit_proc
=
proc
{
|
req
|
settings
.
throttle_unauthenticated_requests_per_period
}
period_proc
=
proc
{
|
req
|
settings
.
throttle_unauthenticated_period_in_seconds
.
seconds
}
period_proc
=
proc
{
|
req
|
settings
.
throttle_unauthenticated_period_in_seconds
.
seconds
}
{
limit:
limit_proc
,
period:
period_proc
}
{
limit:
limit_proc
,
period:
period_proc
}
end
end
def
self
.
throttle_
authenticated_api_options
def
self
.
authenticated_api_options
limit_proc
=
proc
{
|
req
|
settings
.
throttle_authenticated_api_requests_per_period
}
limit_proc
=
proc
{
|
req
|
settings
.
throttle_authenticated_api_requests_per_period
}
period_proc
=
proc
{
|
req
|
settings
.
throttle_authenticated_api_period_in_seconds
.
seconds
}
period_proc
=
proc
{
|
req
|
settings
.
throttle_authenticated_api_period_in_seconds
.
seconds
}
{
limit:
limit_proc
,
period:
period_proc
}
{
limit:
limit_proc
,
period:
period_proc
}
end
end
def
self
.
throttle_
authenticated_web_options
def
self
.
authenticated_web_options
limit_proc
=
proc
{
|
req
|
settings
.
throttle_authenticated_web_requests_per_period
}
limit_proc
=
proc
{
|
req
|
settings
.
throttle_authenticated_web_requests_per_period
}
period_proc
=
proc
{
|
req
|
settings
.
throttle_authenticated_web_period_in_seconds
.
seconds
}
period_proc
=
proc
{
|
req
|
settings
.
throttle_authenticated_web_period_in_seconds
.
seconds
}
{
limit:
limit_proc
,
period:
period_proc
}
{
limit:
limit_proc
,
period:
period_proc
}
end
end
end
throttle
(
'throttle_unauthenticated'
,
throttle_unauthenticated_options
)
do
|
req
|
class
Rack::Attack
settings
.
throttle_unauthenticated_enabled
&&
throttle
(
'throttle_unauthenticated'
,
Gitlab
::
Throttle
.
unauthenticated_options
)
do
|
req
|
Gitlab
::
Throttle
.
settings
.
throttle_unauthenticated_enabled
&&
req
.
unauthenticated?
&&
req
.
unauthenticated?
&&
req
.
ip
req
.
ip
end
end
throttle
(
'throttle_authenticated_api'
,
throttle_
authenticated_api_options
)
do
|
req
|
throttle
(
'throttle_authenticated_api'
,
Gitlab
::
Throttle
.
authenticated_api_options
)
do
|
req
|
settings
.
throttle_authenticated_api_enabled
&&
Gitlab
::
Throttle
.
settings
.
throttle_authenticated_api_enabled
&&
req
.
api_request?
&&
req
.
api_request?
&&
req
.
authenticated_user_id
req
.
authenticated_user_id
end
end
throttle
(
'throttle_authenticated_web'
,
throttle_
authenticated_web_options
)
do
|
req
|
throttle
(
'throttle_authenticated_web'
,
Gitlab
::
Throttle
.
authenticated_web_options
)
do
|
req
|
settings
.
throttle_authenticated_web_enabled
&&
Gitlab
::
Throttle
.
settings
.
throttle_authenticated_web_enabled
&&
req
.
web_request?
&&
req
.
web_request?
&&
req
.
authenticated_user_id
req
.
authenticated_user_id
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment