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
Jérome Perrin
gitlab-ce
Commits
c8b2def2
Commit
c8b2def2
authored
Dec 18, 2014
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more comments explaining how we block IPs
parent
4a389e76
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
1 deletion
+6
-1
config/initializers/rack_attack_git_basic_auth.rb
config/initializers/rack_attack_git_basic_auth.rb
+2
-0
lib/gitlab/backend/grack_auth.rb
lib/gitlab/backend/grack_auth.rb
+4
-1
No files found.
config/initializers/rack_attack_git_basic_auth.rb
View file @
c8b2def2
unless
Rails
.
env
.
test?
unless
Rails
.
env
.
test?
# Tell the Rack::Attack Rack middleware to maintain an IP blacklist. We will
# update the blacklist from Grack::Auth#authenticate_user.
Rack
::
Attack
.
blacklist
(
'Git HTTP Basic Auth'
)
do
|
req
|
Rack
::
Attack
.
blacklist
(
'Git HTTP Basic Auth'
)
do
|
req
|
Rack
::
Attack
::
Allow2Ban
.
filter
(
req
.
ip
,
Gitlab
.
config
.
rack_attack
.
git_basic_auth
)
do
Rack
::
Attack
::
Allow2Ban
.
filter
(
req
.
ip
,
Gitlab
.
config
.
rack_attack
.
git_basic_auth
)
do
# This block only gets run if the IP was not already banned.
# This block only gets run if the IP was not already banned.
...
...
lib/gitlab/backend/grack_auth.rb
View file @
c8b2def2
...
@@ -76,7 +76,10 @@ module Grack
...
@@ -76,7 +76,10 @@ module Grack
return
user
if
user
.
present?
return
user
if
user
.
present?
# At this point, we know the credentials were wrong. We let Rack::Attack
# At this point, we know the credentials were wrong. We let Rack::Attack
# know there was a failed authentication attempt from this IP
# know there was a failed authentication attempt from this IP. This
# information is stored in the Rails cache (Redis) and will be used by
# the Rack::Attack middleware to decide whether to block requests from
# this IP.
Rack
::
Attack
::
Allow2Ban
.
filter
(
@request
.
ip
,
Gitlab
.
config
.
rack_attack
.
git_basic_auth
)
do
Rack
::
Attack
::
Allow2Ban
.
filter
(
@request
.
ip
,
Gitlab
.
config
.
rack_attack
.
git_basic_auth
)
do
# Return true, so that Allow2Ban increments the counter (stored in
# Return true, so that Allow2Ban increments the counter (stored in
# Rails.cache) for the IP
# Rails.cache) for the IP
...
...
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