Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cleaning-portalmec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Richard Fernando Heise Ferreira
cleaning-portalmec
Commits
f41dfab9
Commit
f41dfab9
authored
7 years ago
by
Israel Barreto Sant'Anna
Browse files
Options
Downloads
Patches
Plain Diff
Added some commentary important for getting the right IP in production
parent
af792d9f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/controllers/concerns/downloadable_controller.rb
+1
-0
1 addition, 0 deletions
app/controllers/concerns/downloadable_controller.rb
app/models/user.rb
+6
-0
6 additions, 0 deletions
app/models/user.rb
config/initializers/rack-attack.rb
+2
-0
2 additions, 0 deletions
config/initializers/rack-attack.rb
with
9 additions
and
0 deletions
app/controllers/concerns/downloadable_controller.rb
+
1
−
0
View file @
f41dfab9
...
...
@@ -22,6 +22,7 @@ module DownloadableController
# GET /learning_objects/1/download
def
download
# Change request.remote_ip to req.env["HTTP_X_REAL_IP"] in production
downloadable
.
download
(
current_user
,
request
.
remote_ip
)
link
=
downloadable
.
download_link
if
!
link
.
blank?
...
...
This diff is collapsed.
Click to expand it.
app/models/user.rb
+
6
−
0
View file @
f41dfab9
...
...
@@ -277,4 +277,10 @@ class User < ApplicationRecord
def
ignore_changes
super
+
%w(tokens sign_in_count current_sign_in_at last_sign_in_at current_sign_in_ip last_sign_in_ip score follows_count confirmation_token confirmed_at confirmation_sent_at)
end
def
update_tracked_fields
(
request
)
super
# Change request.remote_ip to req.env["HTTP_X_REAL_IP"] in production
self
.
current_sign_in_ip
=
request
.
remote_ip
end
end
This diff is collapsed.
Click to expand it.
config/initializers/rack-attack.rb
+
2
−
0
View file @
f41dfab9
...
...
@@ -43,6 +43,7 @@ class Rack::Attack
#
# Key: "rack::attack:#{Time.now.to_i/:period}:req/ip:#{req.ip}"
throttle
(
'req/ip'
,
limit:
600
,
period:
5
.
minutes
)
do
|
req
|
# Change req.ip to req.env["HTTP_X_REAL_IP"] in production
req
.
ip
unless
req
.
path
=~
%r{ ^
\/
(attachments|download|system) }
end
...
...
@@ -59,6 +60,7 @@ class Rack::Attack
#
# Key: "rack::attack:#{Time.now.to_i/:period}:logins/ip:#{req.ip}"
throttle
(
'logins/ip'
,
limit:
5
,
period:
20
.
seconds
)
do
|
req
|
# Change req.ip to req.env["HTTP_X_REAL_IP"] in production
req
.
ip
if
req
.
path
==
'/v1/auth/sign_in'
&&
req
.
post?
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment