panda_pal 2.0.5 → 3.0.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd2cd5dc90e37ab172c4fcfa40d08c423bd91a9a
|
4
|
+
data.tar.gz: 41d62864c7f935dd73f0de1dfbf5f1429e03f1d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a208fafdfa5df93a8109354003f43386ada84d4a952d3953ff6324d5b60458acc60833d369ce138cf6cadf32c61fd912ab15d08fea1025942946ac0096065c0c
|
7
|
+
data.tar.gz: 43aca646ccde51f27aa8d7fdf3b1127d5b90329df69d216be8b0dee7dc57421ce317082d63f34a136c147720489a19872f62e1b574c4cc9a6cb348653965b32f
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module PandaPal
|
2
2
|
class Organization < ActiveRecord::Base
|
3
|
-
|
3
|
+
attribute :settings
|
4
|
+
attr_encrypted :settings, marshal: true, key: :encryption_key
|
5
|
+
before_save {|a| a.settings = a.settings} # this is a hacky work-around to a bug where attr_encrypted is not saving settings in place
|
4
6
|
validates :key, uniqueness: { case_sensitive: false }, presence: true
|
5
7
|
validates :secret, presence: true
|
6
8
|
validates :name, uniqueness: { case_sensitive: false }, presence: true, format: { with: /\A[a-z0-9_]+\z/i }
|
@@ -16,6 +18,16 @@ module PandaPal
|
|
16
18
|
|
17
19
|
serialize :settings, Hash
|
18
20
|
|
21
|
+
def encryption_key
|
22
|
+
# production environment might not have loaded secret_key_base yet.
|
23
|
+
# In that case, just read it from env.
|
24
|
+
if (Rails.application.secrets.secret_key_base)
|
25
|
+
Rails.application.secrets.secret_key_base[0,32]
|
26
|
+
else
|
27
|
+
ENV["SECRET_KEY_BASE"][0,32]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
19
31
|
private
|
20
32
|
|
21
33
|
def create_schema
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class EncryptOrganizationSettings < ActiveRecord::Migration[5.1]
|
2
|
+
def up
|
3
|
+
rename_column :panda_pal_organizations, :settings, :old_settings
|
4
|
+
add_column :panda_pal_organizations, :encrypted_settings, :text
|
5
|
+
add_column :panda_pal_organizations, :encrypted_settings_iv, :string
|
6
|
+
end
|
7
|
+
|
8
|
+
def down
|
9
|
+
rename_column :panda_pal_organizations, :old_settings, :settings
|
10
|
+
remove_column :panda_pal_organizations, :encrypted_settings
|
11
|
+
remove_column :panda_pal_organizations, :encrypted_settings_iv
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class RemoveOldOrganizationSettings < ActiveRecord::Migration[5.1]
|
2
|
+
def up
|
3
|
+
# migrations run for public and local tenants. However, PandaPal::Organization
|
4
|
+
# is going to always go to public tenant. So don't do this active record
|
5
|
+
# stuff unless we are on the public tenant.
|
6
|
+
if current_tenant == 'public'
|
7
|
+
#PandaPal::Organization.connection.schema_cache.clear!
|
8
|
+
#PandaPal::Organization.reset_column_information
|
9
|
+
PandaPal::Organization.find_each do |o|
|
10
|
+
# Would like to just be able to do this:
|
11
|
+
# o.settings = YAML.load(o.old_settings)
|
12
|
+
# o.save!
|
13
|
+
# but for some reason that is always making the settings null. Instead we will encrypt the settings manually.
|
14
|
+
|
15
|
+
iv = SecureRandom.random_bytes(12)
|
16
|
+
key = o.encryption_key
|
17
|
+
encrypted_settings = PandaPal::Organization.encrypt_settings(YAML.load(o.old_settings), iv: iv, key: key)
|
18
|
+
o.update_columns(encrypted_settings_iv: [iv].pack("m"), encrypted_settings: encrypted_settings)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
remove_column :panda_pal_organizations, :old_settings
|
22
|
+
end
|
23
|
+
|
24
|
+
def down
|
25
|
+
add_column :panda_pal_organizations, :old_settings, :text
|
26
|
+
if current_tenant == 'public'
|
27
|
+
PandaPal::Organization.find_each do |o|
|
28
|
+
o.old_settings = o.settings.to_yaml
|
29
|
+
o.save
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/panda_pal/version.rb
CHANGED
data/panda_pal.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_dependency 'apartment', '~> 1.2.0'
|
21
21
|
s.add_dependency 'ims-lti', '~> 2.1.0'
|
22
22
|
s.add_dependency 'browser', '2.5.0'
|
23
|
+
s.add_dependency 'attr_encrypted', '~> 3.0.0'
|
23
24
|
|
24
25
|
s.add_development_dependency 'rspec-rails'
|
25
26
|
s.add_development_dependency 'factory_girl_rails'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: panda_pal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Young
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-12-
|
12
|
+
date: 2017-12-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -81,6 +81,20 @@ dependencies:
|
|
81
81
|
- - '='
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: 2.5.0
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: attr_encrypted
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 3.0.0
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 3.0.0
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
99
|
name: rspec-rails
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,6 +165,8 @@ files:
|
|
151
165
|
- db/migrate/20160413135653_create_panda_pal_sessions.rb
|
152
166
|
- db/migrate/20160425130344_add_panda_pal_organization_to_session.rb
|
153
167
|
- db/migrate/20170106165533_add_salesforce_id_to_organizations.rb
|
168
|
+
- db/migrate/30171205183457_encrypt_organization_settings.rb
|
169
|
+
- db/migrate/30171205194657_remove_old_organization_settings.rb
|
154
170
|
- lib/panda_pal.rb
|
155
171
|
- lib/panda_pal/engine.rb
|
156
172
|
- lib/panda_pal/helpers.rb
|