mirror of
https://github.com/mediacms-io/mediacms.git
synced 2026-02-04 06:22:59 -05:00
wtv
This commit is contained in:
22
lti/views.py
22
lti/views.py
@@ -240,16 +240,18 @@ class LaunchView(View):
|
||||
if media_token:
|
||||
logger.error(f"[LTI LAUNCH DEBUG] Found media_friendly_token in custom claims: {media_token}")
|
||||
|
||||
# Check if media token was passed via OIDC session data (from filter launch)
|
||||
# The state from the OIDC flow is used to retrieve session data
|
||||
state = request.POST.get('state')
|
||||
if state and not media_token:
|
||||
session_key = f'state-{state}'
|
||||
launch_session_data = request.session.get(session_key, {})
|
||||
logger.error(f"[LTI LAUNCH DEBUG] Checking OIDC session data for state {state}: {launch_session_data}")
|
||||
media_token = launch_session_data.get('media_friendly_token')
|
||||
if media_token:
|
||||
logger.error(f"[LTI LAUNCH DEBUG] Found media_friendly_token in OIDC session data: {media_token}")
|
||||
# Check if media token was passed via target_link_uri query parameter (from filter launch)
|
||||
if not media_token:
|
||||
target_link_uri = launch_data.get('https://purl.imsglobal.org/spec/lti/claim/target_link_uri', '')
|
||||
logger.error(f"[LTI LAUNCH DEBUG] target_link_uri: {target_link_uri}")
|
||||
if '?media_token=' in target_link_uri or '&media_token=' in target_link_uri:
|
||||
from urllib.parse import parse_qs, urlparse
|
||||
|
||||
parsed = urlparse(target_link_uri)
|
||||
params = parse_qs(parsed.query)
|
||||
media_token = params.get('media_token', [None])[0]
|
||||
if media_token:
|
||||
logger.error(f"[LTI LAUNCH DEBUG] Found media_token in target_link_uri: {media_token}")
|
||||
|
||||
# Store media_token in session for determine_redirect to use
|
||||
if media_token:
|
||||
|
||||
@@ -70,20 +70,27 @@ $instance->launchcontainer = LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS;
|
||||
// Get type config
|
||||
$typeconfig = lti_get_type_type_config($ltitoolid);
|
||||
|
||||
// Store media token in session so we can add it to lti_message_hint
|
||||
// This is how Moodle passes extra data through the LTI launch
|
||||
$launchid = 'filter_mediacms_' . uniqid();
|
||||
if (!isset($SESSION->lti_initiatelogin_data)) {
|
||||
$SESSION->lti_initiatelogin_data = [];
|
||||
// Override the tool URL to include media token as query parameter
|
||||
// This way MediaCMS receives it in the target_link_uri
|
||||
if (is_array($typeconfig)) {
|
||||
$baseurl = $typeconfig['toolurl'] ?? $mediacmsurl . '/lti/launch/';
|
||||
$typeconfig['toolurl'] = $baseurl . '?media_token=' . urlencode($mediatoken);
|
||||
if (isset($typeconfig['toolurl_secure'])) {
|
||||
$baseurl_secure = $typeconfig['toolurl_secure'];
|
||||
$typeconfig['toolurl_secure'] = $baseurl_secure . '?media_token=' . urlencode($mediatoken);
|
||||
}
|
||||
} else {
|
||||
$baseurl = $typeconfig->toolurl ?? $mediacmsurl . '/lti/launch/';
|
||||
$typeconfig->toolurl = $baseurl . '?media_token=' . urlencode($mediatoken);
|
||||
if (isset($typeconfig->toolurl_secure)) {
|
||||
$baseurl_secure = $typeconfig->toolurl_secure;
|
||||
$typeconfig->toolurl_secure = $baseurl_secure . '?media_token=' . urlencode($mediatoken);
|
||||
}
|
||||
}
|
||||
$SESSION->lti_initiatelogin_data[$launchid] = [
|
||||
'media_friendly_token' => $mediatoken,
|
||||
'courseid' => $courseid,
|
||||
];
|
||||
|
||||
// Use Moodle's LTI launch function to initiate OIDC properly
|
||||
// Pass the launchid so Moodle includes it in lti_message_hint
|
||||
$content = lti_initiate_login($course->id, $launchid, $instance, $typeconfig, null, 'MediaCMS video resource');
|
||||
// Pass null for cmid since we don't have a real course module
|
||||
$content = lti_initiate_login($course->id, null, $instance, $typeconfig, null, 'MediaCMS video resource');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $content;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2026012805; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2026012806; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2024100700; // Requires Moodle 5.0 or later.
|
||||
$plugin->component = 'filter_mediacmslti'; // Full name of the plugin (used for diagnostics).
|
||||
$plugin->maturity = MATURITY_STABLE;
|
||||
|
||||
Reference in New Issue
Block a user