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
iv
gitlab-ce
Commits
e73ea126
Commit
e73ea126
authored
9 years ago
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for manually entering 2FA details
parent
f042b085
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
6 deletions
+40
-6
app/assets/stylesheets/pages/profile.scss
app/assets/stylesheets/pages/profile.scss
+14
-0
app/controllers/profiles/two_factor_auths_controller.rb
app/controllers/profiles/two_factor_auths_controller.rb
+2
-1
app/views/profiles/two_factor_auths/new.html.haml
app/views/profiles/two_factor_auths/new.html.haml
+18
-2
spec/controllers/profiles/two_factor_auths_controller_spec.rb
.../controllers/profiles/two_factor_auths_controller_spec.rb
+5
-2
spec/factories.rb
spec/factories.rb
+1
-1
No files found.
app/assets/stylesheets/pages/profile.scss
View file @
e73ea126
...
@@ -93,3 +93,17 @@
...
@@ -93,3 +93,17 @@
}
}
}
}
}
}
// Profile > Account > Two Factor Authentication
.two-factor-new
{
.manual-instructions
{
h3
{
margin-top
:
0
;
}
// Slightly increase the size of the details so they're easier to read
dl
{
font-size
:
1
.1em
;
}
}
}
This diff is collapsed.
Click to expand it.
app/controllers/profiles/two_factor_auths_controller.rb
View file @
e73ea126
class
Profiles::TwoFactorAuthsController
<
Profiles
::
ApplicationController
class
Profiles::TwoFactorAuthsController
<
Profiles
::
ApplicationController
def
new
def
new
unless
current_user
.
otp_secret
unless
current_user
.
otp_secret
current_user
.
otp_secret
=
User
.
generate_otp_secret
current_user
.
otp_secret
=
User
.
generate_otp_secret
(
16
)
current_user
.
save!
current_user
.
save!
end
end
...
@@ -18,6 +18,7 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
...
@@ -18,6 +18,7 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
else
else
@error
=
'Invalid pin code'
@error
=
'Invalid pin code'
@qr_code
=
build_qr_code
@qr_code
=
build_qr_code
render
'new'
render
'new'
end
end
end
end
...
...
This diff is collapsed.
Click to expand it.
app/views/profiles/two_factor_auths/new.html.haml
View file @
e73ea126
...
@@ -7,14 +7,30 @@
...
@@ -7,14 +7,30 @@
%hr
%hr
=
form_tag
profile_two_factor_auth_path
,
method: :post
,
class:
'form-horizontal'
do
|
f
|
=
form_tag
profile_two_factor_auth_path
,
method: :post
,
class:
'form-horizontal
two-factor-new
'
do
|
f
|
-
if
@error
-
if
@error
.alert.alert-danger
.alert.alert-danger
=
@error
=
@error
.form-group
.form-group
.col-sm-2
.col-sm-2
.col-sm-
10
.col-sm-
2
=
raw
@qr_code
=
raw
@qr_code
.col-sm-8.manual-instructions
%h3
Can't scan the code?
%p
To add the entry manually, provide the following details to the
application on your phone.
%dl
%dt
Account
%dd
=
current_user
.
email
%dl
%dt
Key
%dd
=
current_user
.
otp_secret
.
scan
(
/.{4}/
).
join
(
' '
)
%dl
%dt
Time based
%dd
Yes
.form-group
.form-group
=
label_tag
:pin_code
,
nil
,
class:
"control-label"
=
label_tag
:pin_code
,
nil
,
class:
"control-label"
.col-sm-10
.col-sm-10
...
...
This diff is collapsed.
Click to expand it.
spec/controllers/profiles/two_factor_auths_controller_spec.rb
View file @
e73ea126
...
@@ -11,8 +11,11 @@ describe Profiles::TwoFactorAuthsController do
...
@@ -11,8 +11,11 @@ describe Profiles::TwoFactorAuthsController do
describe
'GET new'
do
describe
'GET new'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
it
'generates otp_secret'
do
it
'generates otp_secret for user'
do
expect
{
get
:new
}.
to
change
{
user
.
otp_secret
}
expect
(
User
).
to
receive
(
:generate_otp_secret
).
with
(
16
).
and_return
(
'secret'
).
once
get
:new
get
:new
# Second hit shouldn't re-generate it
end
end
it
'assigns qr_code'
do
it
'assigns qr_code'
do
...
...
This diff is collapsed.
Click to expand it.
spec/factories.rb
View file @
e73ea126
...
@@ -31,7 +31,7 @@ FactoryGirl.define do
...
@@ -31,7 +31,7 @@ FactoryGirl.define do
trait
:two_factor
do
trait
:two_factor
do
before
(
:create
)
do
|
user
|
before
(
:create
)
do
|
user
|
user
.
otp_required_for_login
=
true
user
.
otp_required_for_login
=
true
user
.
otp_secret
=
User
.
generate_otp_secret
user
.
otp_secret
=
User
.
generate_otp_secret
(
16
)
end
end
end
end
...
...
This diff is collapsed.
Click to expand it.
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