Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #43147: LTI 1.3 Cosumer authentication fails with provider on different domain #8756

Open
wants to merge 2 commits into
base: release_8
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Modules/LTIConsumer/classes/class.ilLTIConsumerContentGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,23 @@ protected function launch(): void
$this->dic->toolbar()->addText($this->getStartButtonTxt11());
}
} else {

// Set an addititional PHPSESSID cookie for LTI 1.3 authentication
// - The standard cookie does not work with LTI tools on different domains because it has samesite = Lax
// - The additional cookie sets samesite to None so that it is sent with the POST request from the LTI tool
// - Limit the additional cookie to the path of the ltiauth.php script
// - Force secure to require HTTPS (needed for samesite = None)
// see https://web.dev/articles/samesite-cookie-recipes?hl=en#unsafe-requests

setcookie(session_name(), session_id(), [
'expires' => 0,
'path' => rtrim(IL_COOKIE_PATH, '/') . '/Modules/LTIConsumer/ltiauth.php',
'domain' => IL_COOKIE_DOMAIN,
'secure' => true,
'httponly' => true,
'samesite' => 'None'
]);

if ($this->object->isLaunchMethodEmbedded() && (ilSession::get('lti13_login_data') == null)) {
$tpl = new ilTemplate('tpl.lti_content.html', true, true, 'Modules/LTIConsumer');
$tpl->setVariable("EMBEDDED_IFRAME_SRC", $this->dic->ctrl()->getLinkTarget(
Expand Down
Loading