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
Kazuhiko Shiozaki
gitlab-ce
Commits
73023951
Commit
73023951
authored
Mar 27, 2015
by
Dmitriy Zaporozhets
Committed by
Robert Speicher
May 09, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Init 2 factor authentication for user model
parent
fe75411d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
2 deletions
+18
-2
app/models/user.rb
app/models/user.rb
+4
-1
app/views/devise/sessions/_new_base.html.haml
app/views/devise/sessions/_new_base.html.haml
+2
-1
config/initializers/devise.rb
config/initializers/devise.rb
+4
-0
db/migrate/20150327223628_add_devise_two_factor_to_users.rb
db/migrate/20150327223628_add_devise_two_factor_to_users.rb
+8
-0
No files found.
app/models/user.rb
View file @
73023951
...
@@ -57,6 +57,9 @@ require 'carrierwave/orm/activerecord'
...
@@ -57,6 +57,9 @@ require 'carrierwave/orm/activerecord'
require
'file_size_validator'
require
'file_size_validator'
class
User
<
ActiveRecord
::
Base
class
User
<
ActiveRecord
::
Base
devise
:two_factor_authenticatable
,
:otp_secret_encryption_key
=>
File
.
read
(
Rails
.
root
.
join
(
'.secret'
)).
chomp
include
Sortable
include
Sortable
include
Gitlab
::
ConfigHelper
include
Gitlab
::
ConfigHelper
include
TokenAuthenticatable
include
TokenAuthenticatable
...
@@ -70,7 +73,7 @@ class User < ActiveRecord::Base
...
@@ -70,7 +73,7 @@ class User < ActiveRecord::Base
default_value_for
:hide_no_password
,
false
default_value_for
:hide_no_password
,
false
default_value_for
:theme_id
,
gitlab_config
.
default_theme
default_value_for
:theme_id
,
gitlab_config
.
default_theme
devise
:
database_authenticatable
,
:
lockable
,
:async
,
devise
:lockable
,
:async
,
:recoverable
,
:rememberable
,
:trackable
,
:validatable
,
:omniauthable
,
:confirmable
,
:registerable
:recoverable
,
:rememberable
,
:trackable
,
:validatable
,
:omniauthable
,
:confirmable
,
:registerable
attr_accessor
:force_random_password
attr_accessor
:force_random_password
...
...
app/views/devise/sessions/_new_base.html.haml
View file @
73023951
=
form_for
(
resource
,
as:
resource_name
,
url:
session_path
(
resource_name
))
do
|
f
|
=
form_for
(
resource
,
as:
resource_name
,
url:
session_path
(
resource_name
))
do
|
f
|
=
f
.
text_field
:login
,
class:
"form-control top"
,
placeholder:
"Username or Email"
,
autofocus:
"autofocus"
=
f
.
text_field
:login
,
class:
"form-control top"
,
placeholder:
"Username or Email"
,
autofocus:
"autofocus"
=
f
.
password_field
:password
,
class:
"form-control bottom"
,
placeholder:
"Password"
=
f
.
password_field
:password
,
class:
"form-control middle"
,
placeholder:
"Password"
=
f
.
text_field
:otp_attempt
,
class:
'form-control bottom'
,
placeholder:
'Two-factor authentication token'
-
if
devise_mapping
.
rememberable?
-
if
devise_mapping
.
rememberable?
.remember-me.checkbox
.remember-me.checkbox
%label
{
for:
"user_remember_me"
}
%label
{
for:
"user_remember_me"
}
...
...
config/initializers/devise.rb
View file @
73023951
# Use this hook to configure devise mailer, warden hooks and so forth. The first
# Use this hook to configure devise mailer, warden hooks and so forth. The first
# four configuration values can also be set straight in your models.
# four configuration values can also be set straight in your models.
Devise
.
setup
do
|
config
|
Devise
.
setup
do
|
config
|
config
.
warden
do
|
manager
|
manager
.
default_strategies
(
:scope
=>
:user
).
unshift
:two_factor_authenticatable
end
# ==> Mailer Configuration
# ==> Mailer Configuration
# Configure the class responsible to send e-mails.
# Configure the class responsible to send e-mails.
config
.
mailer
=
"DeviseMailer"
config
.
mailer
=
"DeviseMailer"
...
...
db/migrate/20150327223628_add_devise_two_factor_to_users.rb
0 → 100644
View file @
73023951
class
AddDeviseTwoFactorToUsers
<
ActiveRecord
::
Migration
def
change
add_column
:users
,
:encrypted_otp_secret
,
:string
add_column
:users
,
:encrypted_otp_secret_iv
,
:string
add_column
:users
,
:encrypted_otp_secret_salt
,
:string
add_column
:users
,
:otp_required_for_login
,
:boolean
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