panda_pal 5.2.0 → 5.2.5
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/app/lib/panda_pal/misc_helper.rb +2 -0
- data/config/initializers/apartment.rb +59 -11
- data/db/migrate/20160412205931_create_panda_pal_organizations.rb +1 -1
- data/db/migrate/20160413135653_create_panda_pal_sessions.rb +1 -1
- data/db/migrate/20160425130344_add_panda_pal_organization_to_session.rb +1 -1
- data/db/migrate/20170106165533_add_salesforce_id_to_organizations.rb +1 -1
- data/db/migrate/20171205183457_encrypt_organization_settings.rb +1 -1
- data/db/migrate/20171205194657_remove_old_organization_settings.rb +1 -1
- data/lib/panda_pal/helpers/controller_helper.rb +8 -6
- data/lib/panda_pal/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc40f9ca1d3a036a82a30105f8390bfe9faf57519ca977040921999c1e97221c
|
4
|
+
data.tar.gz: 01cca7d9851d83e6d2029291fde3f0baba97c1ba46e51287211b9769f803ae7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f41f229e1d8101ce9de5ba9d97ec3e8a3a96b5a11d5fa7972534df8e1d2226172db2e82c3af17f228cc48b1ceb0f8e71e6ded9ed08308c9124a45365e89cf8fa
|
7
|
+
data.tar.gz: 29dbfab39a1b5445d31975306af414e336f0a3965c2fd5426e90335963d4da50238c69c7232a66248ad4f7524b7fd3444fc01d2a535ba4e1414aa2f02267b1bc
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'apartment/elevators/generic'
|
2
2
|
|
3
3
|
Apartment.configure do |config|
|
4
|
-
config.excluded_models
|
4
|
+
config.excluded_models ||= []
|
5
|
+
config.excluded_models |= ['PandaPal::Organization', 'PandaPal::Session']
|
5
6
|
|
6
7
|
config.tenant_names = lambda {
|
7
8
|
PandaPal::Organization.pluck(:name)
|
@@ -14,6 +15,21 @@ Rails.application.config.middleware.use Apartment::Elevators::Generic, lambda {
|
|
14
15
|
end
|
15
16
|
}
|
16
17
|
|
18
|
+
module PandaPal::Plugins::ApartmentCache
|
19
|
+
private
|
20
|
+
|
21
|
+
if Rails.version >= '5.0'
|
22
|
+
def normalize_key(key, options)
|
23
|
+
"tenant:#{Apartment::Tenant.current}/#{super}"
|
24
|
+
end
|
25
|
+
else
|
26
|
+
def namespaced_key(*args)
|
27
|
+
"tenant:#{Apartment::Tenant.current}/#{super}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
ActiveSupport::Cache::Store.send(:prepend, PandaPal::Plugins::ApartmentCache)
|
32
|
+
|
17
33
|
if defined?(ActionCable)
|
18
34
|
module ActionCable
|
19
35
|
module Channel
|
@@ -38,7 +54,7 @@ if defined?(ActionCable)
|
|
38
54
|
end
|
39
55
|
end
|
40
56
|
|
41
|
-
module ActionCableApartment
|
57
|
+
module PandaPal::Plugins::ActionCableApartment
|
42
58
|
module Connection
|
43
59
|
def tenant=(name)
|
44
60
|
@tenant = name
|
@@ -56,18 +72,50 @@ if defined?(ActionCable)
|
|
56
72
|
end
|
57
73
|
end
|
58
74
|
|
59
|
-
ActionCable::Connection::Base.prepend(ActionCableApartment::Connection)
|
75
|
+
ActionCable::Connection::Base.prepend(PandaPal::Plugins::ActionCableApartment::Connection)
|
60
76
|
end
|
61
77
|
|
62
|
-
|
63
|
-
|
78
|
+
if defined?(Delayed)
|
79
|
+
module PandaPal::Plugins
|
80
|
+
class ApartmentDelayedJobsPlugin < ::Delayed::Plugin
|
81
|
+
callbacks do |lifecycle|
|
82
|
+
lifecycle.around(:enqueue) do |job, *args, &block|
|
83
|
+
current_tenant = Apartment::Tenant.current
|
64
84
|
|
65
|
-
|
66
|
-
|
67
|
-
|
85
|
+
#make sure enqueue on public tenant unless we are testing since delayed job is set to run immediately
|
86
|
+
Apartment::Tenant.switch!('public') unless Rails.env.test?
|
87
|
+
job.tenant = current_tenant
|
88
|
+
begin
|
89
|
+
block.call(job, *args)
|
90
|
+
rescue Exception => e
|
91
|
+
Rails.logger.error("Error enqueing job #{job.to_s} - #{e.backtrace}")
|
92
|
+
ensure
|
93
|
+
#switch back to prev tenant
|
94
|
+
Apartment::Tenant.switch!(current_tenant)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
lifecycle.before(:perform) do |worker, *args, &block|
|
99
|
+
tenant = args.first.tenant
|
100
|
+
Apartment::Tenant.switch!(tenant) if tenant.present?
|
101
|
+
Rails.logger.debug("Running job with tenant #{Apartment::Tenant.current}")
|
102
|
+
end
|
103
|
+
|
104
|
+
lifecycle.around(:invoke_job) do |job, *args, &block|
|
105
|
+
begin
|
106
|
+
block.call(job, *args)
|
107
|
+
ensure
|
108
|
+
Apartment::Tenant.switch!('public')
|
109
|
+
Rails.logger.debug("Resetting Tenant back to: #{Apartment::Tenant.current}")
|
110
|
+
end
|
111
|
+
end
|
68
112
|
|
69
|
-
|
70
|
-
|
113
|
+
lifecycle.after(:failure) do |job, *args|
|
114
|
+
Rails.logger.error("Job failed on tenant: #{Apartment::Tenant.current}")
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
71
118
|
end
|
119
|
+
|
120
|
+
Delayed::Worker.plugins << PandaPal::Plugins::ApartmentDelayedJobsPlugin
|
72
121
|
end
|
73
|
-
ActiveSupport::Cache::Store.send :prepend, ApartmentCache
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddPandaPalOrganizationToSession <
|
1
|
+
class AddPandaPalOrganizationToSession < PandaPal::MiscHelper::MigrationClass
|
2
2
|
def change
|
3
3
|
add_column :panda_pal_sessions, :panda_pal_organization_id, :integer
|
4
4
|
add_index :panda_pal_sessions, :panda_pal_organization_id
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class EncryptOrganizationSettings <
|
1
|
+
class EncryptOrganizationSettings < PandaPal::MiscHelper::MigrationClass
|
2
2
|
def up
|
3
3
|
# don't rerun this if it was already run before we renamed the migration.
|
4
4
|
existing_versions = execute ("SELECT * from schema_migrations where version = '30171205183457'")
|
@@ -3,7 +3,7 @@ require 'browser'
|
|
3
3
|
module PandaPal::Helpers::ControllerHelper
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
-
class
|
6
|
+
class SessionNonceMismatch < StandardError; end
|
7
7
|
|
8
8
|
included do
|
9
9
|
helper_method :link_nonce, :current_session
|
@@ -22,17 +22,16 @@ module PandaPal::Helpers::ControllerHelper
|
|
22
22
|
payload = JSON.parse(panda_pal_cryptor.decrypt_and_verify(params[:session_token])).with_indifferent_access
|
23
23
|
matched_session = PandaPal::Session.find_by(session_key: payload[:session_key])
|
24
24
|
|
25
|
-
if matched_session.present? && matched_session.data[:link_nonce] ==
|
25
|
+
if matched_session.present? && matched_session.data[:link_nonce] == payload[:nonce]
|
26
26
|
@current_session = matched_session
|
27
27
|
@current_session.data[:link_nonce] = nil
|
28
28
|
end
|
29
|
+
raise SessionNonceMismatch, "Session Not Found" unless @current_session.present?
|
29
30
|
elsif (session_key = params[:session_key] || session_key_header || flash[:session_key] || session[:session_key]).present?
|
30
31
|
@current_session = PandaPal::Session.find_by(session_key: session_key) if session_key.present?
|
31
|
-
else
|
32
|
-
@current_session = PandaPal::Session.new(panda_pal_organization_id: current_organization.id)
|
33
32
|
end
|
34
33
|
|
35
|
-
|
34
|
+
@current_session ||= PandaPal::Session.new(panda_pal_organization_id: current_organization.id)
|
36
35
|
|
37
36
|
@current_session
|
38
37
|
end
|
@@ -154,6 +153,8 @@ module PandaPal::Helpers::ControllerHelper
|
|
154
153
|
current_session.panda_pal_organization_id == current_organization.id,
|
155
154
|
Apartment::Tenant.current == current_organization.name
|
156
155
|
].all?
|
156
|
+
rescue SessionNonceMismatch
|
157
|
+
false
|
157
158
|
end
|
158
159
|
|
159
160
|
def safari_override
|
@@ -166,7 +167,8 @@ module PandaPal::Helpers::ControllerHelper
|
|
166
167
|
# nicely with webpack-dev-server live reloading (otherwise
|
167
168
|
# you get an access error everytime it tries to live reload).
|
168
169
|
|
169
|
-
def redirect_with_session_to(location, params = {}, route_context: self)
|
170
|
+
def redirect_with_session_to(location, params = {}, route_context: self, **rest)
|
171
|
+
params.merge!(rest)
|
170
172
|
if Rails.env.development?
|
171
173
|
redirect_to route_context.send(location, {
|
172
174
|
session_key: current_session.session_key,
|
data/lib/panda_pal/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: panda_pal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.2.
|
4
|
+
version: 5.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Instructure ProServe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|