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
Léo-Paul Géneau
gitlab-ce
Commits
70b9d8da
Commit
70b9d8da
authored
Mar 03, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unecessary defaults for uniq ip block, cleanup refactoring leftovers
parent
8a9bc24e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
11 deletions
+9
-11
db/migrate/20170210131347_add_unique_ips_limit_to_application_settings.rb
...210131347_add_unique_ips_limit_to_application_settings.rb
+2
-2
db/schema.rb
db/schema.rb
+4
-5
lib/gitlab/auth/unique_ips_limiter.rb
lib/gitlab/auth/unique_ips_limiter.rb
+2
-1
lib/gitlab/request_context.rb
lib/gitlab/request_context.rb
+0
-2
spec/lib/gitlab/request_context_spec.rb
spec/lib/gitlab/request_context_spec.rb
+1
-1
No files found.
db/migrate/20170210131347_add_unique_ips_limit_to_application_settings.rb
View file @
70b9d8da
...
...
@@ -4,8 +4,8 @@ class AddUniqueIpsLimitToApplicationSettings < ActiveRecord::Migration
disable_ddl_transaction!
def
up
add_column
_with_default
:application_settings
,
:unique_ips_limit_per_user
,
:integer
,
default:
10
add_column
_with_default
:application_settings
,
:unique_ips_limit_time_window
,
:integer
,
default:
3600
add_column
:application_settings
,
:unique_ips_limit_per_user
,
:integer
add_column
:application_settings
,
:unique_ips_limit_time_window
,
:integer
add_column_with_default
:application_settings
,
:unique_ips_limit_enabled
,
:boolean
,
default:
false
end
...
...
db/schema.rb
View file @
70b9d8da
...
...
@@ -111,11 +111,10 @@ ActiveRecord::Schema.define(version: 20170305203726) do
t
.
boolean
"plantuml_enabled"
t
.
integer
"max_pages_size"
,
default:
100
,
null:
false
t
.
integer
"terminal_max_session_time"
,
default:
0
,
null:
false
(
??
)
t
.
string
"default_artifacts_expire_in"
,
default:
'0'
,
null:
false
t
.
integer
"unique_ips_limit_per_user"
,
default:
10
,
null:
false
t
.
integer
"unique_ips_limit_time_window"
,
default:
3600
,
null:
false
t
.
boolean
"unique_ips_limit_enabled"
,
default:
false
,
null:
false
t
.
string
"default_artifacts_expire_in"
,
default:
"0"
,
null:
false
t
.
integer
"unique_ips_limit_per_user"
t
.
integer
"unique_ips_limit_time_window"
t
.
boolean
"unique_ips_limit_enabled"
,
default:
false
,
null:
false
end
create_table
"audit_events"
,
force: :cascade
do
|
t
|
...
...
@@ -587,9 +586,9 @@ ActiveRecord::Schema.define(version: 20170305203726) do
end
add_index
"labels"
,
[
"group_id"
,
"project_id"
,
"title"
],
name:
"index_labels_on_group_id_and_project_id_and_title"
,
unique:
true
,
using: :btree
add_index
"labels"
,
[
"type"
,
"project_id"
],
name:
"index_labels_on_type_and_project_id"
,
using: :btree
add_index
"labels"
,
[
"project_id"
],
name:
"index_labels_on_project_id"
,
using: :btree
add_index
"labels"
,
[
"title"
],
name:
"index_labels_on_title"
,
using: :btree
add_index
"labels"
,
[
"type"
,
"project_id"
],
name:
"index_labels_on_type_and_project_id"
,
using: :btree
create_table
"lfs_objects"
,
force: :cascade
do
|
t
|
t
.
string
"oid"
,
null:
false
...
...
lib/gitlab/auth/unique_ips_limiter.rb
View file @
70b9d8da
...
...
@@ -8,12 +8,13 @@ module Gitlab
if
config
.
unique_ips_limit_enabled
ip
=
RequestContext
.
client_ip
unique_ips
=
update_and_return_ips_count
(
user_id
,
ip
)
raise
TooManyIps
.
new
(
user_id
,
ip
,
unique_ips
)
if
unique_ips
>
config
.
unique_ips_limit_per_user
end
end
def
limit_user!
(
user
=
nil
)
user
=
yield
if
user
.
nil?
&&
block_given?
user
||=
yield
if
block_given?
limit_user_id!
(
user
.
id
)
unless
user
.
nil?
user
end
...
...
lib/gitlab/request_context.rb
View file @
70b9d8da
module
Gitlab
RequestStoreNotActive
=
Class
.
new
(
StandardError
)
class
RequestContext
class
<<
self
def
client_ip
...
...
spec/lib/gitlab/request_context_spec.rb
View file @
70b9d8da
...
...
@@ -22,7 +22,7 @@ describe Gitlab::RequestContext, lib: true do
it
{
is_expected
.
to
eq
(
ip
)
}
end
context
'before RequestContext m
w
run'
do
context
'before RequestContext m
iddleware
run'
do
it
{
is_expected
.
to
be_nil
}
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