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
8e665140
Commit
8e665140
authored
Mar 07, 2017
by
Markus Koller
Committed by
Alexis Reigel
Apr 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename check_2fa_requirement to check_two_factor_requirement
parent
7140e09e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
8 deletions
+8
-8
app/controllers/concerns/enforces_two_factor_authentication.rb
...ontrollers/concerns/enforces_two_factor_authentication.rb
+4
-4
app/controllers/profiles/two_factor_auths_controller.rb
app/controllers/profiles/two_factor_auths_controller.rb
+1
-1
app/controllers/sessions_controller.rb
app/controllers/sessions_controller.rb
+1
-1
spec/controllers/application_controller_spec.rb
spec/controllers/application_controller_spec.rb
+2
-2
No files found.
app/controllers/concerns/enforces_two_factor_authentication.rb
View file @
8e665140
...
@@ -2,18 +2,18 @@
...
@@ -2,18 +2,18 @@
#
#
# Controller concern to enforce two-factor authentication requirements
# Controller concern to enforce two-factor authentication requirements
#
#
# Upon inclusion, adds `check_
2fa_requirement` as a before_action, and
# Upon inclusion, adds `check_
two_factor_requirement` as a before_action,
# makes `two_factor_grace_period_expired?` and `two_factor_skippable?`
#
and
makes `two_factor_grace_period_expired?` and `two_factor_skippable?`
# available as view helpers.
# available as view helpers.
module
EnforcesTwoFactorAuthentication
module
EnforcesTwoFactorAuthentication
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Concern
included
do
included
do
before_action
:check_
2fa
_requirement
before_action
:check_
two_factor
_requirement
helper_method
:two_factor_grace_period_expired?
,
:two_factor_skippable?
helper_method
:two_factor_grace_period_expired?
,
:two_factor_skippable?
end
end
def
check_
2fa
_requirement
def
check_
two_factor
_requirement
if
two_factor_authentication_required?
&&
current_user
&&
!
current_user
.
two_factor_enabled?
&&
!
skip_two_factor?
if
two_factor_authentication_required?
&&
current_user
&&
!
current_user
.
two_factor_enabled?
&&
!
skip_two_factor?
redirect_to
profile_two_factor_auth_path
redirect_to
profile_two_factor_auth_path
end
end
...
...
app/controllers/profiles/two_factor_auths_controller.rb
View file @
8e665140
class
Profiles::TwoFactorAuthsController
<
Profiles
::
ApplicationController
class
Profiles::TwoFactorAuthsController
<
Profiles
::
ApplicationController
skip_before_action
:check_
2fa
_requirement
skip_before_action
:check_
two_factor
_requirement
def
show
def
show
unless
current_user
.
otp_secret
unless
current_user
.
otp_secret
...
...
app/controllers/sessions_controller.rb
View file @
8e665140
...
@@ -3,7 +3,7 @@ class SessionsController < Devise::SessionsController
...
@@ -3,7 +3,7 @@ class SessionsController < Devise::SessionsController
include
Devise
::
Controllers
::
Rememberable
include
Devise
::
Controllers
::
Rememberable
include
Recaptcha
::
ClientHelper
include
Recaptcha
::
ClientHelper
skip_before_action
:check_
2fa
_requirement
,
only:
[
:destroy
]
skip_before_action
:check_
two_factor
_requirement
,
only:
[
:destroy
]
prepend_before_action
:check_initial_setup
,
only:
[
:new
]
prepend_before_action
:check_initial_setup
,
only:
[
:new
]
prepend_before_action
:authenticate_with_two_factor
,
prepend_before_action
:authenticate_with_two_factor
,
...
...
spec/controllers/application_controller_spec.rb
View file @
8e665140
...
@@ -117,8 +117,8 @@ describe ApplicationController do
...
@@ -117,8 +117,8 @@ describe ApplicationController do
context
'two-factor authentication'
do
context
'two-factor authentication'
do
let
(
:controller
)
{
ApplicationController
.
new
}
let
(
:controller
)
{
ApplicationController
.
new
}
describe
'#check_
2fa
_requirement'
do
describe
'#check_
two_factor
_requirement'
do
subject
{
controller
.
send
:check_
2fa
_requirement
}
subject
{
controller
.
send
:check_
two_factor
_requirement
}
it
'does not redirect if 2FA is not required'
do
it
'does not redirect if 2FA is not required'
do
allow
(
controller
).
to
receive
(
:two_factor_authentication_required?
).
and_return
(
false
)
allow
(
controller
).
to
receive
(
:two_factor_authentication_required?
).
and_return
(
false
)
...
...
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