Giter Club home page Giter Club logo

lib-lti1p3-core's Introduction

TAO - LTI 1.3 Core Library

Latest Version License GPL2 Build Status Tests Coverage Status Psalm Level Status Packagist Downloads IMS Certified

IMS certified PHP library for LTI 1.3 Core implementations as platforms and / or as tools.

Table of contents

TAO LTI 1.3 PHP framework

This library is part of the TAO LTI 1.3 PHP framework.

IMS

You can find below IMS related information.

Related certifications

Related specifications

Installation

$ composer require oat-sa/lib-lti1p3-core

Documentation

You can find below the library documentation, presented by topics.

Quick start

Messages interactions

Services interactions

Wiki

You can find more information in the library wiki.

Tests

To run tests:

$ vendor/bin/phpunit

Note: see phpunit.xml.dist for available test suites.

lib-lti1p3-core's People

Contributors

andreluizmachado avatar edwin-focaloid avatar ekkinox avatar emgolubev avatar ericbouwers avatar florenceoat avatar gitromba avatar kochen avatar major66 avatar mike-ionut-mihai-sandu-tao avatar peetya avatar poyuki avatar serpentblade avatar wazelin avatar weaverryan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lib-lti1p3-core's Issues

[Question] How to embed this library in my Tool ( based on PHP codeigniter) ?

Hi everyone , I am new in LTI 1.3 - tao ,so for me this a bit hard to understand how to embed this library into my tool. For LMS , I am using Moodle .
If is there any example code availble for this library use by a Tool based on PHP , If available for demo purpose Can someone please share me?
I just confued about the workflow . That example code maybe help me to understand the complete architecture.

Thanks in Advance ! @Cicatrice

phpseclib vulnerable to denial of service

+-------------------+----------------------------------------------------------------------------------+
| Package           | phpseclib/phpseclib                                                              |
| CVE               | CVE-2023-49316                                                                   |
| Title             | phpseclib vulnerable to denial of service                                        |
| URL               | https://github.com/advisories/GHSA-jpr7-q523-hx25                                |
| Affected versions | <3.0.34                                                                          |
| Reported at       | 2023-11-27T18:31:14+00:00                                                        |
+-------------------+----------------------------------------------------------------------------------+

Update to 3.0.34

Update lcobucci/jwt

Hello, Is it possible to update this package 'lcobucci/jwt' to a newer version (^5.0) ?

what is authenticity_token during OIDC Authentication on platform side

Hi, I'm buidling LTI Platform using LTI Reference Implementation, during content selection, I redirected to login_initiations on lti-ri, then I click send post request and it bring me to my platform oidc init,
I try OidcAuthenticator and authenticate $request, but it fails with message

OIDC authentication failed: Argument 1 passed to OAT\Library\Lti1p3Core\Security\Jwt\Parser\Parser::parse() must be of the type string, null given, called in //vendor/oat-sa/lib-lti1p3-core/src/Security/Oidc/OidcAuthenticator.php on line 82

after I dump the $request, I get parsedBody

array:3 [▼
  "utf8" => "✓"
  "authenticity_token" => "MKLZdolGU4StoBaZDvKSMl0d70BXTXHT2AFIEyPn+1KTCVnKgh64CBzQtMgYZjrCc5lAucV/Z0y4SG3jP03gyg=="
  "commit" => "Send POST request"
]

I have no idea how to auntethicate it, I can't find 'authenticity_token' on this library even on test case, I have no idea which function can handle it, any ideas how to authenticate it?

regards

"error":"invalid_jwt_token","error_description":"iat missing"

After a succed login and launch validation, when I want to getContextMembershipForPayload (Lti1p3Nrps), it fails by responding "iat missing".
I tried using OAT\Library\Lti1p3Core\Service\Client\LtiServiceClient directly. Same happens.

Whole error:
Cannot get context membership for payload: Cannot get context membership for claim: Cannot get context membership: Cannot get access token: Client error: POST https://developer.anthology.com/api/v1/gateway/oauth2/jwttoken resulted in a 400 Bad Request response: {"error":"invalid_jwt_token","error_description":"iat missing"}

So it fails in getAccessToken from LtiServiceClient

The thing is that if I print the token claims... iat appears. So... very very strange.

Any ideas?

Thanks in advance

problem with adding multiple resourceCollection

Hi Team, I try to add multiple ResourceCollection, but it doesn't work, here is what I've tried so far:

$resources = [];
foreach ($payload->courses as $uuid) {
   $course = Course::whereUuid($uuid)->first();
   $resources[] = new LtiResourceLink('ltiResourceLinkIdentifier', [
       'url' => getLtiDomain().'/launch',
       'title' => $course->name,
       'text'  => $course->settings['about'],
       'custom'    => [
          'course' => $uuid
       ],
    ]);
}
// agregate courses to resources collection
$resourceCollection = new ResourceCollection($resources); 

I also try this method

$resourceCollection = new ResourceCollection(); 
foreach ($payload->courses as $uuid) {
   $course = Course::whereUuid($uuid)->first();
   $resource = new LtiResourceLink('ltiResourceLinkIdentifier', [
       'url' => getLtiDomain().'/launch',
       'title' => $course->name,
       'text'  => $course->settings['about'],
       'custom'    => [
          'course' => $uuid
       ],
    ]);
$resourceCollection->add($resource);
}

both of those codes do not work, So how to add multiple items to resource collection properly?

`OidcAuthenticator` response is send to `target_link_uri` instead of `redirect_uri`

According to the LTI 1.3 specs, the out-of-band registration process includes registration of redirect uri provided by the tool. The authentication response shall be send only to one of those uri. The specific uri is provided by the tool via the redirect_uri parameter in the authentication request.

However, OidcAuthenticator is sending the authentication response to the target_link_uri, which is the uri to which the tool is supposed to redirect the user after validating the authentication response.

$originalToken->getClaims()->getMandatory(LtiMessagePayloadInterface::CLAIM_LTI_TARGET_LINK_URI),

`aud` Claim in ServiceClient should not assume it is always equal to getOAuth2AccessTokenUrl

According to the IMSGlobal spec (https://www.imsglobal.org/spec/security/v1p0/#using-json-web-tokens-with-oauth-2-0-client-credentials-grant): "...the authorization server MAY instruct the Consumer to use the token endpoint URL of the authorization server as a value for an aud element..."

Not all platforms do this. For example, Brightspace has a separate audiance value. Brightspace OAuth2 Audience is https://api.brightspace.com/auth/token and its Brightspace OAuth2 Access Token URL is https://auth.brightspace.com/core/connect/token

In the current implementation of the ServiceClient the aud is set equal to the platform->getOAuth2AccessTokenUrl() value. I propose to set it equal to the platform->getAudience() value.

The piece of code to be changed is:

->permittedFor($registration->getPlatform()->getOAuth2AccessTokenUrl())

Using Cached Access Tokens

Description:

I'm using this library to implement LTI 1.3 into an LMS application. Reading the documentation, I'm able to get the integration working but caching access tokens doesn't make sense to me!

When setting up the server service we generate an access token for a key chain which requires passing AccessTokenRepository to store the created access tokens, However, the AccessTokenRepository is not used with service endpoint authentication so why are we storing these tokens if they're not being used?

Possible Solution?

Maybe the idea is that we create a custom validator interface and pass it to RequestAccessTokenValidator? I think that'd work by decoding the JWT and searching for the id in the cache (the database in my case).

Ideal solution

Since the AccessTokenRepository is required for generating access tokens, It should also be required for validating access tokens. so RequestAccessTokenValidator.php should be modified to use the cache adapter to search for access tokens and make sure they're not revoked or expired.

LtiMessage::toUrl() invalid when $this->url already contains query string

As the title of this issue says: The LtiMessage::toUrl() method should generate a valid URL if the base URL already contains a query string.

return sprintf('%s?%s', $this->url, http_build_query(array_filter($this->getParameters()->all())));

A base url of http://localhost/mod/lti/contentitem_return.php?course=2&id=39&sesskey=BP0AlkCbZq results in the following return value from LtiMessage::toUrl() (which is invalid because of the double ?).
http://localhost/mod/lti/contentitem_return.php?course=2&id=39&sesskey=BP0AlkCbZq?JWT=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjU1ZmQwNzIxMWY5ZDQ4MGVhOWVjNGIwNTU5ZGFiNzMwZGNlZmU4MjZhMDdmZjU5YjA5NDgxN2Q1NmRjZjJlNzYifQ.eyJodHRwczovL3B1cmwuaW1zZ2xvYmFsLm9yZy9zcGVjL2x0aS1kbC9jbGFpbS9kYXRhIjpudWxsLCJodHRwczovL3B1cmwuaW1zZ2xvYmFsLm9yZy9zcGVjL2x0aS1kbC9jbGFpbS9tc2ciOiIxIGl0ZW0ocykgcHJvdmlkZWQiLCJodHRwczovL3B1cmwuaW1zZ2xvYmFsLm9yZy9zcGVjL2x0aS1kbC9jbGFpbS9sb2ciOiIxIGl0ZW0ocykgcHJvdmlkZWQiLCJodHRwczovL3B1cmwuaW1zZ2xvYmFsLm9yZy9zcGVjL2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ZD7v7ImCYQ6qnMwiZlZy0EfDDioLxvhSZu8nJArcTCPCVCxZVRn4SGsnmSKWu1zTZ3nrLjm0AE3mzU6FHWX-E1BSW5y1wzX-ofoqLHCkWioflfzNJ37rMlFpIYGC1nGPlN-sImJCiZTwOxMKvXe_3Mufl3pPAqSao_3ba0prr9aYBN3cl3rVHp4aWvAJMhttovOs2LxWTojM5n0TVMfDpwtkRNHpIS7JDD-oBxcAV-OVR-2yl02qJntPKFRdyN37_NZiWc7IcywBCefjpeNHRHLAfV2lkCiEEmo7w7BF_hz-fAQc7aExfvFqj3T55cglIA_4JJ4ZPY2ng1KKRg1SeFhM3CHz3WjVtX0gYmbDSvUKmmFqNhCMA1PMzvP4

how to set height and width on platform iframe

Hi, I develope laravel app for LTI Tool, and I use moodle as LTI Platform to consume course from laravel.
I wonder how to set Launch Presentation width & height, because moodle display height is too short and when I debug it says height is null

thank you

Error at OIDC initiation

The following error appears at OIDC initiation:

OIDC initiation failed: OAT\Library\Lti1p3Core\Message\Payload\Builder\MessagePayloadBuilder::buildMessagePayload(): Argument #1 ($keyChain) must be of type OAT\Library\Lti1p3Core\Security\Key\KeyChainInterface, null given, called in /var/www/html/vendor/oat-sa/lib-lti1p3-core/src/Security/Oidc/OidcInitiator.php on line 96

It happens becaue buildMessagePayload definitely expect a key chain object but the given Registration does not contain any tool key chain information.

How about throwing an LtiException before the following line?

$statePayload = $this->builder->buildMessagePayload($registration->getToolKeyChain());

support `aud` Claim in LTI messages to be an array

https://www.imsglobal.org/spec/security/v1p0/#id-token

aud
REQUIRED. Audience(s) for whom this ID Token is intended i.e. the Tool. It MUST contain the OAuth 2.0 client_id of the Tool as an audience value. It MAY also contain identifiers for other audiences. In the general case, the aud value is an array of case-sensitive strings. In the common special case when there is one audience, the aud value MAY be a single case-sensitive string.

This library makes it always a special case, and only support SINGLE value aud Claim when OidcAuthenticator and can't do any overwride

I can not find any example on IMS site about aud that is not an array
EG: http://www.imsglobal.org/spec/lti/v1p3/#e-full-example-resource-link-request

OidcAuthenticationRequestHandler raises RuntimeException

I'm calling the handler in my platform oidc/auth controller like this: $psrRequest = $this->requestFactory->createServerRequest($request->getMethod(), $request->getRequestUri()); return $this->handler->handle($psrRequest);

but it triggers a RuntimeException with this error: Resources are not supported in serialized data. Path: Nyholm\Psr7\Stream -> Nyholm\Psr7\Response

because the serializer finds a property of type resource...

Any idea what might be wrong? Since I'm using the bundle handler I'm not really sure how to avoid it.

Cache Launch message

Hi all,
I would like to know if this library offer some strategy for caching the message Launch in order to retrieve message launch data during subsequent requests, for example consider this Deep Linking Scenario:

  • the platform launch the tool and the tool show the Item Selection content after the message Launch validation using the method validatePlatformOriginatingLaunch, this method return LaunchValidationResultInterface with lots of usefull information (for example deep linking settings)
  • The user select some contents and click on a button in order to send the items to platform, so we need to create a Deep Link Response, at this stage we can retrieve the data from the cache in order to build the response.

Have I to implement my own this strategy? Or do you offer something?
Hope all is clear,

Workflow implementation of LTI as a Platform

Hello, I need help about this package, I still confuse about step by step guide if I want integrate my laravel app as a LTI platform, I use moodle as LTI Tool provider and moodle give me Registration URL, what can I do with that link? I cannot find any code that tell me to process that link, what essential routes needed to be a Platform, how to process from Registration URL and get all the data from tool provider and then launch the course.

thank you in advance

OidcAuthenticator generates a new nonce to id_token instead of returning nonce from auth request

Hi,

I've been using your LTI 1.3 core library in a project (as a platform) for a while with some success. However, I've recently noticed something unexpected in how it handles platform-side OIDC authentication.

IMS Global's documentation states that the nonce is supposed to be passed as is from the auth request into the auth response's id token sent to the LTI tool: however, the \OAT\Library\Lti1p3Core\Security\Oidc\OidcAuthenticator class by default contains a message payload builder which generates a new nonce and injects it into the ID token, thus causing some LTI tools to reject auth responses created by this library.

I've been able to work around this issue, but I believe that since this is a fundamental aspect of OIDC security checking that either:

  • I'm missing something in how OidcAuthenticator instances are created (but I didn't see any other documentation on this, and no other nonce generator implementations exist within this library)
  • the library is mistakenly generating a new nonce for the auth response
  • I and/or the LTI tool provider is mistaken as to the purpose of the nonce

Thank you for your time and advice, your work is appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.