Class: PandaPal::LtiV1P3Controller
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- PandaPal::LtiV1P3Controller
- Defined in:
- app/controllers/panda_pal/lti_v1_p3_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#login ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/panda_pal/lti_v1_p3_controller.rb', line 18 def login @current_lti_platform = PandaPal::Platform.resolve_platform(params) current_session_data[:lti_platform] = @current_lti_platform&.serialize current_session_data[:lti_oauth_nonce] = SecureRandom.uuid current_session_data[:canvas_environment] = params['canvas_environment'] current_session_data[:canvas_region] = params['canvas_region'] current_session.panda_pal_organization_id = -1 @form_action = current_lti_platform.authentication_redirect_url @method = :post @form_data = { scope: 'openid', response_type: 'id_token', response_mode: 'form_post', prompt: 'none', redirect_uri: params[:target_link_uri] || v1p3_resource_link_request_url, client_id: params.require(:client_id), login_hint: params.require(:login_hint), lti_message_hint: params.require(:lti_message_hint), state: current_session.session_key, nonce: current_session_data[:lti_oauth_nonce] } end |
#public_jwks ⇒ Object
101 102 103 104 105 |
# File 'app/controllers/panda_pal/lti_v1_p3_controller.rb', line 101 def public_jwks render json: { keys: [JWT::JWK.new(PandaPal.lti_private_key).export] } end |
#resource_link_request ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/panda_pal/lti_v1_p3_controller.rb', line 43 def resource_link_request ltype = @decoded_lti_jwt['https://www.instructure.com/placement'] if ltype current_session_data.merge!({ lti_version: 'v1p3', lti_launch_placement: ltype, launch_params: @decoded_lti_jwt, }) redirect_with_session_to(:"#{LaunchUrlHelpers.launch_route(ltype)}_url", route_context: main_app) end end |
#tool_config ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'app/controllers/panda_pal/lti_v1_p3_controller.rb', line 57 def tool_config if PandaPal.lti_environments.empty? render plain: 'Domains must be set in lti_environments' return end platform = PandaPal..delete(:platform) || 'canvas.instructure.com' request_url = "#{request.scheme}://#{request.host_with_port}" parsed_request_url = URI.parse(request_url) mapped_placements = PandaPal.lti_paths.map do |k, opts| opts = LaunchUrlHelpers.normalize_lti_launch_desc(opts) opts.merge!({ placement: k, target_link_uri: LaunchUrlHelpers.absolute_launch_url( k.to_sym, host: parsed_request_url, launch_handler: v1p3_resource_link_request_path, default_auto_launch: true ), }) opts end config_json = { title: PandaPal.[:title], scopes: [], public_jwk_url: v1p3_public_jwks_url, description: PandaPal.[:description] || 'PandaPal LTI', target_link_uri: v1p3_resource_link_request_url, #app_url(:resource_link_request, request), oidc_initiation_url: v1p3_oidc_login_url, extensions: [{ platform: platform, privacy_level: "public", settings: { placements: mapped_placements, }, }], custom_fields: PandaPal.lti_custom_params, # PandaPal.lti_options[:custom_fields], } render json: config_json end |