panda_pal 5.14.0.beta6 → 5.14.0.beta8
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/config/initializers/apartment.rb +13 -12
- data/lib/panda_pal/helpers/controller_helper.rb +25 -27
- data/lib/panda_pal/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96e6b46ee78bbd2cec669b0a996af2731f2993869e17b8a911251ed58ff032e8
|
4
|
+
data.tar.gz: d166c1cce9c738d7b273f9a634cd0b0e315d938fb8950156e43870fdc8230d30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbe53c4546c8ef0d7552a2fc25e8522ccaf64d290a68802dee2b53525ef25d76e677870e9f9a05232eebcf20acb5e85a9d230afcfb2b03c56a68aec9b40d6202
|
7
|
+
data.tar.gz: 39bfddb95032c0070c3776b998536fd83fca8b013d3a0b6b4438889c57f7b26f52ee3394dfed124d9565a38f41a34c8e7e6b2fab329aba4816ed39cbbb809ede
|
@@ -220,18 +220,19 @@ Apartment.configure do |config|
|
|
220
220
|
end
|
221
221
|
|
222
222
|
Rails.application.config.middleware.use Apartment::Elevators::Generic, lambda { |request|
|
223
|
-
if match = request.path.match(/\/(?:orgs?|organizations?)\/(\d+)/)
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
223
|
+
tenant = if match = request.path.match(/\/(?:orgs?|organizations?)\/(\d+)/)
|
224
|
+
PandaPal::Organization.find_by(id: match[1]).try(:tenant_name)
|
225
|
+
elsif match = request.path.match(/\/(?:orgs?|organizations?|o)\/(\w+)/)
|
226
|
+
PandaPal::Organization.find_by(name: match[1]).try(:tenant_name)
|
227
|
+
elsif (panda_token = PandaPal::Helpers::SessionReplacement.extract_panda_token(request)).present?
|
228
|
+
header, sig = panda_token.split('.')
|
229
|
+
# This is just switching the tenant. Auth should be performed elsewhere (eg via `forbid_access_if_lacking_session`/`valid_session?`).
|
230
|
+
decoded_header = JSON.parse(Base64.urlsafe_decode64(header))
|
231
|
+
PandaPal::Organization.find_by(id: decoded_header['o']).try(:tenant_name)
|
232
|
+
elsif request.path.start_with?('/rails/active_storage/blobs/')
|
233
|
+
PandaPal::Organization.find_by(id: request.params['organization_id']).try(:tenant_name)
|
234
|
+
end
|
235
|
+
tenant || 'public'
|
235
236
|
}
|
236
237
|
|
237
238
|
module PandaPal::Plugins::ApartmentCache
|
@@ -69,43 +69,41 @@ module PandaPal::Helpers
|
|
69
69
|
def validate_v1p3_launch
|
70
70
|
require "json/jwt"
|
71
71
|
|
72
|
-
|
72
|
+
Apartment::Tenant.switch!("public")
|
73
73
|
|
74
|
-
|
75
|
-
|
76
|
-
raise JSON::JWT::VerificationFailed, 'error decoding id_token' if decoded_jwt.blank?
|
74
|
+
decoded_jwt = JSON::JWT.decode(params.require(:id_token), :skip_verification)
|
75
|
+
raise JSON::JWT::VerificationFailed, 'error decoding id_token' if decoded_jwt.blank?
|
77
76
|
|
78
|
-
|
79
|
-
|
77
|
+
client_id = decoded_jwt['aud']
|
78
|
+
deployment_id = decoded_jwt['https://purl.imsglobal.org/spec/lti/claim/deployment_id']
|
80
79
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
if deployment_id.present?
|
81
|
+
@organization ||= PandaPal::Organization.find_by(key: "#{client_id}/#{deployment_id}")
|
82
|
+
@organization ||= PandaPal::Organization.find_by(key: deployment_id)
|
83
|
+
end
|
85
84
|
|
86
|
-
|
85
|
+
@organization ||= PandaPal::Organization.find_by(key: client_id)
|
87
86
|
|
88
|
-
|
87
|
+
params[:session_key] = params[:state]
|
89
88
|
|
90
|
-
|
91
|
-
|
89
|
+
raise JSON::JWT::VerificationFailed, 'Unrecognized Organization' unless @organization.present?
|
90
|
+
raise JSON::JWT::VerificationFailed, 'Organization does not trust platform' unless @organization.trusted_platform?(current_lti_platform)
|
92
91
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
92
|
+
begin
|
93
|
+
decoded_jwt.verify!(current_lti_platform.public_jwks)
|
94
|
+
rescue JSON::JWK::Set::KidNotFound
|
95
|
+
decoded_jwt.verify!(current_lti_platform.public_jwks(force: true))
|
96
|
+
end
|
98
97
|
|
99
|
-
|
100
|
-
|
98
|
+
raise JSON::JWT::VerificationFailed, 'State is invalid' unless current_panda_session.panda_pal_organization_id == 0
|
99
|
+
raise JSON::JWT::VerificationFailed, 'State is invalid' unless current_panda_session[:lti_oauth_nonce] == decoded_jwt['nonce']
|
101
100
|
|
102
|
-
|
103
|
-
|
101
|
+
jwt_verifier = PandaPal::LtiJwtValidator.new(decoded_jwt, client_id)
|
102
|
+
raise JSON::JWT::VerificationFailed, jwt_verifier.errors unless jwt_verifier.valid?
|
104
103
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
end
|
104
|
+
# Migrate the session to the correct tenant
|
105
|
+
login_session = current_panda_session
|
106
|
+
login_session.delete
|
109
107
|
|
110
108
|
@organization.switch_tenant
|
111
109
|
|
data/lib/panda_pal/version.rb
CHANGED