google-authenticator-rails 1.6.1 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +78 -66
- data/README.md +2 -2
- data/lib/google-authenticator-rails.rb +1 -0
- data/lib/google-authenticator-rails/active_record/helpers.rb +4 -0
- data/lib/google-authenticator-rails/version.rb +1 -1
- data/spec/google_authenticator_spec.rb +9 -4
- metadata +22 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7590aa55a2ba14e7005c74ce65b40dbbde7b1156
|
4
|
+
data.tar.gz: cc80661ea84c682684a1894a91a323e41ad748eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb2ba50e82b403794d9f8f4b2e47601526bbceb94f430732e92679abe66bf0a5faa054f2617163c51f47acb95f12fd539383c6cee3f83c24a46162cfaf9ff89a
|
7
|
+
data.tar.gz: cde11467ffb3ee7ff5fd5606558f8501936857e29a8580298205280911d010a5d4a386a67e4147ea2099ca57fda95a2adb97115fadcc691cb77813c25021a159
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,109 +1,121 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
google-authenticator-rails (1.
|
4
|
+
google-authenticator-rails (1.7.0)
|
5
5
|
actionpack
|
6
6
|
activerecord
|
7
7
|
google-qr
|
8
8
|
rails
|
9
|
-
rotp (=
|
9
|
+
rotp (= 3.3.0)
|
10
|
+
rqrcode
|
10
11
|
|
11
12
|
GEM
|
12
13
|
remote: https://rubygems.org/
|
13
14
|
specs:
|
14
|
-
actioncable (5.
|
15
|
-
actionpack (= 5.
|
15
|
+
actioncable (5.2.2)
|
16
|
+
actionpack (= 5.2.2)
|
16
17
|
nio4r (~> 2.0)
|
17
|
-
websocket-driver (
|
18
|
-
actionmailer (5.
|
19
|
-
actionpack (= 5.
|
20
|
-
actionview (= 5.
|
21
|
-
activejob (= 5.
|
18
|
+
websocket-driver (>= 0.6.1)
|
19
|
+
actionmailer (5.2.2)
|
20
|
+
actionpack (= 5.2.2)
|
21
|
+
actionview (= 5.2.2)
|
22
|
+
activejob (= 5.2.2)
|
22
23
|
mail (~> 2.5, >= 2.5.4)
|
23
24
|
rails-dom-testing (~> 2.0)
|
24
|
-
actionpack (5.
|
25
|
-
actionview (= 5.
|
26
|
-
activesupport (= 5.
|
25
|
+
actionpack (5.2.2)
|
26
|
+
actionview (= 5.2.2)
|
27
|
+
activesupport (= 5.2.2)
|
27
28
|
rack (~> 2.0)
|
28
29
|
rack-test (>= 0.6.3)
|
29
30
|
rails-dom-testing (~> 2.0)
|
30
31
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
31
|
-
actionview (5.
|
32
|
-
activesupport (= 5.
|
32
|
+
actionview (5.2.2)
|
33
|
+
activesupport (= 5.2.2)
|
33
34
|
builder (~> 3.1)
|
34
35
|
erubi (~> 1.4)
|
35
36
|
rails-dom-testing (~> 2.0)
|
36
37
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
37
|
-
activejob (5.
|
38
|
-
activesupport (= 5.
|
38
|
+
activejob (5.2.2)
|
39
|
+
activesupport (= 5.2.2)
|
39
40
|
globalid (>= 0.3.6)
|
40
|
-
activemodel (5.
|
41
|
-
activesupport (= 5.
|
42
|
-
activerecord (5.
|
43
|
-
activemodel (= 5.
|
44
|
-
activesupport (= 5.
|
45
|
-
arel (
|
46
|
-
|
41
|
+
activemodel (5.2.2)
|
42
|
+
activesupport (= 5.2.2)
|
43
|
+
activerecord (5.2.2)
|
44
|
+
activemodel (= 5.2.2)
|
45
|
+
activesupport (= 5.2.2)
|
46
|
+
arel (>= 9.0)
|
47
|
+
activestorage (5.2.2)
|
48
|
+
actionpack (= 5.2.2)
|
49
|
+
activerecord (= 5.2.2)
|
50
|
+
marcel (~> 0.3.1)
|
51
|
+
activesupport (5.2.2)
|
47
52
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
48
|
-
i18n (
|
53
|
+
i18n (>= 0.7, < 2)
|
49
54
|
minitest (~> 5.1)
|
50
55
|
tzinfo (~> 1.1)
|
51
56
|
appraisal (0.5.2)
|
52
57
|
bundler
|
53
58
|
rake
|
54
|
-
arel (
|
59
|
+
arel (9.0.0)
|
55
60
|
builder (3.2.3)
|
56
|
-
|
57
|
-
|
61
|
+
chunky_png (1.3.11)
|
62
|
+
concurrent-ruby (1.1.4)
|
63
|
+
crass (1.0.4)
|
58
64
|
diff-lcs (1.1.3)
|
59
|
-
docile (1.1
|
60
|
-
erubi (1.
|
61
|
-
globalid (0.4.
|
65
|
+
docile (1.3.1)
|
66
|
+
erubi (1.8.0)
|
67
|
+
globalid (0.4.2)
|
62
68
|
activesupport (>= 4.2.0)
|
63
69
|
google-qr (0.2.2)
|
64
|
-
i18n (
|
70
|
+
i18n (1.6.0)
|
65
71
|
concurrent-ruby (~> 1.0)
|
66
|
-
json (2.
|
67
|
-
loofah (2.2.
|
72
|
+
json (2.2.0)
|
73
|
+
loofah (2.2.3)
|
68
74
|
crass (~> 1.0.2)
|
69
75
|
nokogiri (>= 1.5.9)
|
70
|
-
mail (2.7.
|
76
|
+
mail (2.7.1)
|
71
77
|
mini_mime (>= 0.1.1)
|
72
|
-
|
73
|
-
|
74
|
-
|
78
|
+
marcel (0.3.3)
|
79
|
+
mimemagic (~> 0.3.2)
|
80
|
+
method_source (0.9.2)
|
81
|
+
mimemagic (0.3.3)
|
82
|
+
mini_mime (1.0.1)
|
83
|
+
mini_portile2 (2.4.0)
|
75
84
|
minitest (5.11.3)
|
76
|
-
nio4r (2.
|
77
|
-
nokogiri (1.
|
78
|
-
mini_portile2 (~> 2.
|
79
|
-
rack (2.0.
|
80
|
-
rack-test (
|
85
|
+
nio4r (2.3.1)
|
86
|
+
nokogiri (1.10.1)
|
87
|
+
mini_portile2 (~> 2.4.0)
|
88
|
+
rack (2.0.6)
|
89
|
+
rack-test (1.1.0)
|
81
90
|
rack (>= 1.0, < 3)
|
82
|
-
rails (5.
|
83
|
-
actioncable (= 5.
|
84
|
-
actionmailer (= 5.
|
85
|
-
actionpack (= 5.
|
86
|
-
actionview (= 5.
|
87
|
-
activejob (= 5.
|
88
|
-
activemodel (= 5.
|
89
|
-
activerecord (= 5.
|
90
|
-
|
91
|
+
rails (5.2.2)
|
92
|
+
actioncable (= 5.2.2)
|
93
|
+
actionmailer (= 5.2.2)
|
94
|
+
actionpack (= 5.2.2)
|
95
|
+
actionview (= 5.2.2)
|
96
|
+
activejob (= 5.2.2)
|
97
|
+
activemodel (= 5.2.2)
|
98
|
+
activerecord (= 5.2.2)
|
99
|
+
activestorage (= 5.2.2)
|
100
|
+
activesupport (= 5.2.2)
|
91
101
|
bundler (>= 1.3.0)
|
92
|
-
railties (= 5.
|
102
|
+
railties (= 5.2.2)
|
93
103
|
sprockets-rails (>= 2.0.0)
|
94
104
|
rails-dom-testing (2.0.3)
|
95
105
|
activesupport (>= 4.2.0)
|
96
106
|
nokogiri (>= 1.6)
|
97
|
-
rails-html-sanitizer (1.0.
|
98
|
-
loofah (~> 2.
|
99
|
-
railties (5.
|
100
|
-
actionpack (= 5.
|
101
|
-
activesupport (= 5.
|
107
|
+
rails-html-sanitizer (1.0.4)
|
108
|
+
loofah (~> 2.2, >= 2.2.2)
|
109
|
+
railties (5.2.2)
|
110
|
+
actionpack (= 5.2.2)
|
111
|
+
activesupport (= 5.2.2)
|
102
112
|
method_source
|
103
113
|
rake (>= 0.8.7)
|
104
|
-
thor (>= 0.
|
114
|
+
thor (>= 0.19.0, < 2.0)
|
105
115
|
rake (11.3.0)
|
106
|
-
rotp (
|
116
|
+
rotp (3.3.0)
|
117
|
+
rqrcode (0.10.1)
|
118
|
+
chunky_png (~> 1.0)
|
107
119
|
rspec (2.8.0)
|
108
120
|
rspec-core (~> 2.8.0)
|
109
121
|
rspec-expectations (~> 2.8.0)
|
@@ -112,12 +124,12 @@ GEM
|
|
112
124
|
rspec-expectations (2.8.0)
|
113
125
|
diff-lcs (~> 1.1.2)
|
114
126
|
rspec-mocks (2.8.0)
|
115
|
-
simplecov (0.
|
116
|
-
docile (~> 1.1
|
127
|
+
simplecov (0.16.1)
|
128
|
+
docile (~> 1.1)
|
117
129
|
json (>= 1.8, < 3)
|
118
130
|
simplecov-html (~> 0.10.0)
|
119
131
|
simplecov-html (0.10.2)
|
120
|
-
sprockets (3.7.
|
132
|
+
sprockets (3.7.2)
|
121
133
|
concurrent-ruby (~> 1.0)
|
122
134
|
rack (> 1, < 3)
|
123
135
|
sprockets-rails (3.2.1)
|
@@ -125,11 +137,11 @@ GEM
|
|
125
137
|
activesupport (>= 4.0)
|
126
138
|
sprockets (>= 3.0.0)
|
127
139
|
sqlite3 (1.3.13)
|
128
|
-
thor (0.20.
|
140
|
+
thor (0.20.3)
|
129
141
|
thread_safe (0.3.6)
|
130
142
|
tzinfo (1.2.5)
|
131
143
|
thread_safe (~> 0.1)
|
132
|
-
websocket-driver (0.
|
144
|
+
websocket-driver (0.7.0)
|
133
145
|
websocket-extensions (>= 0.1.0)
|
134
146
|
websocket-extensions (0.1.3)
|
135
147
|
|
@@ -142,7 +154,7 @@ DEPENDENCIES
|
|
142
154
|
rake (~> 11.0)
|
143
155
|
rspec (~> 2.8.0)
|
144
156
|
simplecov
|
145
|
-
sqlite3
|
157
|
+
sqlite3 (~> 1.3.6)
|
146
158
|
|
147
159
|
BUNDLED WITH
|
148
|
-
|
160
|
+
2.0.1
|
data/README.md
CHANGED
@@ -52,7 +52,7 @@ Example:
|
|
52
52
|
|
53
53
|
```ruby
|
54
54
|
class User
|
55
|
-
acts_as_google_authenticated :
|
55
|
+
acts_as_google_authenticated :column_name => :user_name
|
56
56
|
end
|
57
57
|
|
58
58
|
@user = User.new(:user_name => "ted")
|
@@ -200,7 +200,7 @@ class UserMfaSession < GoogleAuthenticatorRails::Session::Base
|
|
200
200
|
end
|
201
201
|
|
202
202
|
# app/controllers/mfa_session_controller.rb
|
203
|
-
|
203
|
+
class MfaSessionController < ApplicationController
|
204
204
|
def create
|
205
205
|
UserMfaSession.create(user)
|
206
206
|
end
|
@@ -35,6 +35,10 @@ module GoogleAuthenticatorRails # :nodoc:
|
|
35
35
|
GoogleQR.new(:data => ROTP::TOTP.new(google_secret_value, :issuer => google_issuer).provisioning_uri(google_label), :size => size || self.class.google_qr_size).to_s
|
36
36
|
end
|
37
37
|
|
38
|
+
def google_qr_to_base64(size = 200)
|
39
|
+
"data:image/png;base64,#{Base64.strict_encode64(RQRCode::QRCode.new(ROTP::TOTP.new(google_secret_value, :issuer => google_issuer).provisioning_uri(google_label).to_s).as_png(size: size).to_s)}"
|
40
|
+
end
|
41
|
+
|
38
42
|
def google_label
|
39
43
|
method = self.class.google_label_method
|
40
44
|
case method
|
@@ -6,12 +6,12 @@ describe GoogleAuthenticatorRails do
|
|
6
6
|
|
7
7
|
context 'counter = 1' do
|
8
8
|
let(:counter) { 1 }
|
9
|
-
it { should == 868864 }
|
9
|
+
it { should == "868864" }
|
10
10
|
end
|
11
11
|
|
12
12
|
context 'counter = 2' do
|
13
13
|
let(:counter) { 2 }
|
14
|
-
it { should == 304404 }
|
14
|
+
it { should == "304404" }
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -19,7 +19,7 @@ describe GoogleAuthenticatorRails do
|
|
19
19
|
let(:secret) { '5qlcip7azyjuwm36' }
|
20
20
|
let(:original_time) { Time.parse("2012-08-07 11:11:00 AM +0700") }
|
21
21
|
let!(:time) { original_time }
|
22
|
-
let(:code) { 495502 }
|
22
|
+
let(:code) { "495502" }
|
23
23
|
|
24
24
|
before do
|
25
25
|
Time.stub!(:now).and_return(time)
|
@@ -243,7 +243,7 @@ describe GoogleAuthenticatorRails do
|
|
243
243
|
|
244
244
|
context 'custom issuer' do
|
245
245
|
let(:user) { UserFactory.create ProcIssuerUser }
|
246
|
-
it { should eq "https://chart.googleapis.com/chart?cht=qr&chl=otpauth%3A%2F%2Ftotp%
|
246
|
+
it { should eq "https://chart.googleapis.com/chart?cht=qr&chl=otpauth%3A%2F%2Ftotp%2FFA%2520Admin%3Atest%40example.com%3Fsecret%3D#{secret}%26issuer%3DFA%2BAdmin&chs=200x200" }
|
247
247
|
end
|
248
248
|
|
249
249
|
context 'method defined by symbol' do
|
@@ -272,6 +272,11 @@ describe GoogleAuthenticatorRails do
|
|
272
272
|
subject { user.google_qr_uri('400x400') }
|
273
273
|
it { should eq "https://chart.googleapis.com/chart?cht=qr&chl=otpauth%3A%2F%2Ftotp%2Ftest%40example.com%3Fsecret%3D#{secret}&chs=400x400" }
|
274
274
|
end
|
275
|
+
|
276
|
+
context 'generates base64 image' do
|
277
|
+
let(:user) { UserFactory.create QrCodeUser }
|
278
|
+
it { user.google_qr_to_base64.include?('data:image/png;base64').should be_true }
|
279
|
+
end
|
275
280
|
end
|
276
281
|
end
|
277
282
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-authenticator-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared McFarland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rotp
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.3.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.3.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rqrcode
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: actionpack
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,16 +154,16 @@ dependencies:
|
|
140
154
|
name: sqlite3
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
142
156
|
requirements:
|
143
|
-
- - "
|
157
|
+
- - "~>"
|
144
158
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
159
|
+
version: 1.3.6
|
146
160
|
type: :development
|
147
161
|
prerelease: false
|
148
162
|
version_requirements: !ruby/object:Gem::Requirement
|
149
163
|
requirements:
|
150
|
-
- - "
|
164
|
+
- - "~>"
|
151
165
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
166
|
+
version: 1.3.6
|
153
167
|
description: Add the ability to use the Google Authenticator with ActiveRecord.
|
154
168
|
email:
|
155
169
|
- jared.online@gmail.com
|