-
Notifications
You must be signed in to change notification settings - Fork 25
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
Cookies are always empty. #54
Comments
@ronnela Can you provide more context for how you encountered this error? Any details you can share about the requests being made during the launch would be helpful, along with your implementation of the |
The Launch is coming from Canvas which is on different domain and that is why the cookie is always empty because of cross-origin rule. |
This library isn't reliant on a cookie from Canvas, however it does set one for the tool provider domain. Can you provide more details of your implementation, specifically the |
I'm marking this issue as closed for the time being. If we get more information, we can reopen it. |
Hi @dbhynds Sorry I was assigned to work on another project but I am back on this now. Here is the ICookie namespace App\LTIStorage; use Illuminate\Support\Facades\Cookie; class Lti13Cookie implements ICookie
} And here is what it looks like its requiring the use of cookie lti-1-3-php-library/src/LtiMessageLaunch.php Line 359 in d89c674
|
I'm having the same issue.
I think Cookie::queue is not actually attaching a cookie to the response |
Here's a high level overview of how it's working in our system:
function login(Request $request, IDatabase $db, ICache $cache, ICookie $cookie) {
$redirectUrl = LtiOidcLogin::new($db, $cache, $cookie)
->doOidcLoginRedirect('https://ourdomain.com/lti/launch', $request->all())
->getRedirectUrl();
return redirect($url);
}
function launch(Request $request, IDatabase $db, ICache $cache, ICookie $cookie, ILtiServiceConnector $serviceConnector) {
$launch = LtiMessageLaunch::new($db, $cache, $cookie, $serviceConnector)
->validate($request->all());
$ltiData = $launch->getLaunchData();
// Do whatever after that.
} How does that compare to what you're doing? Are you able to see the cookie being attached to the redirect back to the LMS? What about the subsequent launch request? As I mentioned, we have this working in our production infrastructure, so my guess is there some configuration issue with your app (or perhaps the LMS). Unrelated (and I'll update the documentation), but I noticed some typing issues in the public function getCookie(string $name): ?string
{
return Cookie::get($name);
} |
Thanks for the reply. So after a bit of fiddling I managed to figure out what the issue was So I'm pretty much I was doing the same thing as mentioned above. With slight deviations in the implementation of my login and launch endpoints. I'm using Laravel 9.x (fyi). Here were my implementations of the endpoints:
I wasn't passing instances of my interfaces or the request into my login/launch endpoints. From what I gathered from the documentation it seemed as though you could pass new definitions of those interfaces. Also, when I was digging through LtiMessageLaunch and LtiOidcLogin it seemed like it captured the necessary request data. I.e. in LtiMessageLaunch:
In LtiOdicLogin:
With those previous implementations of login/launch endpoints I was getting through the login phase and getting a successful redirect from the LMS to the launch endpoint (with the correct data). I tried your endpoint examples and they fixed the issue of the missing lti1p3_state cookie. However, it seems I was still stuck with a 419 session expired issue. Firefox was discarding the cookies:
The cookie expires a minute from creation, and has these properties as defined in my config/session.php:
From my limited understanding of cookies nothing here seemed to be the issue. For the purposes of testing I omitted these routes in Middleware/VerifyCsrfToken.php which then allows LtiException to throw: However, I'm not sure this is the most secure way to do this. Should I be omitting these routes from Csfr Token Verification? |
Ahah! I totally forgot that we had to tinker with the config for cookies to get this to work, but that's totally it. Thank you, I'll update the documentation. A few notes: First, I see how--based on the interface of public function validate(array $requestPostData);
// and
public function doOidcLoginRedirect($launch_url, array $requestPostData); Thoughts on that? Second, we also have |
Just in case it helps anyone (I spent a whole day on this), I had the same problems as detailed here with the additional problem that I was using Laravel's artisan serve functionality as a web server on localhost. As this doesn't have ssl support, the cookies were never set. In the end, I used the instructions here to setup https on Vite and then use that as a proxy for Laravel's web server. I then had to force Laravel to use https in boot method of the AppServiceProvider class.
|
The cookie is always empty and the Launch endpoint is giving this error
State not found. Please make sure you have cookies enabled in this browser.
The text was updated successfully, but these errors were encountered: