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