encrypted_field 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/lib/encrypted_field/action_view.rb +9 -0
- data/lib/encrypted_field/controller_additions.rb +17 -0
- data/lib/encrypted_field/railtie.rb +11 -0
- data/lib/encrypted_field/version.rb +1 -1
- data/lib/encrypted_field.rb +7 -1
- data/lib/tasks/generate_keypair.rake +1 -1
- data/vendor/assets/encrypted_field.js +15 -0
- data/vendor/assets/jsencrypt.js +4351 -18393
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 893b3d14ad9dd9026cb9db5a43772636c0f0a408
|
4
|
+
data.tar.gz: 41f51c9792157cc0132c5f012672dbe6f75a3e04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 908e6488ddf661e78c45e8a4002ceda346807b3f3e2120498e92967579d7904b4fac462e6da31cbf2d78142a426a60e726510ef1ba299c1629e8ac1d13232b71
|
7
|
+
data.tar.gz: 317c0334fe2fd5d3f2b0ed6ade673a4faacd9fb32f2cf3882896cd8fc11a5c63a8bc9385473355ed9c9df5f7d765edcec1fb59ed3e128e2d676ca8e5692323de
|
data/.gitignore
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module EncryptedField
|
4
|
+
module ControllerAdditions
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
included do
|
7
|
+
def decrypt_encrypted_field(value)
|
8
|
+
@private_key ||= OpenSSL::PKey::RSA.new(File.read("#{ENV['CONFIG_CERTIFICATE_PATH']}/encrypted_field_private_key.pem"))
|
9
|
+
@private_key.private_decrypt(Base64.decode64(value))
|
10
|
+
end
|
11
|
+
def encrypt_encrypted_field(value)
|
12
|
+
@private_key ||= OpenSSL::PKey::RSA.new(File.read("#{ENV['CONFIG_CERTIFICATE_PATH']}/encrypted_field_public_key.pem"))
|
13
|
+
Base64.encode64(@private_key.public_encrypt(value))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/encrypted_field.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
require "encrypted_field/version"
|
2
|
+
require 'encrypted_field/controller_additions'
|
3
|
+
require "encrypted_field/railtie" if defined?(Rails)
|
2
4
|
require "openssl"
|
3
5
|
|
4
6
|
module EncryptedField
|
5
|
-
class Engine < ::Rails::Engine
|
7
|
+
class Engine < ::Rails::Engine
|
8
|
+
initializer :assets do |config|
|
9
|
+
Rails.application.config.assets.paths << root.join("vendor", "assets")
|
10
|
+
end
|
11
|
+
end
|
6
12
|
end
|
@@ -4,7 +4,7 @@ namespace :keypair do
|
|
4
4
|
rsa_key = OpenSSL::PKey::RSA.new(2048)
|
5
5
|
private_key = rsa_key.to_pem
|
6
6
|
public_key = rsa_key.public_key.to_pem
|
7
|
-
path = (args[:path] || '.')
|
7
|
+
path = (args[:path] || ENV['CONFIG_CERTIFICATE_PATH'] || '.')
|
8
8
|
|
9
9
|
File.open("#{path}/encrypted_field_public_key.pem", "w+") do |f|
|
10
10
|
f.write public_key
|
@@ -0,0 +1,15 @@
|
|
1
|
+
//= require jsencrypt
|
2
|
+
|
3
|
+
$(document).on('turbolinks:load', function(){
|
4
|
+
$('form').submit(function( event ) {
|
5
|
+
var encrypt = new JSEncrypt();
|
6
|
+
$('[data-encrypt]').each(function(){
|
7
|
+
unencrypted = $(this);
|
8
|
+
encrypt.setKey($('#public_key').val());
|
9
|
+
encrypted = encrypt.encrypt(unencrypted.val());
|
10
|
+
if (encrypted != false) {
|
11
|
+
unencrypted.val(encrypted);
|
12
|
+
}
|
13
|
+
})
|
14
|
+
});
|
15
|
+
});
|