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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
21b10d61
Commit
21b10d61
authored
May 14, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'rs-ldap-2fa' into 'master'
Enable 2FA for LDAP logins See merge request !395
parents
c3427745
0ad9fc60
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
27 deletions
+66
-27
CHANGELOG-EE
CHANGELOG-EE
+1
-0
app/controllers/concerns/authenticates_with_two_factor.rb
app/controllers/concerns/authenticates_with_two_factor.rb
+30
-0
app/controllers/omniauth_callbacks_controller.rb
app/controllers/omniauth_callbacks_controller.rb
+8
-1
app/views/profiles/accounts/show.html.haml
app/views/profiles/accounts/show.html.haml
+24
-25
lib/gitlab/ldap/user.rb
lib/gitlab/ldap/user.rb
+3
-1
No files found.
CHANGELOG-EE
View file @
21b10d61
v 7.11.0
v 7.11.0
- Skip git hooks commit validation when pushing new tag.
- Skip git hooks commit validation when pushing new tag.
- Add Two-factor authentication (2FA) for LDAP logins
v 7.10.1
v 7.10.1
- Check if comment exists in Jira before sending a reference
- Check if comment exists in Jira before sending a reference
...
...
app/controllers/concerns/authenticates_with_two_factor.rb
0 → 100644
View file @
21b10d61
# == AuthenticatesWithTwoFactor
#
# Controller concern to handle two-factor authentication
#
# Upon inclusion, skips `require_no_authentication` on `:create`.
module
AuthenticatesWithTwoFactor
extend
ActiveSupport
::
Concern
included
do
# This action comes from DeviseController, but because we call `sign_in`
# manually, not skipping this action would cause a "You are already signed
# in." error message to be shown upon successful login.
skip_before_action
:require_no_authentication
,
only:
[
:create
]
end
# Store the user's ID in the session for later retrieval and render the
# two factor code prompt
#
# The user must have been authenticated with a valid login and password
# before calling this method!
#
# user - User record
#
# Returns nil
def
prompt_for_two_factor
(
user
)
session
[
:otp_user_id
]
=
user
.
id
render
'devise/sessions/two_factor'
and
return
end
end
app/controllers/omniauth_callbacks_controller.rb
View file @
21b10d61
class
OmniauthCallbacksController
<
Devise
::
OmniauthCallbacksController
class
OmniauthCallbacksController
<
Devise
::
OmniauthCallbacksController
include
AuthenticatesWithTwoFactor
protect_from_forgery
except: :kerberos
protect_from_forgery
except: :kerberos
Gitlab
.
config
.
omniauth
.
providers
.
each
do
|
provider
|
Gitlab
.
config
.
omniauth
.
providers
.
each
do
|
provider
|
define_method
provider
[
'name'
]
do
define_method
provider
[
'name'
]
do
handle_omniauth
handle_omniauth
...
@@ -26,7 +29,11 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
...
@@ -26,7 +29,11 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
# Do additional LDAP checks for the user filter and EE features
# Do additional LDAP checks for the user filter and EE features
if
@user
.
allowed?
if
@user
.
allowed?
if
@user
.
otp_required_for_login?
prompt_for_two_factor
(
gl_user
)
else
sign_in_and_redirect
(
gl_user
)
sign_in_and_redirect
(
gl_user
)
end
else
else
flash
[
:alert
]
=
"Access denied for your LDAP account."
flash
[
:alert
]
=
"Access denied for your LDAP account."
redirect_to
new_user_session_path
redirect_to
new_user_session_path
...
...
app/views/profiles/accounts/show.html.haml
View file @
21b10d61
...
@@ -26,7 +26,6 @@
...
@@ -26,7 +26,6 @@
%span
You don`t have one yet. Click generate to fix it.
%span
You don`t have one yet. Click generate to fix it.
=
f
.
submit
'Generate'
,
class:
"btn success btn-build-token"
=
f
.
submit
'Generate'
,
class:
"btn success btn-build-token"
-
unless
current_user
.
ldap_user?
%fieldset
%fieldset
-
if
current_user
.
otp_required_for_login
-
if
current_user
.
otp_required_for_login
%legend
.text-success
%legend
.text-success
...
...
lib/gitlab/ldap/user.rb
View file @
21b10d61
...
@@ -24,7 +24,9 @@ module Gitlab
...
@@ -24,7 +24,9 @@ module Gitlab
update_user_attributes
update_user_attributes
end
end
# instance methods
delegate
:otp_required_for_login?
,
:otp_backup_codes
,
:otp_attempt
,
to: :gl_user
def
gl_user
def
gl_user
@gl_user
||=
find_by_uid_and_provider
||
find_by_email
||
build_new_user
@gl_user
||=
find_by_uid_and_provider
||
find_by_email
||
build_new_user
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