google-authenticator-rails 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Y2MxMDMxMGNmZjZiYzgwNDc5NjAwNTFlMTYzOWJkZWE4NWMxNTM1OA==
5
+ data.tar.gz: !binary |-
6
+ NjRkNGQzMGJjMjgzNmU1ZjEyM2NhNmU1ZjRjYmNmZmU0NWQwZTUxZQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NDkyN2M5YmYwYmNkNmI0NjEwMWQ0ZTY5NzNlNGY4Yjk0ZmMyMjE2ODk1Yjgw
10
+ OGFmZDQzY2M2ODcxYTA3NTllYjQyYmY1YzkxMThhYTI4MDlkODliZDc2ZmE0
11
+ YWRiMjAxZWI5N2E0ODRlNzVmMDc5MDI3YTBhZTg2ZThlZmU1ZTY=
12
+ data.tar.gz: !binary |-
13
+ OTlkYmY5YmViYjgzZmNlNzZjYjgyYjU3ZDk2ZjkwZTU1Y2MwNmI2ZWJiNDIy
14
+ NDAzOTUyYjU5NDMzYTUzMDc2YzZkMWU5MDIwYzBkZTg0YTYyZWE1MWFhNzQx
15
+ YTFiNjUxZTU1MzA4NzM3ODcyNDE0NTUyNTNhNjFhYzliNzc5M2M=
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/google-authenticator-rails.png)](http://badge.fury.io/rb/google-authenticator-rails)
4
4
  [![Build Status](https://secure.travis-ci.org/jaredonline/google-authenticator.png)](http://travis-ci.org/jaredonline/google-authenticator)
5
- [![Code Climate](https://codeclimate.com/repos/52d87827e30ba05abf0010c8/badges/a5a86d94e894763e190a/gpa.png)](https://codeclimate.com/repos/52d87827e30ba05abf0010c8/feed)
5
+ [![Code Climate](https://codeclimate.com/github/jaredonline/google-authenticator.png)](https://codeclimate.com/github/jaredonline/google-authenticator)
6
6
 
7
7
  Rails (ActiveRecord) integration with the Google Authenticator apps for Android and the iPhone. Uses the Authlogic style for cookie management.
8
8
 
@@ -26,7 +26,7 @@ Example:
26
26
 
27
27
  ```ruby
28
28
  class User
29
- acts_as_google_authenticated
29
+ acts_as_google_authenticated
30
30
  end
31
31
 
32
32
  @user = User.new
@@ -49,7 +49,7 @@ Examples:
49
49
 
50
50
  ```ruby
51
51
  class User
52
- acts_as_google_authenticated :column => :user_name
52
+ acts_as_google_authenticated :column => :user_name
53
53
  end
54
54
 
55
55
  @user = User.new(:user_name => "ted")
@@ -92,6 +92,30 @@ end
92
92
  @user.mfa_secret # => "56ahi483"
93
93
  ```
94
94
 
95
+ You can also specify which column the appropriate `MfaSession` subclass should use to look up the record:
96
+
97
+ Example
98
+
99
+ ```ruby
100
+ class User
101
+ acts_as_google_authenticated :lookup_token => :salt
102
+ end
103
+ ```
104
+
105
+ The above will cause the `UserMfaSession` class to call `User.where(:salt => cookie_salt)` or `User.scoped(:conditions => { :salt => cookie_salt })` to find the appropriate record.
106
+
107
+ You can also specify a name for the 'issuer' (the name of the website) where the user is using this token:
108
+
109
+ Example
110
+
111
+ ```ruby
112
+ class User
113
+ acts_as_google_authenticated :issuer => 'your_site.com'
114
+ end
115
+ ```
116
+
117
+ By this way your user will have the name of your site at the authenticator card besides the current token.
118
+
95
119
  ## Sample Rails Setup
96
120
 
97
121
  This is a very rough outline of how GoogleAuthenticatorRails is meant to manage the sessions and cookies for a Rails app.
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- google-authenticator-rails (0.0.6)
4
+ google-authenticator-rails (0.0.7)
5
5
  actionpack
6
6
  activerecord (< 4.0.0)
7
7
  google-qr
8
- rotp (= 1.4.1)
8
+ rotp (= 1.6.1)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
@@ -23,7 +23,7 @@ GEM
23
23
  google-qr (0.2.2)
24
24
  rack (1.1.6)
25
25
  rake (10.1.1)
26
- rotp (1.4.1)
26
+ rotp (1.6.1)
27
27
  rspec (2.8.0)
28
28
  rspec-core (~> 2.8.0)
29
29
  rspec-expectations (~> 2.8.0)
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- google-authenticator-rails (0.0.6)
4
+ google-authenticator-rails (0.0.7)
5
5
  actionpack
6
6
  activerecord (< 4.0.0)
7
7
  google-qr
8
- rotp (= 1.4.1)
8
+ rotp (= 1.6.1)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
@@ -47,7 +47,7 @@ GEM
47
47
  rack-test (0.5.7)
48
48
  rack (>= 1.0)
49
49
  rake (10.1.1)
50
- rotp (1.4.1)
50
+ rotp (1.6.1)
51
51
  rspec (2.8.0)
52
52
  rspec-core (~> 2.8.0)
53
53
  rspec-expectations (~> 2.8.0)
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- google-authenticator-rails (0.0.6)
4
+ google-authenticator-rails (0.0.7)
5
5
  actionpack
6
6
  activerecord (< 4.0.0)
7
7
  google-qr
8
- rotp (= 1.4.1)
8
+ rotp (= 1.6.1)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
@@ -51,7 +51,7 @@ GEM
51
51
  rack-test (0.6.2)
52
52
  rack (>= 1.0)
53
53
  rake (10.1.1)
54
- rotp (1.4.1)
54
+ rotp (1.6.1)
55
55
  rspec (2.8.0)
56
56
  rspec-core (~> 2.8.0)
57
57
  rspec-expectations (~> 2.8.0)
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- google-authenticator-rails (0.0.6)
4
+ google-authenticator-rails (0.0.7)
5
5
  actionpack
6
6
  activerecord (< 4.0.0)
7
7
  google-qr
8
- rotp (= 1.4.1)
8
+ rotp (= 1.6.1)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
@@ -49,7 +49,7 @@ GEM
49
49
  rack-test (0.6.2)
50
50
  rack (>= 1.0)
51
51
  rake (10.1.1)
52
- rotp (1.4.1)
52
+ rotp (1.6.1)
53
53
  rspec (2.8.0)
54
54
  rspec-core (~> 2.8.0)
55
55
  rspec-expectations (~> 2.8.0)
@@ -20,12 +20,12 @@ Gem::Specification.new do |gem|
20
20
  gem.name = "google-authenticator-rails"
21
21
  gem.require_paths = ["lib"]
22
22
  gem.version = Google::Authenticator::Rails::VERSION
23
-
24
- gem.add_dependency "rotp", "= 1.4.1"
23
+
24
+ gem.add_dependency "rotp", "= 1.6.1"
25
25
  gem.add_dependency "activerecord", "< 4.0.0"
26
26
  gem.add_dependency "google-qr"
27
27
  gem.add_dependency "actionpack"
28
-
28
+
29
29
  gem.add_development_dependency "rspec", "~> 2.8.0"
30
30
  gem.add_development_dependency "appraisal", "~> 0.5.1"
31
31
  gem.add_development_dependency "sqlite3"
@@ -77,15 +77,17 @@ module GoogleAuthenticatorRails # :nodoc:
77
77
  # to "google_secret"
78
78
  # [:lookup_token] the column to use to find the record from the DB, defaults
79
79
  # to "persistence_token"
80
+ # [:issuer] the name of the issuer to appear at the app (is optional)
80
81
  def acts_as_google_authenticated(options = {})
81
82
  @google_label_column = options[:column_name] || :email
82
83
  @google_label_method = options[:method] || :default_google_label_method
83
84
  @google_secret_column = options[:google_secret_column] || :google_secret
84
85
  @google_lookup_token = options[:lookup_token] || :persistence_token
86
+ @google_issuer = options[:issuer]
85
87
 
86
88
  puts ":skip_attr_accessible is no longer required. Called from #{Kernel.caller[0]}}" if options.has_key?(:skip_attr_accessible)
87
89
 
88
- [:google_label_column, :google_label_method, :google_secret_column, :google_lookup_token].each do |cattr|
90
+ [:google_label_column, :google_label_method, :google_secret_column, :google_lookup_token, :google_issuer].each do |cattr|
89
91
  self.singleton_class.class_eval { attr_reader cattr }
90
92
  end
91
93
 
@@ -23,7 +23,7 @@ module GoogleAuthenticatorRails # :nodoc:
23
23
  end
24
24
 
25
25
  def google_qr_uri
26
- GoogleQR.new(:data => ROTP::TOTP.new(google_secret_value).provisioning_uri(google_label), :size => "200x200").to_s
26
+ GoogleQR.new(:data => ROTP::TOTP.new(google_secret_value, :issuer => google_issuer).provisioning_uri(google_label), :size => "200x200").to_s
27
27
  end
28
28
 
29
29
  def google_label
@@ -50,6 +50,10 @@ module GoogleAuthenticatorRails # :nodoc:
50
50
  def google_secret_value
51
51
  self.__send__(self.class.google_secret_column)
52
52
  end
53
+
54
+ def google_issuer
55
+ self.class.google_issuer
56
+ end
53
57
  end
54
58
  end
55
59
  end
@@ -1,7 +1,7 @@
1
1
  module Google
2
2
  module Authenticator
3
3
  module Rails
4
- VERSION = "0.0.7"
4
+ VERSION = "0.0.8"
5
5
  end
6
6
  end
7
7
  end
@@ -11,19 +11,19 @@ describe GoogleAuthenticatorRails do
11
11
 
12
12
  context 'counter = 1' do
13
13
  let(:counter) { 1 }
14
- it { should == 812658 }
14
+ it { should == 868864 }
15
15
  end
16
16
 
17
17
  context 'counter = 2' do
18
18
  let(:counter) { 2 }
19
- it { should == 73348 }
19
+ it { should == 304404 }
20
20
  end
21
21
  end
22
22
 
23
23
  context 'time-based passwords' do
24
24
  let(:time) { Time.parse("2012-08-07 11:11:11 AM +0700") }
25
25
  let(:secret) { "test" }
26
- let(:code) { 472374 }
26
+ let(:code) { 922511 }
27
27
  before { Time.stub!(:now).and_return(time) }
28
28
 
29
29
  specify { GoogleAuthenticatorRails::time_based_password(secret).should == code }
@@ -47,7 +47,7 @@ describe GoogleAuthenticatorRails do
47
47
  end
48
48
 
49
49
  context 'code validation' do
50
- subject { @user.google_authentic?(472374) }
50
+ subject { @user.google_authentic?(922511) }
51
51
 
52
52
  it { should be true }
53
53
 
@@ -75,7 +75,7 @@ describe GoogleAuthenticatorRails do
75
75
  end
76
76
 
77
77
  it 'validates code' do
78
- @user.google_authentic?(472374).should be_true
78
+ @user.google_authentic?(922511).should be_true
79
79
  end
80
80
 
81
81
  it 'generates a url for a qr code' do
metadata CHANGED
@@ -1,138 +1,120 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: google-authenticator-rails
3
- version: !ruby/object:Gem::Version
4
- hash: 17
5
- prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 7
10
- version: 0.0.7
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Jared McFarland
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2014-01-17 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- version_requirements: &id001 !ruby/object:Gem::Requirement
22
- none: false
23
- requirements:
24
- - - "="
25
- - !ruby/object:Gem::Version
26
- hash: 5
27
- segments:
28
- - 1
29
- - 4
30
- - 1
31
- version: 1.4.1
32
- prerelease: false
33
- type: :runtime
11
+ date: 2014-02-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
34
14
  name: rotp
35
- requirement: *id001
36
- - !ruby/object:Gem::Dependency
37
- version_requirements: &id002 !ruby/object:Gem::Requirement
38
- none: false
39
- requirements:
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.6.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.6.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: activerecord
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
40
31
  - - <
41
- - !ruby/object:Gem::Version
42
- hash: 63
43
- segments:
44
- - 4
45
- - 0
46
- - 0
32
+ - !ruby/object:Gem::Version
47
33
  version: 4.0.0
48
- prerelease: false
49
34
  type: :runtime
50
- name: activerecord
51
- requirement: *id002
52
- - !ruby/object:Gem::Dependency
53
- version_requirements: &id003 !ruby/object:Gem::Requirement
54
- none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
62
35
  prerelease: false
63
- type: :runtime
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - <
39
+ - !ruby/object:Gem::Version
40
+ version: 4.0.0
41
+ - !ruby/object:Gem::Dependency
64
42
  name: google-qr
65
- requirement: *id003
66
- - !ruby/object:Gem::Dependency
67
- version_requirements: &id004 !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
76
- prerelease: false
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
77
48
  type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
78
56
  name: actionpack
79
- requirement: *id004
80
- - !ruby/object:Gem::Dependency
81
- version_requirements: &id005 !ruby/object:Gem::Requirement
82
- none: false
83
- requirements:
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
84
73
  - - ~>
85
- - !ruby/object:Gem::Version
86
- hash: 47
87
- segments:
88
- - 2
89
- - 8
90
- - 0
74
+ - !ruby/object:Gem::Version
91
75
  version: 2.8.0
92
- prerelease: false
93
76
  type: :development
94
- name: rspec
95
- requirement: *id005
96
- - !ruby/object:Gem::Dependency
97
- version_requirements: &id006 !ruby/object:Gem::Requirement
98
- none: false
99
- requirements:
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 2.8.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: appraisal
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
100
87
  - - ~>
101
- - !ruby/object:Gem::Version
102
- hash: 9
103
- segments:
104
- - 0
105
- - 5
106
- - 1
88
+ - !ruby/object:Gem::Version
107
89
  version: 0.5.1
108
- prerelease: false
109
90
  type: :development
110
- name: appraisal
111
- requirement: *id006
112
- - !ruby/object:Gem::Dependency
113
- version_requirements: &id007 !ruby/object:Gem::Requirement
114
- none: false
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- hash: 3
119
- segments:
120
- - 0
121
- version: "0"
122
91
  prerelease: false
123
- type: :development
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 0.5.1
97
+ - !ruby/object:Gem::Dependency
124
98
  name: sqlite3
125
- requirement: *id007
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'
126
111
  description: Add the ability to use the Google Authenticator with ActiveRecord.
127
- email:
112
+ email:
128
113
  - jared.online@gmail.com
129
114
  executables: []
130
-
131
115
  extensions: []
132
-
133
116
  extra_rdoc_files: []
134
-
135
- files:
117
+ files:
136
118
  - .gitignore
137
119
  - .rspec
138
120
  - .ruby-gemset
@@ -174,38 +156,28 @@ files:
174
156
  - spec/spec_helper.rb
175
157
  homepage: http://github.com/jaredonline/google-authenticator
176
158
  licenses: []
177
-
159
+ metadata: {}
178
160
  post_install_message:
179
161
  rdoc_options: []
180
-
181
- require_paths:
162
+ require_paths:
182
163
  - lib
183
- required_ruby_version: !ruby/object:Gem::Requirement
184
- none: false
185
- requirements:
186
- - - ">="
187
- - !ruby/object:Gem::Version
188
- hash: 3
189
- segments:
190
- - 0
191
- version: "0"
192
- required_rubygems_version: !ruby/object:Gem::Requirement
193
- none: false
194
- requirements:
195
- - - ">="
196
- - !ruby/object:Gem::Version
197
- hash: 3
198
- segments:
199
- - 0
200
- version: "0"
164
+ required_ruby_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ! '>='
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ required_rubygems_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
201
174
  requirements: []
202
-
203
175
  rubyforge_project:
204
- rubygems_version: 1.8.24
176
+ rubygems_version: 2.2.1
205
177
  signing_key:
206
- specification_version: 3
178
+ specification_version: 4
207
179
  summary: Add the ability to use the Google Authenticator with ActiveRecord.
208
- test_files:
180
+ test_files:
209
181
  - spec/action_controller/integration_spec.rb
210
182
  - spec/action_controller/rails_adapter_spec.rb
211
183
  - spec/google_authenticator_spec.rb