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
1735ed61
Commit
1735ed61
authored
Mar 14, 2017
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename cache db column with `_cached` suffix
parent
20575859
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
12 deletions
+12
-12
app/controllers/concerns/enforces_two_factor_authentication.rb
...ontrollers/concerns/enforces_two_factor_authentication.rb
+2
-2
app/models/user.rb
app/models/user.rb
+1
-1
db/migrate/20170124193205_add_two_factor_columns_to_users.rb
db/migrate/20170124193205_add_two_factor_columns_to_users.rb
+2
-2
db/schema.rb
db/schema.rb
+1
-1
spec/controllers/application_controller_spec.rb
spec/controllers/application_controller_spec.rb
+2
-2
spec/models/user_spec.rb
spec/models/user_spec.rb
+4
-4
No files found.
app/controllers/concerns/enforces_two_factor_authentication.rb
View file @
1735ed61
...
@@ -21,7 +21,7 @@ module EnforcesTwoFactorAuthentication
...
@@ -21,7 +21,7 @@ module EnforcesTwoFactorAuthentication
def
two_factor_authentication_required?
def
two_factor_authentication_required?
current_application_settings
.
require_two_factor_authentication?
||
current_application_settings
.
require_two_factor_authentication?
||
current_user
.
try
(
:require_two_factor_authentication?
)
current_user
.
try
(
:require_two_factor_authentication
_from_group
?
)
end
end
def
two_factor_authentication_reason
(
global:
->
{},
group:
->
{})
def
two_factor_authentication_reason
(
global:
->
{},
group:
->
{})
...
@@ -37,7 +37,7 @@ module EnforcesTwoFactorAuthentication
...
@@ -37,7 +37,7 @@ module EnforcesTwoFactorAuthentication
def
two_factor_grace_period
def
two_factor_grace_period
periods
=
[
current_application_settings
.
two_factor_grace_period
]
periods
=
[
current_application_settings
.
two_factor_grace_period
]
periods
<<
current_user
.
two_factor_grace_period
if
current_user
.
try
(
:require_two_factor_authentication?
)
periods
<<
current_user
.
two_factor_grace_period
if
current_user
.
try
(
:require_two_factor_authentication
_from_group
?
)
periods
.
min
periods
.
min
end
end
...
...
app/models/user.rb
View file @
1735ed61
...
@@ -974,7 +974,7 @@ class User < ActiveRecord::Base
...
@@ -974,7 +974,7 @@ class User < ActiveRecord::Base
def
update_two_factor_requirement
def
update_two_factor_requirement
periods
=
expanded_groups_requiring_two_factor_authentication
.
pluck
(
:two_factor_grace_period
)
periods
=
expanded_groups_requiring_two_factor_authentication
.
pluck
(
:two_factor_grace_period
)
self
.
require_two_factor_authentication
=
periods
.
any?
self
.
require_two_factor_authentication
_from_group
=
periods
.
any?
self
.
two_factor_grace_period
=
periods
.
min
||
User
.
column_defaults
[
'two_factor_grace_period'
]
self
.
two_factor_grace_period
=
periods
.
min
||
User
.
column_defaults
[
'two_factor_grace_period'
]
save
save
...
...
db/migrate/20170124193205_add_two_factor_columns_to_users.rb
View file @
1735ed61
...
@@ -6,12 +6,12 @@ class AddTwoFactorColumnsToUsers < ActiveRecord::Migration
...
@@ -6,12 +6,12 @@ class AddTwoFactorColumnsToUsers < ActiveRecord::Migration
disable_ddl_transaction!
disable_ddl_transaction!
def
up
def
up
add_column_with_default
(
:users
,
:require_two_factor_authentication
,
:boolean
,
default:
false
)
add_column_with_default
(
:users
,
:require_two_factor_authentication
_from_group
,
:boolean
,
default:
false
)
add_column_with_default
(
:users
,
:two_factor_grace_period
,
:integer
,
default:
48
)
add_column_with_default
(
:users
,
:two_factor_grace_period
,
:integer
,
default:
48
)
end
end
def
down
def
down
remove_column
(
:users
,
:require_two_factor_authentication
)
remove_column
(
:users
,
:require_two_factor_authentication
_from_group
)
remove_column
(
:users
,
:two_factor_grace_period
)
remove_column
(
:users
,
:two_factor_grace_period
)
end
end
end
end
db/schema.rb
View file @
1735ed61
...
@@ -1249,7 +1249,7 @@ ActiveRecord::Schema.define(version: 20170402231018) do
...
@@ -1249,7 +1249,7 @@ ActiveRecord::Schema.define(version: 20170402231018) do
t
.
boolean
"authorized_projects_populated"
t
.
boolean
"authorized_projects_populated"
t
.
boolean
"ghost"
t
.
boolean
"ghost"
t
.
boolean
"notified_of_own_activity"
t
.
boolean
"notified_of_own_activity"
t
.
boolean
"require_two_factor_authentication"
,
default:
false
,
null:
false
t
.
boolean
"require_two_factor_authentication
_from_group
"
,
default:
false
,
null:
false
t
.
integer
"two_factor_grace_period"
,
default:
48
,
null:
false
t
.
integer
"two_factor_grace_period"
,
default:
48
,
null:
false
end
end
...
...
spec/controllers/application_controller_spec.rb
View file @
1735ed61
...
@@ -183,7 +183,7 @@ describe ApplicationController do
...
@@ -183,7 +183,7 @@ describe ApplicationController do
end
end
it
'returns true if a 2FA requirement is set on the user'
do
it
'returns true if a 2FA requirement is set on the user'
do
user
.
require_two_factor_authentication
=
true
user
.
require_two_factor_authentication
_from_group
=
true
allow
(
controller
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
controller
).
to
receive
(
:current_user
).
and_return
(
user
)
expect
(
subject
).
to
be_truthy
expect
(
subject
).
to
be_truthy
...
@@ -201,7 +201,7 @@ describe ApplicationController do
...
@@ -201,7 +201,7 @@ describe ApplicationController do
end
end
context
'with a 2FA requirement set on the user'
do
context
'with a 2FA requirement set on the user'
do
let
(
:user
)
{
create
:user
,
require_two_factor_authentication:
true
,
two_factor_grace_period:
23
}
let
(
:user
)
{
create
:user
,
require_two_factor_authentication
_from_group
:
true
,
two_factor_grace_period:
23
}
it
'returns the user grace period if lower than the application grace period'
do
it
'returns the user grace period if lower than the application grace period'
do
stub_application_setting
two_factor_grace_period:
24
stub_application_setting
two_factor_grace_period:
24
...
...
spec/models/user_spec.rb
View file @
1735ed61
...
@@ -1548,7 +1548,7 @@ describe User, models: true do
...
@@ -1548,7 +1548,7 @@ describe User, models: true do
end
end
it
'requires 2FA'
do
it
'requires 2FA'
do
expect
(
user
.
require_two_factor_authentication
).
to
be
true
expect
(
user
.
require_two_factor_authentication
_from_group
).
to
be
true
end
end
it
'uses the shortest grace period'
do
it
'uses the shortest grace period'
do
...
@@ -1567,7 +1567,7 @@ describe User, models: true do
...
@@ -1567,7 +1567,7 @@ describe User, models: true do
end
end
it
'requires 2FA'
do
it
'requires 2FA'
do
expect
(
user
.
require_two_factor_authentication
).
to
be
true
expect
(
user
.
require_two_factor_authentication
_from_group
).
to
be
true
end
end
end
end
...
@@ -1582,7 +1582,7 @@ describe User, models: true do
...
@@ -1582,7 +1582,7 @@ describe User, models: true do
end
end
it
'requires 2FA'
do
it
'requires 2FA'
do
expect
(
user
.
require_two_factor_authentication
).
to
be
true
expect
(
user
.
require_two_factor_authentication
_from_group
).
to
be
true
end
end
end
end
...
@@ -1596,7 +1596,7 @@ describe User, models: true do
...
@@ -1596,7 +1596,7 @@ describe User, models: true do
end
end
it
'does not require 2FA'
do
it
'does not require 2FA'
do
expect
(
user
.
require_two_factor_authentication
).
to
be
false
expect
(
user
.
require_two_factor_authentication
_from_group
).
to
be
false
end
end
it
'falls back to the default grace period'
do
it
'falls back to the default grace period'
do
...
...
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