two_factor_authentication 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 780c92dea8df1f3f6d1e761562e1469cc12a96a8
4
- data.tar.gz: 82e383a9f79a3628e9950a17da920eeed8464622
3
+ metadata.gz: dec5112783c16117a3f498bed06abb05be9b2206
4
+ data.tar.gz: 6a637bc5a895b60da9b46360a799cd0a54d7da59
5
5
  SHA512:
6
- metadata.gz: 31390c4f5e6e0506fc16e502a0cfa6ea908b371819f2bee9e7e14d42cec3a1ddc28ded3e584af1d650cc6c9c731ea3f4303543605d81f910fcffceec3cfaea15
7
- data.tar.gz: a2d5fe899017a753c7d106245d52f248b9f74260864a6a38129649e8e0148d17ea9da56779c45b936466278292305131f7e17e74ec6704fbdda07dfb00a6bff0
6
+ metadata.gz: 796540a1cc3c572de0a121f90da0d1c1981689a53c7560e1b6cc2f2e192a9bdca46d9c2cdb6b34a625afbd5ce972959ae58244fb513f79278c122ae8bcb8f962
7
+ data.tar.gz: 53685bf09da5ed84bc2a1c8fb2bae730e4b2fb6438afdf871f8f3db0cd8a7e37351d6a581738ea9143bd61267ac9fa9943694443acc0c03776f6651060d04c34
data/README.md CHANGED
@@ -175,14 +175,15 @@ To add them, generate a migration such as:
175
175
 
176
176
  $ rails g migration AddTwoFactorFieldsToUsers direct_otp:string direct_otp_sent_at:datetime totp_timestamp:timestamp
177
177
 
178
- The `otp_secret_key` is not only required for users who use Google Authentictor,
178
+ The `otp_secret_key` is only required for users who use TOTP (Google Authenticator) codes,
179
179
  so unless it has been shared with the user it should be set to `nil`. The
180
180
  following pseudo-code is an example of how this might be done:
181
181
 
182
182
  ```ruby
183
183
  User.find_each do |user| do
184
- if !uses_authentictor_app(user)
184
+ if !uses_authenticator_app(user)
185
185
  user.otp_secret_key = nil
186
+ user.save!
186
187
  end
187
188
  end
188
189
  ```
@@ -113,16 +113,16 @@ module Devise
113
113
 
114
114
  module EncryptionInstanceMethods
115
115
  def otp_secret_key
116
- decrypt(encrypted_otp_secret_key)
116
+ otp_decrypt(encrypted_otp_secret_key)
117
117
  end
118
118
 
119
119
  def otp_secret_key=(value)
120
- self.encrypted_otp_secret_key = encrypt(value)
120
+ self.encrypted_otp_secret_key = otp_encrypt(value)
121
121
  end
122
122
 
123
123
  private
124
124
 
125
- def decrypt(encrypted_value)
125
+ def otp_decrypt(encrypted_value)
126
126
  return encrypted_value if encrypted_value.blank?
127
127
 
128
128
  encrypted_value = encrypted_value.unpack('m').first
@@ -137,7 +137,7 @@ module Devise
137
137
  value
138
138
  end
139
139
 
140
- def encrypt(value)
140
+ def otp_encrypt(value)
141
141
  return value if value.blank?
142
142
 
143
143
  value = value.to_s
@@ -162,7 +162,7 @@ module Devise
162
162
  iv = encrypted_otp_secret_key_iv
163
163
 
164
164
  if iv.nil?
165
- algo = OpenSSL::Cipher::Cipher.new(algorithm)
165
+ algo = OpenSSL::Cipher.new(algorithm)
166
166
  iv = [algo.random_iv].pack('m')
167
167
  self.encrypted_otp_secret_key_iv = iv
168
168
  end
@@ -1,3 +1,3 @@
1
1
  module TwoFactorAuthentication
2
- VERSION = "2.0.0".freeze
2
+ VERSION = "2.0.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: two_factor_authentication
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.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: 2017-05-11 00:00:00.000000000 Z
11
+ date: 2017-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails