google-authenticator-rails 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/google-authenticator-rails/version.rb +1 -1
- data/lib/tasks/google_authenticator.rake +55 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ae116066dcdcca361997f0f22706e59454f8b4b
|
4
|
+
data.tar.gz: 6fb7e9435cdd2e8e69cd90e294fde9c0780587b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aeaee230b02e18fdcc3d7eddd7e891329d5420af79b0be27d6ad1b6e1c844586e492b66997b86482d6a5c82a2d542e163e484f3eae31e797542e92a0b289ab7
|
7
|
+
data.tar.gz: db86ad2e95458da74abffd87f401a5406793146dc4354536e53f8db111b01fc57379ba65a6cf8430c50b968c2c57e3289f4d874482dbd0036a40f3297661e305
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,55 @@
|
|
1
|
+
namespace :google_authenticator do
|
2
|
+
|
3
|
+
def do_encrypt(args, already_encrypted, op_name)
|
4
|
+
model_names = if args[:optional_model_list]
|
5
|
+
args.extras.unshift(args[:optional_model_list])
|
6
|
+
else
|
7
|
+
# Adapted from https://stackoverflow.com/a/8248849/7478194
|
8
|
+
Dir[Rails.root.join('app/models/*.rb').to_s].map { |filename| File.basename(filename, '.rb').camelize }
|
9
|
+
end
|
10
|
+
|
11
|
+
ActiveRecord::Base.transaction do
|
12
|
+
match_op = " = #{already_encrypted ? 138 : 16}"
|
13
|
+
model_names.each do |model_name|
|
14
|
+
klass = model_name.constantize
|
15
|
+
next unless klass.ancestors.include?(ActiveRecord::Base) && klass.try(:google_secrets_encrypted)
|
16
|
+
print "#{op_name}ing model #{klass.name.inspect} (table #{klass.table_name.inspect}): "
|
17
|
+
count = 0
|
18
|
+
klass.where("LENGTH(#{klass.google_secret_column})#{match_op}").find_each do |record|
|
19
|
+
yield record
|
20
|
+
count += 1
|
21
|
+
end
|
22
|
+
puts "#{count} #{'secret'.pluralize(count)} #{op_name}ed"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'Encrypt all secret columns (add the :encrypt_secrets options *before* running)'
|
28
|
+
task :encrypt_secrets, [:optional_model_list] => :environment do |_t, args|
|
29
|
+
do_encrypt(args, false, 'Encrypt') { |record| record.encrypt_google_secret! }
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'Re-encrypt all secret columns from old_secret_key_base to secret_key_base'
|
33
|
+
task :reencrypt_secrets, [:optional_model_list] => :environment do |_t, args|
|
34
|
+
if Rails.application.secrets.old_secret_key_base.blank?
|
35
|
+
puts 'old_secret_key_base is not set in config/secrets.yml'
|
36
|
+
else
|
37
|
+
secret_encryptor = GoogleAuthenticatorRails::ActiveRecord::Helpers.get_google_secret_encryptor
|
38
|
+
Rails.application.secrets[:secret_key_base] = Rails.application.secrets.old_secret_key_base
|
39
|
+
Rails.application.instance_eval { @caching_key_generator = nil }
|
40
|
+
old_secret_encryptor = GoogleAuthenticatorRails::ActiveRecord::Helpers.get_google_secret_encryptor
|
41
|
+
do_encrypt(args, true, 'Re-encrypt') do |record|
|
42
|
+
GoogleAuthenticatorRails.secret_encryptor = old_secret_encryptor
|
43
|
+
plain_secret = record.google_secret_value
|
44
|
+
GoogleAuthenticatorRails.secret_encryptor = secret_encryptor
|
45
|
+
record.send(:change_google_secret_to!, plain_secret)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
desc 'Decrypt all secret columns (remove the :encrypt_secrets options *after* running)'
|
51
|
+
task :decrypt_secrets, [:optional_model_list] => :environment do |_t, args|
|
52
|
+
do_encrypt(args, true, 'Decrypt') { |record| record.send(:change_google_secret_to!, record.google_secret_value, false) }
|
53
|
+
end
|
54
|
+
|
55
|
+
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.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared McFarland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rotp
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- lib/google-authenticator-rails/session/base.rb
|
178
178
|
- lib/google-authenticator-rails/session/persistence.rb
|
179
179
|
- lib/google-authenticator-rails/version.rb
|
180
|
+
- lib/tasks/google_authenticator.rake
|
180
181
|
- spec/action_controller/integration_spec.rb
|
181
182
|
- spec/action_controller/rails_adapter_spec.rb
|
182
183
|
- spec/google_authenticator_spec.rb
|