two_factor_authentication 1.0 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +20 -0
- data/Gemfile +17 -0
- data/README.md +27 -18
- data/Rakefile +13 -0
- data/app/controllers/devise/two_factor_authentication_controller.rb +5 -4
- data/app/views/devise/two_factor_authentication/max_login_attempts_reached.html.erb +2 -2
- data/config/locales/en.yml +3 -0
- data/config/locales/ru.yml +6 -0
- data/lib/two_factor_authentication/controllers/helpers.rb +11 -1
- data/lib/two_factor_authentication/models/two_factor_authenticatable.rb +12 -4
- data/lib/two_factor_authentication/version.rb +1 -1
- data/spec/controllers/two_factor_auth_spec.rb +20 -0
- data/spec/features/two_factor_authenticatable_spec.rb +86 -0
- data/spec/lib/two_factor_authentication/models/two_factor_authenticatable_spec.rb +92 -6
- data/spec/rails_app/.gitignore +3 -0
- data/spec/rails_app/README.md +3 -0
- data/spec/rails_app/Rakefile +7 -0
- data/spec/rails_app/app/assets/javascripts/application.js +1 -0
- data/spec/rails_app/app/assets/stylesheets/application.css +4 -0
- data/spec/rails_app/app/controllers/application_controller.rb +3 -0
- data/spec/rails_app/app/controllers/home_controller.rb +10 -0
- data/spec/rails_app/app/helpers/application_helper.rb +8 -0
- data/spec/rails_app/app/mailers/.gitkeep +0 -0
- data/spec/rails_app/app/models/.gitkeep +0 -0
- data/spec/rails_app/app/models/guest_user.rb +10 -0
- data/spec/rails_app/app/models/user.rb +15 -0
- data/spec/rails_app/app/views/home/dashboard.html.erb +7 -0
- data/spec/rails_app/app/views/home/index.html.erb +3 -0
- data/spec/rails_app/app/views/layouts/application.html.erb +20 -0
- data/spec/rails_app/config.ru +4 -0
- data/spec/rails_app/config/application.rb +63 -0
- data/spec/rails_app/config/boot.rb +10 -0
- data/spec/rails_app/config/database.yml +19 -0
- data/spec/rails_app/config/environment.rb +5 -0
- data/spec/rails_app/config/environments/development.rb +28 -0
- data/spec/rails_app/config/environments/production.rb +68 -0
- data/spec/rails_app/config/environments/test.rb +32 -0
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails_app/config/initializers/devise.rb +256 -0
- data/spec/rails_app/config/initializers/inflections.rb +15 -0
- data/spec/rails_app/config/initializers/mime_types.rb +5 -0
- data/spec/rails_app/config/initializers/secret_token.rb +7 -0
- data/spec/rails_app/config/initializers/session_store.rb +8 -0
- data/spec/rails_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/rails_app/config/locales/devise.en.yml +59 -0
- data/spec/rails_app/config/locales/en.yml +5 -0
- data/spec/rails_app/config/routes.rb +64 -0
- data/spec/rails_app/db/migrate/20140403184646_devise_create_users.rb +42 -0
- data/spec/rails_app/db/migrate/20140407172619_two_factor_authentication_add_to_users.rb +15 -0
- data/spec/rails_app/db/migrate/20140407215513_add_nickanme_to_users.rb +7 -0
- data/spec/rails_app/db/schema.rb +38 -0
- data/spec/rails_app/lib/assets/.gitkeep +0 -0
- data/spec/rails_app/lib/sms_provider.rb +17 -0
- data/spec/rails_app/public/404.html +26 -0
- data/spec/rails_app/public/422.html +26 -0
- data/spec/rails_app/public/500.html +25 -0
- data/spec/rails_app/public/favicon.ico +0 -0
- data/spec/rails_app/script/rails +6 -0
- data/spec/spec_helper.rb +7 -7
- data/spec/support/authenticated_model_helper.rb +18 -19
- data/spec/support/capybara.rb +3 -0
- data/spec/support/features_spec_helper.rb +19 -0
- data/spec/support/sms_provider.rb +5 -0
- data/two_factor_authentication.gemspec +3 -1
- metadata +141 -13
@@ -1,29 +1,28 @@
|
|
1
1
|
module AuthenticatedModelHelper
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
include ActiveModel::Validations
|
6
|
-
include Devise::Models::TwoFactorAuthenticatable
|
7
|
-
|
8
|
-
define_model_callbacks :create
|
9
|
-
attr_accessor :otp_secret_key, :email
|
10
|
-
|
11
|
-
has_one_time_password
|
3
|
+
def build_guest_user
|
4
|
+
GuestUser.new
|
12
5
|
end
|
13
6
|
|
14
|
-
|
15
|
-
|
16
|
-
def send_two_factor_authentication_code
|
17
|
-
"Code sent"
|
18
|
-
end
|
7
|
+
def create_user(attributes={})
|
8
|
+
User.create!(valid_attributes(attributes))
|
19
9
|
end
|
20
10
|
|
21
|
-
def
|
22
|
-
|
11
|
+
def valid_attributes(attributes={})
|
12
|
+
{
|
13
|
+
nickname: 'Marissa',
|
14
|
+
email: generate_unique_email,
|
15
|
+
password: 'password',
|
16
|
+
password_confirmation: 'password'
|
17
|
+
}.merge(attributes)
|
23
18
|
end
|
24
19
|
|
25
|
-
def
|
26
|
-
|
20
|
+
def generate_unique_email
|
21
|
+
@@email_count ||= 0
|
22
|
+
@@email_count += 1
|
23
|
+
"user#{@@email_count}@example.com"
|
27
24
|
end
|
28
25
|
|
29
|
-
end
|
26
|
+
end
|
27
|
+
|
28
|
+
RSpec.configuration.send(:include, AuthenticatedModelHelper)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'warden'
|
2
|
+
|
3
|
+
module FeaturesSpecHelper
|
4
|
+
def warden
|
5
|
+
request.env['warden']
|
6
|
+
end
|
7
|
+
|
8
|
+
def complete_sign_in_form_for(user)
|
9
|
+
fill_in "Email", with: user.email
|
10
|
+
fill_in "Password", with: 'password'
|
11
|
+
click_button "Sign in"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
RSpec.configure do |config|
|
16
|
+
config.include Warden::Test::Helpers, type: :feature
|
17
|
+
config.include FeaturesSpecHelper, type: :feature
|
18
|
+
end
|
19
|
+
|
@@ -24,11 +24,13 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
25
25
|
s.require_paths = ["lib"]
|
26
26
|
|
27
|
-
s.add_development_dependency "rspec"
|
28
27
|
s.add_runtime_dependency 'rails', '>= 3.1.1'
|
29
28
|
s.add_runtime_dependency 'devise'
|
30
29
|
s.add_runtime_dependency 'randexp'
|
31
30
|
s.add_runtime_dependency 'rotp'
|
32
31
|
|
33
32
|
s.add_development_dependency 'bundler'
|
33
|
+
s.add_development_dependency 'rake'
|
34
|
+
s.add_development_dependency 'rspec-rails'
|
35
|
+
s.add_development_dependency 'capybara'
|
34
36
|
end
|
metadata
CHANGED
@@ -1,23 +1,37 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: two_factor_authentication
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitrii Golub
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.1.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.1.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: devise
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - '>='
|
18
32
|
- !ruby/object:Gem::Version
|
19
33
|
version: '0'
|
20
|
-
type: :
|
34
|
+
type: :runtime
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
@@ -25,21 +39,21 @@ dependencies:
|
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
42
|
+
name: randexp
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - '>='
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
47
|
+
version: '0'
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - '>='
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
56
|
+
name: rotp
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - '>='
|
@@ -53,13 +67,13 @@ dependencies:
|
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
70
|
+
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - '>='
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: '0'
|
62
|
-
type: :
|
76
|
+
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
@@ -67,13 +81,13 @@ dependencies:
|
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
84
|
+
name: rake
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - '>='
|
74
88
|
- !ruby/object:Gem::Version
|
75
89
|
version: '0'
|
76
|
-
type: :
|
90
|
+
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
@@ -81,7 +95,21 @@ dependencies:
|
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
98
|
+
name: rspec-rails
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: capybara
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
86
114
|
requirements:
|
87
115
|
- - '>='
|
@@ -107,6 +135,7 @@ extensions: []
|
|
107
135
|
extra_rdoc_files: []
|
108
136
|
files:
|
109
137
|
- .gitignore
|
138
|
+
- .travis.yml
|
110
139
|
- Gemfile
|
111
140
|
- LICENSE
|
112
141
|
- README.md
|
@@ -115,6 +144,7 @@ files:
|
|
115
144
|
- app/views/devise/two_factor_authentication/max_login_attempts_reached.html.erb
|
116
145
|
- app/views/devise/two_factor_authentication/show.html.erb
|
117
146
|
- config/locales/en.yml
|
147
|
+
- config/locales/ru.yml
|
118
148
|
- lib/generators/active_record/templates/migration.rb
|
119
149
|
- lib/generators/active_record/two_factor_authentication_generator.rb
|
120
150
|
- lib/generators/two_factor_authentication/two_factor_authentication_generator.rb
|
@@ -127,9 +157,58 @@ files:
|
|
127
157
|
- lib/two_factor_authentication/routes.rb
|
128
158
|
- lib/two_factor_authentication/schema.rb
|
129
159
|
- lib/two_factor_authentication/version.rb
|
160
|
+
- spec/controllers/two_factor_auth_spec.rb
|
161
|
+
- spec/features/two_factor_authenticatable_spec.rb
|
130
162
|
- spec/lib/two_factor_authentication/models/two_factor_authenticatable_spec.rb
|
163
|
+
- spec/rails_app/.gitignore
|
164
|
+
- spec/rails_app/README.md
|
165
|
+
- spec/rails_app/Rakefile
|
166
|
+
- spec/rails_app/app/assets/javascripts/application.js
|
167
|
+
- spec/rails_app/app/assets/stylesheets/application.css
|
168
|
+
- spec/rails_app/app/controllers/application_controller.rb
|
169
|
+
- spec/rails_app/app/controllers/home_controller.rb
|
170
|
+
- spec/rails_app/app/helpers/application_helper.rb
|
171
|
+
- spec/rails_app/app/mailers/.gitkeep
|
172
|
+
- spec/rails_app/app/models/.gitkeep
|
173
|
+
- spec/rails_app/app/models/guest_user.rb
|
174
|
+
- spec/rails_app/app/models/user.rb
|
175
|
+
- spec/rails_app/app/views/home/dashboard.html.erb
|
176
|
+
- spec/rails_app/app/views/home/index.html.erb
|
177
|
+
- spec/rails_app/app/views/layouts/application.html.erb
|
178
|
+
- spec/rails_app/config.ru
|
179
|
+
- spec/rails_app/config/application.rb
|
180
|
+
- spec/rails_app/config/boot.rb
|
181
|
+
- spec/rails_app/config/database.yml
|
182
|
+
- spec/rails_app/config/environment.rb
|
183
|
+
- spec/rails_app/config/environments/development.rb
|
184
|
+
- spec/rails_app/config/environments/production.rb
|
185
|
+
- spec/rails_app/config/environments/test.rb
|
186
|
+
- spec/rails_app/config/initializers/backtrace_silencers.rb
|
187
|
+
- spec/rails_app/config/initializers/devise.rb
|
188
|
+
- spec/rails_app/config/initializers/inflections.rb
|
189
|
+
- spec/rails_app/config/initializers/mime_types.rb
|
190
|
+
- spec/rails_app/config/initializers/secret_token.rb
|
191
|
+
- spec/rails_app/config/initializers/session_store.rb
|
192
|
+
- spec/rails_app/config/initializers/wrap_parameters.rb
|
193
|
+
- spec/rails_app/config/locales/devise.en.yml
|
194
|
+
- spec/rails_app/config/locales/en.yml
|
195
|
+
- spec/rails_app/config/routes.rb
|
196
|
+
- spec/rails_app/db/migrate/20140403184646_devise_create_users.rb
|
197
|
+
- spec/rails_app/db/migrate/20140407172619_two_factor_authentication_add_to_users.rb
|
198
|
+
- spec/rails_app/db/migrate/20140407215513_add_nickanme_to_users.rb
|
199
|
+
- spec/rails_app/db/schema.rb
|
200
|
+
- spec/rails_app/lib/assets/.gitkeep
|
201
|
+
- spec/rails_app/lib/sms_provider.rb
|
202
|
+
- spec/rails_app/public/404.html
|
203
|
+
- spec/rails_app/public/422.html
|
204
|
+
- spec/rails_app/public/500.html
|
205
|
+
- spec/rails_app/public/favicon.ico
|
206
|
+
- spec/rails_app/script/rails
|
131
207
|
- spec/spec_helper.rb
|
132
208
|
- spec/support/authenticated_model_helper.rb
|
209
|
+
- spec/support/capybara.rb
|
210
|
+
- spec/support/features_spec_helper.rb
|
211
|
+
- spec/support/sms_provider.rb
|
133
212
|
- two_factor_authentication.gemspec
|
134
213
|
homepage: https://github.com/Houdini/two_factor_authentication
|
135
214
|
licenses: []
|
@@ -155,7 +234,56 @@ signing_key:
|
|
155
234
|
specification_version: 4
|
156
235
|
summary: Two factor authentication plugin for devise
|
157
236
|
test_files:
|
237
|
+
- spec/controllers/two_factor_auth_spec.rb
|
238
|
+
- spec/features/two_factor_authenticatable_spec.rb
|
158
239
|
- spec/lib/two_factor_authentication/models/two_factor_authenticatable_spec.rb
|
240
|
+
- spec/rails_app/.gitignore
|
241
|
+
- spec/rails_app/README.md
|
242
|
+
- spec/rails_app/Rakefile
|
243
|
+
- spec/rails_app/app/assets/javascripts/application.js
|
244
|
+
- spec/rails_app/app/assets/stylesheets/application.css
|
245
|
+
- spec/rails_app/app/controllers/application_controller.rb
|
246
|
+
- spec/rails_app/app/controllers/home_controller.rb
|
247
|
+
- spec/rails_app/app/helpers/application_helper.rb
|
248
|
+
- spec/rails_app/app/mailers/.gitkeep
|
249
|
+
- spec/rails_app/app/models/.gitkeep
|
250
|
+
- spec/rails_app/app/models/guest_user.rb
|
251
|
+
- spec/rails_app/app/models/user.rb
|
252
|
+
- spec/rails_app/app/views/home/dashboard.html.erb
|
253
|
+
- spec/rails_app/app/views/home/index.html.erb
|
254
|
+
- spec/rails_app/app/views/layouts/application.html.erb
|
255
|
+
- spec/rails_app/config.ru
|
256
|
+
- spec/rails_app/config/application.rb
|
257
|
+
- spec/rails_app/config/boot.rb
|
258
|
+
- spec/rails_app/config/database.yml
|
259
|
+
- spec/rails_app/config/environment.rb
|
260
|
+
- spec/rails_app/config/environments/development.rb
|
261
|
+
- spec/rails_app/config/environments/production.rb
|
262
|
+
- spec/rails_app/config/environments/test.rb
|
263
|
+
- spec/rails_app/config/initializers/backtrace_silencers.rb
|
264
|
+
- spec/rails_app/config/initializers/devise.rb
|
265
|
+
- spec/rails_app/config/initializers/inflections.rb
|
266
|
+
- spec/rails_app/config/initializers/mime_types.rb
|
267
|
+
- spec/rails_app/config/initializers/secret_token.rb
|
268
|
+
- spec/rails_app/config/initializers/session_store.rb
|
269
|
+
- spec/rails_app/config/initializers/wrap_parameters.rb
|
270
|
+
- spec/rails_app/config/locales/devise.en.yml
|
271
|
+
- spec/rails_app/config/locales/en.yml
|
272
|
+
- spec/rails_app/config/routes.rb
|
273
|
+
- spec/rails_app/db/migrate/20140403184646_devise_create_users.rb
|
274
|
+
- spec/rails_app/db/migrate/20140407172619_two_factor_authentication_add_to_users.rb
|
275
|
+
- spec/rails_app/db/migrate/20140407215513_add_nickanme_to_users.rb
|
276
|
+
- spec/rails_app/db/schema.rb
|
277
|
+
- spec/rails_app/lib/assets/.gitkeep
|
278
|
+
- spec/rails_app/lib/sms_provider.rb
|
279
|
+
- spec/rails_app/public/404.html
|
280
|
+
- spec/rails_app/public/422.html
|
281
|
+
- spec/rails_app/public/500.html
|
282
|
+
- spec/rails_app/public/favicon.ico
|
283
|
+
- spec/rails_app/script/rails
|
159
284
|
- spec/spec_helper.rb
|
160
285
|
- spec/support/authenticated_model_helper.rb
|
286
|
+
- spec/support/capybara.rb
|
287
|
+
- spec/support/features_spec_helper.rb
|
288
|
+
- spec/support/sms_provider.rb
|
161
289
|
has_rdoc:
|