Actualización

This commit is contained in:
Xes
2025-04-10 12:24:57 +02:00
parent 8969cc929d
commit 45420b6f0d
39760 changed files with 4303286 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
.env
.DS_Store
.idea
.phpunit.result.cache
build
composer.lock
composer.phar
tests/_output/*
tests/_support/_generated/*
vendor
# ignore the coverage folders
**/coverage

View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2018 Turnitin, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,484 @@
# LTI 1.3 Tool Library
A library used for building IMS-certified LTI 1.3 tool providers in PHP.
This library allows a tool provider (your app) to receive LTI launches from a tool consumer (i.e. LMS). It validates LTI launches and lets an application interact with services like the Names Roles Provisioning Service (to fetch a roster for an LMS course) and Assignment Grades Service (to update grades for students in a course in the LMS).
This library was forked from [IMSGlobal/lti-1-3-php-library](https://github.com/IMSGlobal/lti-1-3-php-library), initially created by @MartinLenord. [Packback](https://packback.co) found the library immensely helpful and extended it over the years. It has been rewritten by Packback to bring it into compliance with the standards set out by the PHP-FIG and the IMS LTI 1.3 Certification process. Packback actively uses and maintains this library.
## Installation
Run:
```bash
composer require packbackbooks/lti-1p3-tool
```
In your code, you will now be able to use classes in the `Packback\Lti1p3` namespace to access the library.
### Configuring JWT
Add the following when bootstrapping your app.
```php
use Firebase\JWT\JWT;
JWT::$leeway = 5;
```
### Data Storage
This library uses three methods for storing and accessing data: cache, cookie, and database. All three must be implemented in order for the library to work. You may create your own custom implementations so long as they adhere to the following interfaces:
- `Packback\Lti1p3\Interfaces\Cache`
- `Packback\Lti1p3\Interfaces\Cookie`
- `Packback\Lti1p3\Interfaces\Database`
Cache and Cookie storage have legacy implementations at `Packback\Lti1p3\ImsStorage\` if you do not wish to implement your own. However you must implement your own database.
#### Database
To allow for launches to be validated and to allow the tool to know where it has to make calls to, registration data must be stored.
The `Packback\Lti1p3\Database` interface must be fully implemented for this to work.
```php
class ExampleDatabase implements Packback\Lti1p3\Interfaces\Database
{
public function findRegistrationByIssuer($iss): Packback\Lti1p3\LtiRegistration
{
$issuer = Issuer::find($iss);
return Packback\Lti1p3\LtiRegistration::new()
->setAuthLoginUrl($issuer->auth_login_url)
->setAuthTokenUrl($issuer->auth_token_url)
->setClientId($issuer->client_id)
->setKeySetUrl($issuer->key_set_url)
->setKid($issuer->kid)
->setIssuer($issuer->issuer)
->setToolPrivateKey($issuer->private_key);
}
public function findDeployment($iss, $deployment_id): Packback\Lti1p3\LtiDeployment
{
$issuer = Issuer::where('issuer', $issuer_url)
->where('client_id', $deployment_id)
->first();
return Packback\Lti1p3\LtiDeployment::new()
->setDeploymentId($issuer->deployment_id);
}
}
```
### Creating a JWKS endpoint
A JWKS (JSON Web Key Set) endpoint can be generated for either an individual registration or from an array of `KID`s and private keys.
```php
use Packback\Lti1p3\JwksEndpoint;
// From issuer
JwksEndpoint::fromIssuer($database, 'http://example.com')->outputJwks();
// From registration
JwksEndpoint::fromRegistration($registration)->outputJwks();
// From array
JwksEndpoint::new(['a_unique_KID' => file_get_contents('/path/to/private/key.pem')])->outputJwks();
```
## Handling Requests
### Open Id Connect Login Request
LTI 1.3 uses a modified version of the OpenId Connect third party initiate login flow. This means that to do an LTI 1.3 launch, you must first receive a login initialization request and return to the platform.
To handle this request, you must first create a new `Packback\Lti1p3\LtiOidcLogin` object.
```php
$login = LtiOidcLogin::new($database);
```
Now you must configure your login request with a return url (this must be preconfigured and white-listed on the tool).
If a redirect url is not given or the registration does not exist an `Packback\Lti1p3\OidcException` will be thrown.
```php
try {
$redirect = $login->doOidcLoginRedirect("https://my.tool/launch");
} catch (Packback\Lti1p3\OidcException $e) {
// handle the error
}
```
With the redirect, we can now redirect the user back to the tool. From there you can get the url you need to redirect to, with all the necessary query parameters.
```php
$redirect_url = $redirect->getRedirectUrl();
```
Alternatively you can redirect using a 302 location header, or javascript.
```php
// Location header
$redirect->doRedirect();
// Javascript
$redirect->doJsRedirect();
```
Redirect is now done, we can move onto the launch.
### LTI Message Launches
Now that we have done the OIDC log the platform will launch back to the tool. To handle this request, first we need to create a new `Packback\Lti1p3\LtiMessageLaunch` object.
```php
$launch = Packback\Lti1p3\LtiMessageLaunch::new($database);
```
#### Validating a Launch
Once we have the message launch, we can validate it. This will check signatures and the presence of a deployment and any required parameters.
If the validation fails an exception will be thrown.
```php
try {
$launch->validate();
} catch (Exception $e) {
// Handle failed launch
}
```
#### Accessing Launch Information
Now we know the launch is valid we can find out more information about the launch.
Check if we have a resource launch or a deep linking launch.
```php
if ($launch->isResourceLaunch()) {
echo 'Resource Launch!';
} else if ($launch->isDeepLinkLaunch()) {
echo 'Deep Linking Launch!';
} else {
echo 'Unknown launch type';
}
```
Check which services we have access to.
```php
if ($launch->hasAgs()) {
echo 'Has Assignments and Grades Service';
}
if ($launch->hasNrps()) {
echo 'Has Names and Roles Service';
}
```
### Accessing Cached Launch Requests
It is likely that you will want to refer back to a launch later during subsequent requests. This is done using the launch id to identify a cached request. The launch id can be found using:
```php
$launch_id = $launch->getLaunchId().
```
Once you have the launch id, you can link it to your session and pass it along as a query parameter.
**Make sure you check the launch id against the user session to prevent someone from making actions on another person's launch.**
Retrieving a launch using the launch id can be done using:
```php
$launch = LtiMessageLaunch::fromCache($launch_id, $database);
```
Once retrieved, you can call any of the methods on the launch object as normal, e.g.
```php
if ($launch->hasAgs()) {
echo 'Has Assignments and Grades Service';
}
```
### Deep Linking Responses
If you receive a deep linking launch, it is very likely that you are going to want to respond to the deep linking request with resources for the platform.
To create a deep link response you will need to get the deep link for the current launch.
```php
$dl = $launch->getDeepLink();
```
Now we are going to need to create `Packback\Lti1p3\LtiDeepLinkResource` to return.
```php
$resource = Packback\Lti1p3\LtiDeepLinkResource::new()
->setUrl("https://my.tool/launch")
->setCustomParams(['my_param' => $my_param])
->setTitle('My Resource');
```
Everything is set to return the resource to the platform. There are two methods of doing this.
The following method will output the html for an aut-posting form for you.
```php
$dl->outputResponseForm([$resource]);
```
Alternatively you can just request the signed JWT that will need posting back to the platform by calling.
```php
$dl->getResponseJwt([$resource]);
```
## Calling Services
### Names and Roles Service
Before using names and roles you should check that you have access to it.
```php
if (!$launch->hasNrps()) {
throw new Exception("Don't have names and roles!");
}
```
Once we know we can access it, we can get an instance of the service from the launch.
```php
$nrps = $launch->getNrps();
```
From the service we can get an array of all the members by calling:
```php
$members = $nrps->getMembers();
```
### Assignments and Grades Service
Before using assignments and grades you should check that you have access to it.
```php
if (!$launch->hasAgs()) {
throw new Exception("Don't have assignments and grades!");
}
```
Once we know we can access it, we can get an instance of the service from the launch.
```php
$ags = $launch->getAgs();
```
To pass a grade back to the platform, you will need to create an `Packback\Lti1p3\LtiGrade` object and populate it with the necessary information.
```php
$grade = Packback\Lti1p3\LtiGrade::new()
->setScoreGiven($grade)
->setScoreMaximum(100)
->setTimestamp(date(DateTime::ISO8601))
->setActivityProgress('Completed')
->setGradingProgress('FullyGraded')
->setUserId($external_user_id);
```
To send the grade to the platform we can call:
```php
$ags->putGrade($grade);
```
This will put the grade into the default provided lineitem. If no default lineitem exists it will create one.
If you want to send multiple types of grade back, that can be done by specifying an `Packback\Lti1p3\LtiLineitem`.
```php
$lineitem = Packback\Lti1p3\LtiLineitem::new()
->setTag('grade')
->setScoreMaximum(100)
->setLabel('Grade');
$ags->putGrade($grade, $lineitem);
```
If a lineitem with the same `tag` exists, that lineitem will be used, otherwise a new lineitem will be created.
## Laravel Implementation Guide
### Installation
Install the library with composer. Open up the AppServiceProvider and set the `JWT::$leeway` `boot()` method. (Both of these steps are described in the installation section above).
In the `register()` method, bind your implementation of the data Cache, Cookie, and Database to their interfaces:
```php
use App\Lti13Cache;
use App\Lti13Cookie;
use App\Lti13Database;
use Firebase\JWT\JWT;
use Illuminate\Support\ServiceProvider;
use Packback\Lti1p3\Interfaces\Cache;
use Packback\Lti1p3\Interfaces\Cookie;
use Packback\Lti1p3\Interfaces\Database;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
JWT::$leeway = 5;
}
public function register()
{
$this->app->bind(Cache::class, Lti13Cache::class);
$this->app->bind(Cookie::class, Lti13Cookie::class);
$this->app->bind(Database::class, Lti13Database::class);
}
}
```
Once this is done, you can begin building the endpoints necessary to handle an LTI 1.3 launch, such as:
- Login
- Launch
- JWKs
### Sample Data Store Implementations
Below are examples of how to get the library's data store interfaces to work with Laravel's facades.
#### Cache
```php
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Config;
use Packback\Lti1p3\Interfaces\Cache as Lti1p3Cache;
class Lti13Cache implements Lti1p3Cache
{
public const NONCE_PREFIX = 'nonce_';
public function getLaunchData($key)
{
return Cache::get($key);
}
public function cacheLaunchData($key, $jwt_body)
{
$duration = Config::get('cache.duration.default');
Cache::put($key, $jwt_body, $duration);
return $this;
}
public function cacheNonce($nonce)
{
$duration = Config::get('cache.duration.default');
Cache::put(static::NONCE_PREFIX . $nonce, true, $duration);
return $this;
}
public function checkNonce($nonce)
{
return Cache::get(static::NONCE_PREFIX . $nonce, false);
}
}
```
#### Cookie
```php
use Illuminate\Support\Facades\Cookie;
use Packback\Lti1p3\Interfaces\Cookie as Lti1p3Cookie;
class Lti13Cookie implements Lti1p3Cookie
{
public function getCookie($name)
{
return Cookie::get($name, false);
}
public function setCookie($name, $value, $exp = 3600, $options = []): self
{
Cookie::queue($name, $value, $exp);
return $this;
}
}
```
#### Database
For this data store you will need to create models to store the issuer and deployment in the database.
```php
use App\Models\Issuer;
use App\Models\Deployment;
use Packback\Lti1p3\Interfaces\Database;
use Packback\Lti1p3\LtiRegistration;
use Packback\Lti1p3\LtiDeployment;
use Packback\Lti1p3\OidcException;
class Lti13Database implements Database
{
public static function findIssuer($issuer_url, $client_id = null)
{
$query = Issuer::where('issuer', $issuer_url);
if ($client_id) {
$query = $query->where('client_id', $client_id);
}
if ($query->count() > 1) {
throw new OidcException('Found multiple registrations for the given issuer, ensure a client_id is specified on login (contact your LMS administrator)', 1);
}
return $query->first();
}
public function findRegistrationByIssuer($issuer, $client_id = null)
{
$issuer = self::findIssuer($issuer, $client_id);
if (!$issuer) {
return false;
}
return LtiRegistration::new()
->setAuthTokenUrl($issuer->auth_token_url)
->setAuthLoginUrl($issuer->auth_login_url)
->setClientId($issuer->client_id)
->setKeySetUrl($issuer->key_set_url)
->setKid($issuer->kid)
->setIssuer($issuer->issuer)
->setToolPrivateKey($issuer->tool_private_key);
}
public function findDeployment($issuer, $deployment_id, $client_id = null)
{
$issuerModel = self::findIssuer($issuer, $client_id);
if (!$issuerModel) {
return false;
}
$deployment = $issuerModel->deployments()->where('deployment_id', $deployment_id)->first();
if (!$deployment) {
return false;
}
return LtiDeployment::new()
->setDeploymentId($deployment->id);
}
}
```
## Sample Legacy Implementation
This library was forked and rewritten from [IMSGlobal/lti-1-3-php-library](https://github.com/IMSGlobal/lti-1-3-php-library). That repo provides an [example implementation](https://github.com/IMSGlobal/lti-1-3-php-example-tool) that may be helpful.
## Contributing
For improvements, suggestions or bug fixes, make a pull request or an issue. Before opening a pull request, add automated tests for your changes and ensure that all tests pass.
### Testing
Automated tests can be run using the command:
```bash
composer test
```

View File

@@ -0,0 +1,44 @@
{
"name": "packbackbooks/lti-1p3-tool",
"type": "library",
"description": "A library used for building IMS-certified LTI 1.3 tool providers in PHP.",
"keywords": [
"lti"
],
"authors": [
{
"name": "Davo Hynds",
"email": "davo@packback.co"
},
{
"name": "Eric Tendian",
"email": "eric@packback.co"
},
{
"name": "Martin Lenord",
"email": "ims.m@rtin.dev"
}
],
"require": {
"firebase/php-jwt": "^5.2",
"phpseclib/phpseclib": "^2.0"
},
"require-dev": {
"mockery/mockery": "^1.4",
"nesbot/carbon": "^2.43",
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
"Packback\\Lti1p3\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"test": "phpunit"
}
}

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
</report>
</coverage>
<testsuites>
<testsuite name="Packback LTI Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
</phpunit>

View File

@@ -0,0 +1,52 @@
<?php
namespace Packback\Lti1p3\ImsStorage;
use Packback\Lti1p3\Interfaces\Cache;
class ImsCache implements Cache
{
private $cache;
public function getLaunchData($key)
{
$this->loadCache();
return $this->cache[$key];
}
public function cacheLaunchData($key, $jwtBody)
{
$this->cache[$key] = $jwtBody;
$this->saveCache();
return $this;
}
public function cacheNonce($nonce)
{
$this->cache['nonce'][$nonce] = true;
$this->saveCache();
return $this;
}
public function checkNonce($nonce)
{
$this->loadCache();
if (!isset($this->cache['nonce'][$nonce])) {
return false;
}
return true;
}
private function loadCache() {
$cache = file_get_contents(sys_get_temp_dir() . '/lti_cache.txt');
if (empty($cache)) {
file_put_contents(sys_get_temp_dir() . '/lti_cache.txt', '{}');
$this->cache = [];
}
$this->cache = json_decode($cache, true);
}
private function saveCache() {
file_put_contents(sys_get_temp_dir() . '/lti_cache.txt', json_encode($this->cache));
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace Packback\Lti1p3\ImsStorage;
use Packback\Lti1p3\Interfaces\Cookie;
class ImsCookie implements Cookie
{
public function getCookie($name)
{
if (isset($_COOKIE[$name])) {
return $_COOKIE[$name];
}
// Look for backup cookie if same site is not supported by the user's browser.
if (isset($_COOKIE["LEGACY_" . $name])) {
return $_COOKIE["LEGACY_" . $name];
}
return false;
}
public function setCookie($name, $value, $exp = 3600, $options = [])
{
$cookie_options = [
'expires' => time() + $exp
];
// SameSite none and secure will be required for tools to work inside iframes
$same_site_options = [
'samesite' => 'None',
'secure' => true
];
setcookie($name, $value, array_merge($cookie_options, $same_site_options, $options));
// Set a second fallback cookie in the event that "SameSite" is not supported
setcookie("LEGACY_" . $name, $value, array_merge($cookie_options, $options));
return $this;
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Packback\Lti1p3\Interfaces;
interface Cache
{
public function getLaunchData($key);
public function cacheLaunchData($key, $jwtBody);
public function cacheNonce($nonce);
public function checkNonce($nonce);
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Packback\Lti1p3\Interfaces;
interface Cookie
{
public function getCookie($name);
public function setCookie($name, $value, $exp = 3600, $options = []);
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Packback\Lti1p3\Interfaces;
interface Database
{
public function findRegistrationByIssuer($iss, $clientId = null);
public function findDeployment($iss, $deploymentId, $clientId = null);
}

View File

@@ -0,0 +1,22 @@
<?php
namespace Packback\Lti1p3\Interfaces;
interface LtiRegistrationInterface
{
public function getIssuer();
public function setIssuer($issuer);
public function getClientId();
public function setClientId($clientId);
public function getKeySetUrl();
public function setKeySetUrl($keySetUrl);
public function getAuthTokenUrl();
public function setAuthTokenUrl($authTokenUrl);
public function getAuthLoginUrl();
public function setAuthLoginUrl($authLoginUrl);
public function getAuthServer();
public function setAuthServer($authServer);
public function getToolPrivateKey();
public function setToolPrivateKey($toolPrivateKey);
public function getKid();
public function setKid($kid);
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Packback\Lti1p3\Interfaces;
interface LtiServiceConnectorInterface
{
public function getAccessToken(array $scopes);
public function makeServiceRequest(array $scopes, $method, $url, $body = null, $contentType = 'application/json', $accept = 'application/json');
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Packback\Lti1p3\Interfaces;
interface MessageValidator
{
public function validate(array $jwtBody);
public function canValidate(array $jwtBody);
}

View File

@@ -0,0 +1,62 @@
<?php
namespace Packback\Lti1p3;
use phpseclib\Crypt\RSA;
use \Firebase\JWT\JWT;
use Packback\Lti1p3\Interfaces\Database;
use Packback\Lti1p3\Interfaces\LtiRegistrationInterface;
class JwksEndpoint
{
private $keys;
public function __construct(array $keys)
{
$this->keys = $keys;
}
public static function new(array $keys) {
return new JwksEndpoint($keys);
}
public static function fromIssuer(Database $database, $issuer) {
$registration = $database->findRegistrationByIssuer($issuer);
return new JwksEndpoint([$registration->getKid() => $registration->getToolPrivateKey()]);
}
public static function fromRegistration(LtiRegistrationInterface $registration) {
return new JwksEndpoint([$registration->getKid() => $registration->getToolPrivateKey()]);
}
public function getPublicJwks()
{
$jwks = [];
foreach ($this->keys as $kid => $private_key) {
$key = new RSA();
$key->setHash("sha256");
$key->loadKey($private_key);
$key->setPublicKey(false, RSA::PUBLIC_FORMAT_PKCS8);
if ( !$key->publicExponent ) {
continue;
}
$components = array(
'kty' => 'RSA',
'alg' => 'RS256',
'use' => 'sig',
'e' => JWT::urlsafeB64Encode($key->publicExponent->toBytes()),
'n' => JWT::urlsafeB64Encode($key->modulus->toBytes()),
'kid' => $kid,
);
$jwks[] = $components;
}
return ['keys' => $jwks];
}
public function outputJwks()
{
echo json_encode($this->getPublicJwks());
}
}

View File

@@ -0,0 +1,104 @@
<?php
namespace Packback\Lti1p3;
use Packback\Lti1p3\Interfaces\LtiServiceConnectorInterface;
class LtiAssignmentsGradesService
{
private $service_connector;
private $service_data;
public function __construct(LtiServiceConnectorInterface $service_connector, array $service_data)
{
$this->service_connector = $service_connector;
$this->service_data = $service_data;
}
public function putGrade(LtiGrade $grade, LtiLineitem $lineitem = null)
{
if (!in_array(LtiConstants::AGS_SCOPE_SCORE, $this->service_data['scope'])) {
throw new LtiException('Missing required scope', 1);
}
if ($lineitem !== null && empty($lineitem->getId())) {
$lineitem = $this->findOrCreateLineitem($lineitem);
$score_url = $lineitem->getId();
} else if ($lineitem === null && !empty($this->service_data['lineitem'])) {
$score_url = $this->service_data['lineitem'] ;
} else {
$lineitem = LtiLineitem::new()
->setLabel('default')
->setScoreMaximum(100);
$lineitem = $this->findOrCreateLineitem($lineitem);
$score_url = $lineitem->getId();
}
// Place '/scores' before url params
$pos = strpos($score_url, '?');
$score_url = $pos === false ? $score_url . '/scores' : substr_replace($score_url, '/scores', $pos, 0);
return $this->service_connector->makeServiceRequest(
$this->service_data['scope'],
LtiServiceConnector::METHOD_POST,
$score_url,
strval($grade),
'application/vnd.ims.lis.v1.score+json',
'application/vnd.ims.lis.v1.score+json'
);
}
public function findOrCreateLineitem(LtiLineitem $new_line_item)
{
if (!in_array(LtiConstants::AGS_SCOPE_LINEITEM, $this->service_data['scope'])) {
throw new LtiException('Missing required scope', 1);
}
$line_items = $this->service_connector->makeServiceRequest(
$this->service_data['scope'],
LtiServiceConnector::METHOD_GET,
$this->service_data['lineitems'],
null,
null,
'application/vnd.ims.lis.v2.lineitemcontainer+json'
);
// If there is only one item, then wrap it in an array so the foreach works
if (isset($line_items['body']['id'])) {
$line_items['body'] = [$line_items['body']];
}
foreach ($line_items['body'] as $line_item) {
if (
(empty($new_line_item->getResourceId()) && empty($new_line_item->getResourceLinkId())) ||
(isset($line_item['resourceId']) && $line_item['resourceId'] == $new_line_item->getResourceId()) ||
(isset($line_item['resourceLinkId']) && $line_item['resourceLinkId'] == $new_line_item->getResourceLinkId())
) {
if (empty($new_line_item->getTag()) || $line_item['tag'] == $new_line_item->getTag()) {
return new LtiLineitem($line_item);
}
}
}
$created_line_item = $this->service_connector->makeServiceRequest(
$this->service_data['scope'],
LtiServiceConnector::METHOD_POST,
$this->service_data['lineitems'],
strval($new_line_item),
'application/vnd.ims.lis.v2.lineitem+json',
'application/vnd.ims.lis.v2.lineitem+json'
);
return new LtiLineitem($created_line_item['body']);
}
public function getGrades(LtiLineitem $lineitem)
{
$lineitem = $this->findOrCreateLineitem($lineitem);
// Place '/results' before url params
$pos = strpos($lineitem->getId(), '?');
$results_url = $pos === false ? $lineitem->getId() . '/results' : substr_replace($lineitem->getId(), '/results', $pos, 0);
$scores = $this->service_connector->makeServiceRequest(
$this->service_data['scope'],
LtiServiceConnector::METHOD_GET,
$results_url,
null,
null,
'application/vnd.ims.lis.v2.resultcontainer+json'
);
return $scores['body'];
}
}

View File

@@ -0,0 +1,94 @@
<?php
namespace Packback\Lti1p3;
class LtiConstants
{
public const V1_3 = '1.3.0';
// Required message claims
public const MESSAGE_TYPE = 'https://purl.imsglobal.org/spec/lti/claim/message_type';
public const VERSION = 'https://purl.imsglobal.org/spec/lti/claim/version';
public const DEPLOYMENT_ID = 'https://purl.imsglobal.org/spec/lti/claim/deployment_id';
public const TARGET_LINK_URI = 'https://purl.imsglobal.org/spec/lti/claim/target_link_uri';
public const RESOURCE_LINK = 'https://purl.imsglobal.org/spec/lti/claim/resource_link';
public const ROLES = 'https://purl.imsglobal.org/spec/lti/claim/roles';
public const FOR_USER = 'https://purl.imsglobal.org/spec/lti/claim/for_user';
// Optional message claims
public const CONTEXT = 'https://purl.imsglobal.org/spec/lti/claim/context';
public const TOOL_PLATFORM = 'https://purl.imsglobal.org/spec/lti/claim/tool_platform';
public const ROLE_SCOPE_MENTOR = 'https://purlimsglobal.org/spec/lti/claim/role_scope_mentor';
public const LAUNCH_PRESENTATION = 'https://purl.imsglobal.org/spec/lti/claim/launch_presentation';
public const LIS = 'https://purl.imsglobal.org/spec/lti/claim/lis';
public const CUSTOM = 'https://purl.imsglobal.org/spec/lti/claim/custom';
// LTI DL
public const DL_CONTENT_ITEMS = 'https://purl.imsglobal.org/spec/lti-dl/claim/content_items';
public const DL_DATA = 'https://purl.imsglobal.org/spec/lti-dl/claim/data';
public const DL_DEEP_LINK_SETTINGS = 'https://purl.imsglobal.org/spec/lti-dl/claim/deep_linking_settings';
// LTI NRPS
public const NRPS_CLAIM_SERVICE = 'https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice';
public const NRPS_SCOPE_MEMBERSHIP_READONLY = 'https://purl.imsglobal.org/spec/lti-nrps/scope/contextmembership.readonly';
// LTI AGS
public const AGS_CLAIM_ENDPOINT = 'https://purl.imsglobal.org/spec/lti-ags/claim/endpoint';
public const AGS_SCOPE_LINEITEM = 'https://purl.imsglobal.org/spec/lti-ags/scope/lineitem';
public const AGS_SCOPE_LINEITEM_READONLY = 'https://purl.imsglobal.org/spec/lti-ags/scope/lineitem.readonly';
public const AGS_SCOPE_RESULT_READONLY = 'https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly';
public const AGS_SCOPE_SCORE = 'https://purl.imsglobal.org/spec/lti-ags/scope/score';
// LTI GS
public const GS_CLAIM_SERVICE = 'https://purl.imsglobal.org/spec/lti-gs/claim/groupsservice';
// User Vocab
public const SYSTEM_ADMINISTRATOR = 'http://purl.imsglobal.org/vocab/lis/v2/system/person#Administrator';
public const SYSTEM_NONE = 'http://purl.imsglobal.org/vocab/lis/v2/system/person#None';
public const SYSTEM_ACCOUNTADMIN = 'http://purl.imsglobal.org/vocab/lis/v2/system/person#AccountAdmin';
public const SYSTEM_CREATOR = 'http://purl.imsglobal.org/vocab/lis/v2/system/person#Creator';
public const SYSTEM_SYSADMIN = 'http://purl.imsglobal.org/vocab/lis/v2/system/person#SysAdmin';
public const SYSTEM_SYSSUPPORT = 'http://purl.imsglobal.org/vocab/lis/v2/system/person#SysSupport';
public const SYSTEM_USER = 'http://purl.imsglobal.org/vocab/lis/v2/system/person#User';
public const INSTITUTION_ADMINISTRATOR = 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Administrator';
public const INSTITUTION_FACULTY = 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Faculty';
public const INSTITUTION_GUEST = 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Guest';
public const INSTITUTION_NONE = 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#None';
public const INSTITUTION_OTHER = 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Other';
public const INSTITUTION_STAFF = 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Staff';
public const INSTITUTION_STUDENT = 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Student';
public const INSTITUTION_ALUMNI = 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Alumni';
public const INSTITUTION_INSTRUCTOR = 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Instructor';
public const INSTITUTION_LEARNER = 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Learner';
public const INSTITUTION_MEMBER = 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Member';
public const INSTITUTION_MENTOR = 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Mentor';
public const INSTITUTION_OBSERVER = 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#Observer';
public const INSTITUTION_PROSPECTIVESTUDENT = 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#ProspectiveStudent';
public const MEMBERSHIP_ADMINISTRATOR = 'http://purl.imsglobal.org/vocab/lis/v2/membership#Administrator';
public const MEMBERSHIP_CONTENTDEVELOPER = 'http://purl.imsglobal.org/vocab/lis/v2/membership#ContentDeveloper';
public const MEMBERSHIP_INSTRUCTOR = 'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor';
public const MEMBERSHIP_LEARNER = 'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner';
public const MEMBERSHIP_MENTOR = 'http://purl.imsglobal.org/vocab/lis/v2/membership#Mentor';
public const MEMBERSHIP_MANAGER = 'http://purl.imsglobal.org/vocab/lis/v2/membership#Manager';
public const MEMBERSHIP_MEMBER = 'http://purl.imsglobal.org/vocab/lis/v2/membership#Member';
public const MEMBERSHIP_OFFICER = 'http://purl.imsglobal.org/vocab/lis/v2/membership#Officer';
// Context sub-roles
public const MEMBERSHIP_EXTERNALINSTRUCTOR = 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#ExternalInstructor';
public const MEMBERSHIP_GRADER = 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#Grader';
public const MEMBERSHIP_GUESTINSTRUCTOR = 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#GuestInstructor';
public const MEMBERSHIP_LECTURER = 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#Lecturer';
public const MEMBERSHIP_PRIMARYINSTRUCTOR = 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#PrimaryInstructor';
public const MEMBERSHIP_SECONDARYINSTRUCTOR = 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#SecondaryInstructor';
public const MEMBERSHIP_TA = 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#TeachingAssistant';
public const MEMBERSHIP_TAGROUP = 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#TeachingAssistantGroup';
public const MEMBERSHIP_TAOFFERING = 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#TeachingAssistantOffering';
public const MEMBERSHIP_TASECTION = 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#TeachingAssistantSection';
public const MEMBERSHIP_TASECTIONASSOCIATION = 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#TeachingAssistantSectionAssociation';
public const MEMBERSHIP_TATEMPLATE = 'http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#TeachingAssistantTemplate';
// Context Vocab
public const COURSE_TEMPLATE = 'http://purl.imsglobal.org/vocab/lis/v2/course#CourseTemplate';
public const COURSE_OFFERING = 'http://purl.imsglobal.org/vocab/lis/v2/course#CourseOffering';
public const COURSE_SECTION = 'http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection';
public const COURSE_GROUP = 'http://purl.imsglobal.org/vocab/lis/v2/course#Group';
}

View File

@@ -0,0 +1,116 @@
<?php
namespace Packback\Lti1p3;
use Packback\Lti1p3\Interfaces\LtiServiceConnectorInterface;
class LtiCourseGroupsService
{
private $service_connector;
private $service_data;
public function __construct(LtiServiceConnectorInterface $service_connector, array $service_data)
{
$this->service_connector = $service_connector;
$this->service_data = $service_data;
}
public function getGroups()
{
$groups = [];
$next_page = $this->service_data['context_groups_url'];
while ($next_page) {
$page = $this->service_connector->makeServiceRequest(
$this->service_data['scope'],
LtiServiceConnector::METHOD_GET,
$next_page,
null,
null,
'application/vnd.ims.lti-gs.v1.contextgroupcontainer+json'
);
$groups = array_merge($groups, $page['body']['groups']);
$next_page = false;
foreach($page['headers'] as $header) {
if (preg_match(LtiServiceConnector::NEXT_PAGE_REGEX, $header, $matches)) {
$next_page = $matches[1];
break;
}
}
}
return $groups;
}
public function getSets()
{
$sets = [];
// Sets are optional.
if (!isset($this->service_data['context_group_sets_url'])) {
return [];
}
$next_page = $this->service_data['context_group_sets_url'];
while ($next_page) {
$page = $this->service_connector->makeServiceRequest(
$this->service_data['scope'],
LtiServiceConnector::METHOD_GET,
$next_page,
null,
null,
'application/vnd.ims.lti-gs.v1.contextgroupcontainer+json'
);
$sets = array_merge($sets, $page['body']['sets']);
$next_page = false;
foreach($page['headers'] as $header) {
if (preg_match(LtiServiceConnector::NEXT_PAGE_REGEX, $header, $matches)) {
$next_page = $matches[1];
break;
}
}
}
return $sets;
}
public function getGroupsBySet()
{
$groups = $this->getGroups();
$sets = $this->getSets();
$groups_by_set = [];
$unsetted = [];
foreach ($sets as $key => $set) {
$groups_by_set[$set['id']] = $set;
$groups_by_set[$set['id']]['groups'] = [];
}
foreach ($groups as $key => $group) {
if (isset($group['set_id']) && isset($groups_by_set[$group['set_id']])) {
$groups_by_set[$group['set_id']]['groups'][$group['id']] = $group;
} else {
$unsetted[$group['id']] = $group;
}
}
if (!empty($unsetted)) {
$groups_by_set['none'] = [
"name" => "None",
"id" => "none",
"groups" => $unsetted,
];
}
return $groups_by_set;
}
}
?>

View File

@@ -0,0 +1,55 @@
<?php
namespace Packback\Lti1p3;
use Firebase\JWT\JWT;
use Packback\Lti1p3\Interfaces\LtiRegistrationInterface;
class LtiDeepLink
{
private $registration;
private $deployment_id;
private $deep_link_settings;
public function __construct(LtiRegistrationInterface $registration, string $deployment_id, array $deep_link_settings)
{
$this->registration = $registration;
$this->deployment_id = $deployment_id;
$this->deep_link_settings = $deep_link_settings;
}
public function getResponseJwt($resources)
{
$message_jwt = [
"iss" => $this->registration->getClientId(),
"aud" => [$this->registration->getIssuer()],
"exp" => time() + 600,
"iat" => time(),
"nonce" => 'nonce' . hash('sha256', random_bytes(64)),
LtiConstants::DEPLOYMENT_ID => $this->deployment_id,
LtiConstants::MESSAGE_TYPE => "LtiDeepLinkingResponse",
LtiConstants::VERSION => LtiConstants::V1_3,
LtiConstants::DL_CONTENT_ITEMS => array_map(function($resource) { return $resource->toArray(); }, $resources),
LtiConstants::DL_DATA => $this->deep_link_settings['data'],
];
return JWT::encode($message_jwt, $this->registration->getToolPrivateKey(), 'RS256', $this->registration->getKid());
}
public function outputResponseForm($resources)
{
$jwt = $this->getResponseJwt($resources);
/**
* @todo Fix this
*/
?>
<form id="auto_submit" action="<?= $this->deep_link_settings['deep_link_return_url']; ?>" method="POST">
<input type="hidden" name="JWT" value="<?= $jwt ?>" />
<input type="submit" name="Go" />
</form>
<script>
document.getElementById('auto_submit').submit();
</script>
<?php
}
}

View File

@@ -0,0 +1,117 @@
<?php
namespace Packback\Lti1p3;
class LtiDeepLinkResource
{
private $type = 'ltiResourceLink';
private $title;
private $text;
private $url;
private $lineitem;
private $custom_params = [];
private $target = 'iframe';
public static function new() {
return new LtiDeepLinkResource();
}
public function getType()
{
return $this->type;
}
public function setType($value)
{
$this->type = $value;
return $this;
}
public function getTitle()
{
return $this->title;
}
public function setTitle($value)
{
$this->title = $value;
return $this;
}
public function getText()
{
return $this->text;
}
public function setText($value)
{
$this->text = $value;
return $this;
}
public function getUrl()
{
return $this->url;
}
public function setUrl($value)
{
$this->url = $value;
return $this;
}
public function getLineitem()
{
return $this->lineitem;
}
public function setLineitem(LtiLineitem $value)
{
$this->lineitem = $value;
return $this;
}
public function getCustomParams()
{
return $this->custom_params;
}
public function setCustomParams($value)
{
$this->custom_params = $value;
return $this;
}
public function getTarget()
{
return $this->target;
}
public function setTarget($value)
{
$this->target = $value;
return $this;
}
public function toArray()
{
$resource = [
"type" => $this->type,
"title" => $this->title,
"text" => $this->text,
"url" => $this->url,
"presentation" => [
"documentTarget" => $this->target,
],
"custom" => $this->custom_params,
];
if ($this->lineitem !== null) {
$resource["lineItem"] = [
"scoreMaximum" => $this->lineitem->getScoreMaximum(),
"label" => $this->lineitem->getLabel(),
];
}
return $resource;
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace Packback\Lti1p3;
class LtiDeployment
{
private $deployment_id;
public static function new() {
return new LtiDeployment();
}
public function getDeploymentId()
{
return $this->deployment_id;
}
public function setDeploymentId($deployment_id)
{
$this->deployment_id = $deployment_id;
return $this;
}
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Packback\Lti1p3;
use \Exception;
class LtiException extends Exception
{
}

View File

@@ -0,0 +1,150 @@
<?php
namespace Packback\Lti1p3;
class LtiGrade
{
private $score_given;
private $score_maximum;
private $comment;
private $activity_progress;
private $grading_progress;
private $timestamp;
private $user_id;
private $submission_review;
public function __construct(array $grade = null)
{
$this->score_given = $grade['scoreGiven'] ?? null;
$this->score_maximum = $grade['scoreMaximum'] ?? null;
$this->comment = $grade['comment'] ?? null;
$this->activity_progress = $grade['activityProgress'] ?? null;
$this->grading_progress = $grade['gradingProgress'] ?? null;
$this->timestamp = $grade['timestamp'] ?? null;
$this->user_id = $grade['userId'] ?? null;
$this->submission_review = $grade['submissionReview'] ?? null;
$this->canvas_extension = $grade['https://canvas.instructure.com/lti/submission'] ?? null;
}
/**
* Static function to allow for method chaining without having to assign to a variable first.
*/
public static function new() {
return new LtiGrade();
}
public function getScoreGiven()
{
return $this->score_given;
}
public function setScoreGiven($value)
{
$this->score_given = $value;
return $this;
}
public function getScoreMaximum()
{
return $this->score_maximum;
}
public function setScoreMaximum($value)
{
$this->score_maximum = $value;
return $this;
}
public function getComment()
{
return $this->comment;
}
public function setComment($comment)
{
$this->comment = $comment;
return $this;
}
public function getActivityProgress()
{
return $this->activity_progress;
}
public function setActivityProgress($value)
{
$this->activity_progress = $value;
return $this;
}
public function getGradingProgress()
{
return $this->grading_progress;
}
public function setGradingProgress($value)
{
$this->grading_progress = $value;
return $this;
}
public function getTimestamp()
{
return $this->timestamp;
}
public function setTimestamp($value)
{
$this->timestamp = $value;
return $this;
}
public function getUserId()
{
return $this->user_id;
}
public function setUserId($value)
{
$this->user_id = $value;
return $this;
}
public function getSubmissionReview()
{
return $this->submission_review;
}
public function setSubmissionReview($value)
{
$this->submission_review = $value;
return $this;
}
public function getCanvasExtension()
{
return $this->canvas_extension;
}
// Custom Extension for Canvas.
// https://documentation.instructure.com/doc/api/score.html
public function setCanvasExtension($value)
{
$this->canvas_extension = $value;
return $this;
}
public function __toString()
{
return json_encode(array_filter([
'scoreGiven' => 0 + $this->score_given,
'scoreMaximum' => 0 + $this->score_maximum,
'comment' => $this->comment,
'activityProgress' => $this->activity_progress,
'gradingProgress' => $this->grading_progress,
'timestamp' => $this->timestamp,
'userId' => $this->user_id,
'submissionReview' => $this->submission_review,
'https://canvas.instructure.com/lti/submission' => $this->canvas_extension
]));
}
}

View File

@@ -0,0 +1,81 @@
<?php
namespace Packback\Lti1p3;
class LtiGradeSubmissionReview
{
private $reviewable_status;
private $label;
private $url;
private $custom;
public function __construct(array $gradeSubmission = null)
{
$this->reviewable_status = $gradeSubmission['reviewableStatus'] ?? null;
$this->label = $gradeSubmission['label'] ?? null;
$this->url = $gradeSubmission['url'] ?? null;
$this->custom = $gradeSubmission['custom'] ?? null;
}
/**
* Static function to allow for method chaining without having to assign to a variable first.
*/
public static function new() {
return new LtiGradeSubmissionReview();
}
public function getReviewableStatus()
{
return $this->reviewable_status;
}
public function setReviewableStatus($value)
{
$this->reviewable_status = $value;
return $this;
}
public function getLabel()
{
return $this->label;
}
public function setLabel($value)
{
$this->label = $value;
return $this;
}
public function getUrl()
{
return $this->url;
}
public function setUrl($url)
{
$this->url = $url;
return $this;
}
public function getCustom()
{
return $this->custom;
}
public function setCustom($value)
{
$this->custom = $value;
return $this;
}
public function __toString()
{
return json_encode(array_filter([
'reviewableStatus' => $this->reviewable_status,
'label' => $this->label,
'url' => $this->url,
'custom' => $this->custom,
]));
}
}
?>

View File

@@ -0,0 +1,134 @@
<?php
namespace Packback\Lti1p3;
class LtiLineitem
{
private $id;
private $score_maximum;
private $label;
private $resource_id;
private $resource_link_id;
private $tag;
private $start_date_time;
private $end_date_time;
public function __construct(array $lineitem = null)
{
$this->id = $lineitem['id'] ?? null;
$this->score_maximum = $lineitem['scoreMaximum'] ?? null;
$this->label = $lineitem['label'] ?? null;
$this->resource_id = $lineitem['resourceId'] ?? null;
$this->resource_link_id = $lineitem['resourceLinkId'] ?? null;
$this->tag = $lineitem['tag'] ?? null;
$this->start_date_time = $lineitem['startDateTime'] ?? null;
$this->end_date_time = $lineitem['endDateTime'] ?? null;
}
/**
* Static function to allow for method chaining without having to assign to a variable first.
*/
public static function new() {
return new LtiLineitem();
}
public function getId()
{
return $this->id;
}
public function setId($value)
{
$this->id = $value;
return $this;
}
public function getLabel()
{
return $this->label;
}
public function setLabel($value)
{
$this->label = $value;
return $this;
}
public function getScoreMaximum()
{
return $this->score_maximum;
}
public function setScoreMaximum($value)
{
$this->score_maximum = $value;
return $this;
}
public function getResourceId()
{
return $this->resource_id;
}
public function setResourceId($value)
{
$this->resource_id = $value;
return $this;
}
public function getResourceLinkId()
{
return $this->resource_link_id;
}
public function setResourceLinkId($value)
{
$this->resource_link_id = $value;
return $this;
}
public function getTag()
{
return $this->tag;
}
public function setTag($value)
{
$this->tag = $value;
return $this;
}
public function getStartDateTime()
{
return $this->start_date_time;
}
public function setStartDateTime($value)
{
$this->start_date_time = $value;
return $this;
}
public function getEndDateTime()
{
return $this->end_date_time;
}
public function setEndDateTime($value)
{
$this->end_date_time = $value;
return $this;
}
public function __toString()
{
return json_encode(array_filter([
'id' => $this->id,
'scoreMaximum' => $this->score_maximum,
'label' => $this->label,
'resourceId' => $this->resource_id,
'tag' => $this->tag,
'startDateTime' => $this->start_date_time,
'endDateTime' => $this->end_date_time,
]));
}
}

View File

@@ -0,0 +1,392 @@
<?php
namespace Packback\Lti1p3;
use Firebase\JWT\JWK;
use Firebase\JWT\JWT;
use Firebase\JWT\ExpiredException;
use Packback\Lti1p3\MessageValidators\DeepLinkMessageValidator;
use Packback\Lti1p3\MessageValidators\ResourceMessageValidator;
use Packback\Lti1p3\MessageValidators\SubmissionReviewMessageValidator;
use Packback\Lti1p3\Interfaces\Cache;
use Packback\Lti1p3\Interfaces\Cookie;
use Packback\Lti1p3\Interfaces\Database;
class LtiMessageLaunch
{
private $db;
private $cache;
private $request;
private $cookie;
private $jwt;
private $registration;
private $launch_id;
/**
* Constructor
*
* @param Database $database Instance of the database interface used for looking up registrations and deployments.
* @param Cache $cache Instance of the Cache interface used to loading and storing launches.
* @param Cookie $cookie Instance of the Cookie interface used to set and read cookies.
*/
function __construct(Database $database, Cache $cache = null, Cookie $cookie = null) {
$this->db = $database;
$this->launch_id = uniqid("lti1p3_launch_", true);
$this->cache = $cache;
$this->cookie = $cookie;
}
/**
* Static function to allow for method chaining without having to assign to a variable first.
*/
public static function new(Database $database, Cache $cache = null, Cookie $cookie = null) {
return new LtiMessageLaunch($database, $cache, $cookie);
}
/**
* Load an LtiMessageLaunch from a Cache using a launch id.
*
* @param string $launch_id The launch id of the LtiMessageLaunch object that is being pulled from the cache.
* @param Database $database Instance of the database interface used for looking up registrations and deployments.
* @param Cache $cache Instance of the Cache interface used to loading and storing launches. If non is provided launch data will be store in $_SESSION.
*
* @throws LtiException Will throw an LtiException if validation fails or launch cannot be found.
* @return LtiMessageLaunch A populated and validated LtiMessageLaunch.
*/
public static function fromCache($launch_id, Database $database, Cache $cache = null) {
$new = new LtiMessageLaunch($database, $cache, null);
$new->launch_id = $launch_id;
$new->jwt = [ 'body' => $new->cache->getLaunchData($launch_id) ];
return $new->validateRegistration();
}
/**
* Validates all aspects of an incoming LTI message launch and caches the launch if successful.
*
* @param array|string $request An array of post request parameters. If not set will default to $_POST.
*
* @throws LtiException Will throw an LtiException if validation fails.
* @return LtiMessageLaunch Will return $this if validation is successful.
*/
public function validate(array $request = null)
{
if ($request === null) {
$request = $_POST;
}
$this->request = $request;
return $this->validateState()
->validateJwtFormat()
->validateNonce()
->validateRegistration()
->validateJwtSignature()
->validateDeployment()
->validateMessage()
->cacheLaunchData();
}
/**
* Returns whether or not the current launch can use the names and roles service.
*
* @return boolean Returns a boolean indicating the availability of names and roles.
*/
public function hasNrps()
{
return !empty($this->jwt['body'][LtiConstants::NRPS_CLAIM_SERVICE]['context_memberships_url']);
}
/**
* Fetches an instance of the names and roles service for the current launch.
*
* @return LtiNamesRolesProvisioningService An instance of the names and roles service that can be used to make calls within the scope of the current launch.
*/
public function getNrps()
{
return new LtiNamesRolesProvisioningService(
new LtiServiceConnector($this->registration),
$this->jwt['body'][LtiConstants::NRPS_CLAIM_SERVICE]);
}
/**
* Returns whether or not the current launch can use the groups service.
*
* @return boolean Returns a boolean indicating the availability of groups.
*/
public function hasGs()
{
return !empty($this->jwt['body'][LtiConstants::GS_CLAIM_SERVICE]['context_groups_url']);
}
/**
* Fetches an instance of the groups service for the current launch.
*
* @return LtiCourseGroupsService An instance of the groups service that can be used to make calls within the scope of the current launch.
*/
public function getGs()
{
return new LtiCourseGroupsService(
new LtiServiceConnector($this->registration),
$this->jwt['body'][LtiConstants::GS_CLAIM_SERVICE]);
}
/**
* Returns whether or not the current launch can use the assignments and grades service.
*
* @return boolean Returns a boolean indicating the availability of assignments and grades.
*/
public function hasAgs()
{
return !empty($this->jwt['body'][LtiConstants::AGS_CLAIM_ENDPOINT]);
}
/**
* Fetches an instance of the assignments and grades service for the current launch.
*
* @return LtiAssignmentsGradesService An instance of the assignments an grades service that can be used to make calls within the scope of the current launch.
*/
public function getAgs()
{
return new LtiAssignmentsGradesService(
new LtiServiceConnector($this->registration),
$this->jwt['body'][LtiConstants::AGS_CLAIM_ENDPOINT]);
}
/**
* Fetches a deep link that can be used to construct a deep linking response.
*
* @return LtiDeepLink An instance of a deep link to construct a deep linking response for the current launch.
*/
public function getDeepLink()
{
return new LtiDeepLink(
$this->registration,
$this->jwt['body'][LtiConstants::DEPLOYMENT_ID],
$this->jwt['body'][LtiConstants::DL_DEEP_LINK_SETTINGS]);
}
/**
* Returns whether or not the current launch is a deep linking launch.
*
* @return boolean Returns true if the current launch is a deep linking launch.
*/
public function isDeepLinkLaunch()
{
return $this->jwt['body'][LtiConstants::MESSAGE_TYPE] === 'LtiDeepLinkingRequest';
}
/**
* Returns whether or not the current launch is a submission review launch.
*
* @return boolean Returns true if the current launch is a submission review launch.
*/
public function isSubmissionReviewLaunch()
{
return $this->jwt['body'][LtiConstants::MESSAGE_TYPE] === 'LtiSubmissionReviewRequest';
}
/**
* Returns whether or not the current launch is a resource launch.
*
* @return boolean Returns true if the current launch is a resource launch.
*/
public function isResourceLaunch()
{
return $this->jwt['body'][LtiConstants::MESSAGE_TYPE] === 'LtiResourceLinkRequest';
}
/**
* Fetches the decoded body of the JWT used in the current launch.
*
* @return array|object Returns the decoded json body of the launch as an array.
*/
public function getLaunchData()
{
return $this->jwt['body'];
}
/**
* Get the unique launch id for the current launch.
*
* @return string A unique identifier used to re-reference the current launch in subsequent requests.
*/
public function getLaunchId()
{
return $this->launch_id;
}
private function getPublicKey() {
$key_set_url = $this->registration->getKeySetUrl();
// Download key set
$public_key_set = json_decode(file_get_contents($key_set_url), true);
if (empty($public_key_set)) {
// Failed to fetch public keyset from URL.
throw new LtiException('Failed to fetch public key', 1);
}
// Find key used to sign the JWT (matches the KID in the header)
foreach ($public_key_set['keys'] as $key) {
if ($key['kid'] == $this->jwt['header']['kid']) {
try {
return openssl_pkey_get_details(
JWK::parseKeySet([
'keys' => [$key]
])[$key['kid']]
);
} catch(\Exception $e) {
return false;
}
}
}
// Could not find public key with a matching kid and alg.
throw new LtiException('Unable to find public key', 1);
}
private function cacheLaunchData() {
$this->cache->cacheLaunchData($this->launch_id, $this->jwt['body']);
return $this;
}
private function validateState() {
// Check State for OIDC.
if ($this->cookie->getCookie(LtiOidcLogin::COOKIE_PREFIX . $this->request['state']) !== $this->request['state']) {
// Error if state doesn't match
throw new LtiException('State not found', 1);
}
return $this;
}
private function validateJwtFormat() {
$jwt = $this->request['id_token'];
if (empty($jwt)) {
throw new LtiException('Missing id_token', 1);
}
// Get parts of JWT.
$jwt_parts = explode('.', $jwt);
if (count($jwt_parts) !== 3) {
// Invalid number of parts in JWT.
throw new LtiException('Invalid id_token, JWT must contain 3 parts', 1);
}
// Decode JWT headers.
$this->jwt['header'] = json_decode(JWT::urlsafeB64Decode($jwt_parts[0]), true);
// Decode JWT Body.
$this->jwt['body'] = json_decode(JWT::urlsafeB64Decode($jwt_parts[1]), true);
return $this;
}
private function validateNonce() {
if (!isset($this->jwt['body']['nonce'])) {
throw new LtiException('Missing Nonce');
}
if (!$this->cache->checkNonce($this->jwt['body']['nonce'])) {
throw new LtiException('Invalid Nonce');
}
return $this;
}
private function validateRegistration() {
// Find registration.
$client_id = is_array($this->jwt['body']['aud']) ? $this->jwt['body']['aud'][0] : $this->jwt['body']['aud'];
$this->registration = $this->db->findRegistrationByIssuer($this->jwt['body']['iss'], $client_id);
if (empty($this->registration)) {
throw new LtiException('Registration not found.', 1);
}
// Check client id.
if ( $client_id !== $this->registration->getClientId()) {
// Client not registered.
throw new LtiException('Client id not registered for this issuer', 1);
}
return $this;
}
private function validateJwtSignature() {
if (!isset($this->jwt['header']['kid'])) {
throw new LtiException('No KID specified in the JWT Header');
}
// Fetch public key.
$public_key = $this->getPublicKey();
// Validate JWT signature
try {
JWT::decode($this->request['id_token'], $public_key['key'], array('RS256'));
} catch(ExpiredException $e) {
// Error validating signature.
throw new LtiException('Invalid signature on id_token', 1);
}
return $this;
}
private function validateDeployment() {
if (!isset($this->jwt['body'][LtiConstants::DEPLOYMENT_ID])) {
throw new LtiException('No deployment ID was specified', 1);
}
// Find deployment.
$client_id = is_array($this->jwt['body']['aud']) ? $this->jwt['body']['aud'][0] : $this->jwt['body']['aud'];
$deployment = $this->db->findDeployment($this->jwt['body']['iss'], $this->jwt['body'][LtiConstants::DEPLOYMENT_ID], $client_id);
if (empty($deployment)) {
// deployment not recognized.
throw new LtiException('Unable to find deployment', 1);
}
return $this;
}
private function validateMessage() {
if (empty($this->jwt['body'][LtiConstants::MESSAGE_TYPE])) {
// Unable to identify message type.
throw new LtiException('Invalid message type', 1);
}
/**
* @todo Fix this nonsense
*/
// Create instances of all validators
$validators = [
new DeepLinkMessageValidator,
new ResourceMessageValidator,
new SubmissionReviewMessageValidator,
];
$message_validator = false;
foreach ($validators as $validator) {
if ($validator->canValidate($this->jwt['body'])) {
if ($message_validator !== false) {
// Can't have more than one validator apply at a time.
throw new LtiException('Validator conflict', 1);
}
$message_validator = $validator;
}
}
if ($message_validator === false) {
throw new LtiException('Unrecognized message type.', 1);
}
if (!$message_validator->validate($this->jwt['body'])) {
throw new LtiException('Message validation failed.', 1);
}
return $this;
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace Packback\Lti1p3;
use Packback\Lti1p3\Interfaces\LtiServiceConnectorInterface;
class LtiNamesRolesProvisioningService
{
private $service_connector;
private $service_data;
public function __construct(LtiServiceConnectorInterface $service_connector, array $service_data)
{
$this->service_connector = $service_connector;
$this->service_data = $service_data;
}
public function getMembers()
{
$members = [];
$next_page = $this->service_data['context_memberships_url'];
while ($next_page) {
$page = $this->service_connector->makeServiceRequest(
[LtiConstants::NRPS_SCOPE_MEMBERSHIP_READONLY],
LtiServiceConnector::METHOD_GET,
$next_page,
null,
null,
'application/vnd.ims.lti-nrps.v2.membershipcontainer+json'
);
$members = array_merge($members, $page['body']['members']);
$next_page = false;
foreach($page['headers'] as $header) {
if (preg_match(LtiServiceConnector::NEXT_PAGE_REGEX, $header, $matches)) {
$next_page = $matches[1];
break;
}
}
}
return $members;
}
}

View File

@@ -0,0 +1,128 @@
<?php
namespace Packback\Lti1p3;
use Packback\Lti1p3\Interfaces\Cache;
use Packback\Lti1p3\Interfaces\Cookie;
use Packback\Lti1p3\Interfaces\Database;
class LtiOidcLogin
{
public const COOKIE_PREFIX = 'lti1p3_';
public const ERROR_MSG_LAUNCH_URL = 'No launch URL configured';
public const ERROR_MSG_ISSUER = 'Could not find issuer';
public const ERROR_MSG_LOGIN_HINT = 'Could not find login hint';
public const ERROR_MSG_REGISTRATION = 'Could not find registration details';
private $db;
private $cache;
private $cookie;
/**
* Constructor
*
* @param Database $database Instance of the database interface used for looking up registrations and deployments.
* @param Cache $cache Instance of the Cache interface used to loading and storing launches. If non is provided launch data will be store in $_SESSION.
* @param Cookie $cookie Instance of the Cookie interface used to set and read cookies. Will default to using $_COOKIE and setcookie.
*/
function __construct(Database $database, Cache $cache = null, Cookie $cookie = null)
{
$this->db = $database;
$this->cache = $cache;
$this->cookie = $cookie;
}
/**
* Static function to allow for method chaining without having to assign to a variable first.
*/
public static function new(Database $database, Cache $cache = null, Cookie $cookie = null)
{
return new LtiOidcLogin($database, $cache, $cookie);
}
/**
* Calculate the redirect location to return to based on an OIDC third party initiated login request.
*
* @param string $launch_url URL to redirect back to after the OIDC login. This URL must match exactly a URL white listed in the platform.
* @param array|string $request An array of request parameters. If not set will default to $_REQUEST.
*
* @return Redirect Returns a redirect object containing the fully formed OIDC login URL.
*/
public function doOidcLoginRedirect($launch_url, array $request = null)
{
if ($request === null) {
$request = $_REQUEST;
}
if (empty($launch_url)) {
throw new OidcException(static::ERROR_MSG_LAUNCH_URL, 1);
}
// Validate Request Data.
$registration = $this->validateOidcLogin($request);
/*
* Build OIDC Auth Response.
*/
// Generate State.
// Set cookie (short lived)
$state = str_replace('.', '_', uniqid('state-', true));
$this->cookie->setCookie(static::COOKIE_PREFIX.$state, $state, 60);
// Generate Nonce.
$nonce = uniqid('nonce-', true);
$this->cache->cacheNonce($nonce);
// Build Response.
$auth_params = [
'scope' => 'openid', // OIDC Scope.
'response_type' => 'id_token', // OIDC response is always an id token.
'response_mode' => 'form_post', // OIDC response is always a form post.
'prompt' => 'none', // Don't prompt user on redirect.
'client_id' => $registration->getClientId(), // Registered client id.
'redirect_uri' => $launch_url, // URL to return to after login.
'state' => $state, // State to identify browser session.
'nonce' => $nonce, // Prevent replay attacks.
'login_hint' => $request['login_hint'] // Login hint to identify platform session.
];
// Pass back LTI message hint if we have it.
if (isset($request['lti_message_hint'])) {
// LTI message hint to identify LTI context within the platform.
$auth_params['lti_message_hint'] = $request['lti_message_hint'];
}
$auth_login_return_url = $registration->getAuthLoginUrl() . '?' . http_build_query($auth_params);
// Return auth redirect.
return new Redirect($auth_login_return_url, http_build_query($request));
}
public function validateOidcLogin($request)
{
// Validate Issuer.
if (empty($request['iss'])) {
throw new OidcException(static::ERROR_MSG_ISSUER, 1);
}
// Validate Login Hint.
if (empty($request['login_hint'])) {
throw new OidcException(static::ERROR_MSG_LOGIN_HINT, 1);
}
// Fetch Registration Details.
$registration = $this->db->findRegistrationByIssuer($request['iss'], $request['client_id'] ?? null);
// Check we got something.
if (empty($registration)) {
throw new OidcException(static::ERROR_MSG_REGISTRATION, 1);
}
// Return Registration.
return $registration;
}
}

View File

@@ -0,0 +1,123 @@
<?php
namespace Packback\Lti1p3;
use Packback\Lti1p3\Interfaces\LtiRegistrationInterface;
class LtiRegistration implements LtiRegistrationInterface
{
private $issuer;
private $clientId;
private $keySetUrl;
private $authTokenUrl;
private $authLoginUrl;
private $authServer;
private $toolPrivateKey;
private $kid;
public function __construct(array $registration = [])
{
$this->issuer = $registration['issuer'] ?? null;
$this->clientId = $registration['clientId'] ?? null;
$this->keySetUrl = $registration['keySetUrl'] ?? null;
$this->authTokenUrl = $registration['authTokenUrl'] ?? null;
$this->authLoginUrl = $registration['authLoginUrl'] ?? null;
$this->authServer = $registration['authServer'] ?? null;
$this->toolPrivateKey = $registration['toolPrivateKey'] ?? null;
$this->kid = $registration['kid'] ?? null;
}
public static function new(array $registration = []) {
return new LtiRegistration($registration);
}
public function getIssuer()
{
return $this->issuer;
}
public function setIssuer($issuer)
{
$this->issuer = $issuer;
return $this;
}
public function getClientId()
{
return $this->clientId;
}
public function setClientId($clientId)
{
$this->clientId = $clientId;
return $this;
}
public function getKeySetUrl()
{
return $this->keySetUrl;
}
public function setKeySetUrl($keySetUrl)
{
$this->keySetUrl = $keySetUrl;
return $this;
}
public function getAuthTokenUrl()
{
return $this->authTokenUrl;
}
public function setAuthTokenUrl($authTokenUrl)
{
$this->authTokenUrl = $authTokenUrl;
return $this;
}
public function getAuthLoginUrl()
{
return $this->authLoginUrl;
}
public function setAuthLoginUrl($authLoginUrl)
{
$this->authLoginUrl = $authLoginUrl;
return $this;
}
public function getAuthServer()
{
return empty($this->authServer) ? $this->authTokenUrl : $this->authServer;
}
public function setAuthServer($authServer)
{
$this->authServer = $authServer;
return $this;
}
public function getToolPrivateKey()
{
return $this->toolPrivateKey;
}
public function setToolPrivateKey($toolPrivateKey)
{
$this->toolPrivateKey = $toolPrivateKey;
return $this;
}
public function getKid()
{
return $this->kid ?? hash('sha256', trim($this->issuer . $this->clientId));
}
public function setKid($kid)
{
$this->kid = $kid;
return $this;
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace Packback\Lti1p3;
use Firebase\JWT\JWT;
use Packback\Lti1p3\Interfaces\LtiRegistrationInterface;
use Packback\Lti1p3\Interfaces\LtiServiceConnectorInterface;
class LtiServiceConnector implements LtiServiceConnectorInterface
{
const NEXT_PAGE_REGEX = "/^Link:.*<([^>]*)>; ?rel=\"next\"/i";
const METHOD_GET = 'GET';
const METHOD_POST = 'POST';
private $registration;
private $access_tokens = [];
public function __construct(LtiRegistrationInterface $registration)
{
$this->registration = $registration;
}
public function getAccessToken(array $scopes)
{
// Don't fetch the same key more than once.
sort($scopes);
$scope_key = md5(implode('|', $scopes));
if (isset($this->access_tokens[$scope_key])) {
return $this->access_tokens[$scope_key];
}
// Build up JWT to exchange for an auth token
$client_id = $this->registration->getClientId();
$jwt_claim = [
"iss" => $client_id,
"sub" => $client_id,
"aud" => $this->registration->getAuthServer(),
"iat" => time() - 5,
"exp" => time() + 60,
"jti" => 'lti-service-token' . hash('sha256', random_bytes(64))
];
// Sign the JWT with our private key (given by the platform on registration)
$jwt = JWT::encode($jwt_claim, $this->registration->getToolPrivateKey(), 'RS256', $this->registration->getKid());
// Build auth token request headers
$auth_request = [
'grant_type' => 'client_credentials',
'client_assertion_type' => 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
'client_assertion' => $jwt,
'scope' => implode(' ', $scopes)
];
// Make request to get auth token
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->registration->getAuthTokenUrl());
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($auth_request));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$resp = curl_exec($ch);
$token_data = json_decode($resp, true);
curl_close ($ch);
return $this->access_tokens[$scope_key] = $token_data['access_token'];
}
public function makeServiceRequest(array $scopes, $method, $url, $body = null, $contentType = 'application/json', $accept = 'application/json')
{
$ch = curl_init();
$headers = [
'Authorization: Bearer ' . $this->getAccessToken($scopes),
'Accept:' . $accept,
];
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
if ($method === 'POST') {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, strval($body));
$headers[] = 'Content-Type: ' . $contentType;
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
if (curl_errno($ch)){
echo 'Request Error:' . curl_error($ch);
}
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
curl_close ($ch);
$resp_headers = substr($response, 0, $header_size);
$resp_body = substr($response, $header_size);
return [
'headers' => array_filter(explode("\r\n", $resp_headers)),
'body' => json_decode($resp_body, true),
];
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace Packback\Lti1p3\MessageValidators;
use Packback\Lti1p3\LtiConstants;
use Packback\Lti1p3\LtiException;
use Packback\Lti1p3\Interfaces\MessageValidator;
class DeepLinkMessageValidator implements MessageValidator
{
public function canValidate(array $jwtBody)
{
return $jwtBody[LtiConstants::MESSAGE_TYPE] === 'LtiDeepLinkingRequest';
}
public function validate(array $jwtBody)
{
if (empty($jwtBody['sub'])) {
throw new LtiException('Must have a user (sub)');
}
if ($jwtBody[LtiConstants::VERSION] !== LtiConstants::V1_3) {
throw new LtiException('Incorrect version, expected 1.3.0');
}
if (!isset($jwtBody[LtiConstants::ROLES])) {
throw new LtiException('Missing Roles Claim');
}
if (empty($jwtBody[LtiConstants::DL_DEEP_LINK_SETTINGS])) {
throw new LtiException('Missing Deep Linking Settings');
}
$deep_link_settings = $jwtBody[LtiConstants::DL_DEEP_LINK_SETTINGS];
if (empty($deep_link_settings['deep_link_return_url'])) {
throw new LtiException('Missing Deep Linking Return URL');
}
if (empty($deep_link_settings['accept_types']) || !in_array('ltiResourceLink', $deep_link_settings['accept_types'])) {
throw new LtiException('Must support resource link placement types');
}
if (empty($deep_link_settings['accept_presentation_document_targets'])) {
throw new LtiException('Must support a presentation type');
}
return true;
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Packback\Lti1p3\MessageValidators;
use Packback\Lti1p3\LtiConstants;
use Packback\Lti1p3\LtiException;
use Packback\Lti1p3\Interfaces\MessageValidator;
class ResourceMessageValidator implements MessageValidator
{
public function canValidate(array $jwtBody)
{
return $jwtBody[LtiConstants::MESSAGE_TYPE] === 'LtiResourceLinkRequest';
}
public function validate(array $jwtBody)
{
if (empty($jwtBody['sub'])) {
throw new LtiException('Must have a user (sub)');
}
if (!isset($jwtBody[LtiConstants::VERSION])) {
throw new LtiException('Missing LTI Version');
}
if ($jwtBody[LtiConstants::VERSION] !== LtiConstants::V1_3) {
throw new LtiException('Incorrect version, expected 1.3.0');
}
if (!isset($jwtBody[LtiConstants::ROLES])) {
throw new LtiException('Missing Roles Claim');
}
if (empty($jwtBody[LtiConstants::RESOURCE_LINK]['id'])) {
throw new LtiException('Missing Resource Link Id');
}
return true;
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Packback\Lti1p3\MessageValidators;
use Packback\Lti1p3\LtiConstants;
use Packback\Lti1p3\LtiException;
use Packback\Lti1p3\Interfaces\MessageValidator;
class SubmissionReviewMessageValidator implements MessageValidator
{
public function canValidate(array $jwtBody)
{
return $jwtBody[LtiConstants::MESSAGE_TYPE] === 'LtiSubmissionReviewRequest';
}
public function validate(array $jwtBody)
{
if (empty($jwtBody['sub'])) {
throw new LtiException('Must have a user (sub)');
}
if ($jwtBody[LtiConstants::VERSION] !== LtiConstants::V1_3) {
throw new LtiException('Incorrect version, expected 1.3.0');
}
if (!isset($jwtBody[LtiConstants::ROLES])) {
throw new LtiException('Missing Roles Claim');
}
if (empty($jwtBody[LtiConstants::RESOURCE_LINK]['id'])) {
throw new LtiException('Missing Resource Link Id');
}
if (empty($jwtBody[LtiConstants::FOR_USER])) {
throw new LtiException('Missing For User');
}
return true;
}
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Packback\Lti1p3;
use \Exception;
class OidcException extends Exception
{
}

View File

@@ -0,0 +1,86 @@
<?php
namespace Packback\Lti1p3;
use Packback\Lti1p3\Interfaces\Cookie;
class Redirect
{
private $location;
private $referer_query;
private static $CAN_302_COOKIE = 'LTI_302_Redirect';
public function __construct(string $location, string $referer_query = null)
{
$this->location = $location;
$this->referer_query = $referer_query;
}
public function doRedirect()
{
header('Location: ' . $this->location, true, 302);
die;
}
public function doHybridRedirect(Cookie $cookie)
{
if (!empty($cookie->getCookie(self::$CAN_302_COOKIE))) {
return $this->doRedirect();
}
$cookie->setCookie(self::$CAN_302_COOKIE, "true");
$this->doJsRedirect();
}
public function getRedirectUrl()
{
return $this->location;
}
public function doJsRedirect()
{
?>
<a id="try-again" target="_blank">If you are not automatically redirected, click here to continue</a>
<script>
document.getElementById('try-again').href=<?php
if (empty($this->referer_query)) {
echo 'window.location.href';
} else {
echo "window.location.origin + window.location.pathname + '?" . $this->referer_query . "'";
}
?>;
var canAccessCookies = function() {
if (!navigator.cookieEnabled) {
// We don't have access
return false;
}
// Firefox returns true even if we don't actually have access
try {
if (!document.cookie || document.cookie == "" || document.cookie.indexOf('<?php echo self::$CAN_302_COOKIE; ?>') === -1) {
return false;
}
} catch (e) {
return false;
}
return true;
};
if (canAccessCookies()) {
// We have access, continue with redirect
window.location = '<?php echo $this->location ?>';
} else {
// We don't have access, reopen flow in a new window.
var opened = window.open(document.getElementById('try-again').href, '_blank');
if (opened) {
document.getElementById('try-again').innerText = "New window opened, click to reopen";
} else {
document.getElementById('try-again').innerText = "Popup blocked, click to open in a new window";
}
}
</script>
<?php
}
}

View File

@@ -0,0 +1,455 @@
<?php namespace Certification;
use Carbon\Carbon;
use Firebase\JWT\JWT;
use PHPUnit\Framework\TestCase;
use Packback\Lti1p3\{
JwksEndpoint,
LtiConstants,
LtiDeployment,
LtiException,
LtiMessageLaunch,
LtiOidcLogin,
LtiRegistration,
};
use Packback\Lti1p3\Interfaces\{
Cache,
Cookie,
Database
};
class TestCache implements Cache
{
private $launchData = [];
private $nonce;
public function getLaunchData($key)
{
return $this->launchData[$key] ?? null;
}
public function cacheLaunchData($key, $jwt_body)
{
$this->launchData[$key] = $jwt_body;
return $this;
}
public function cacheNonce($nonce)
{
$this->nonce = $nonce;
}
public function checkNonce($nonce)
{
return $this->nonce === $nonce;
}
}
class TestCookie implements Cookie
{
private $cookies = [];
public function getCookie($name)
{
return $this->cookies[$name];
}
public function setCookie($name, $value, $exp = 3600, $options = [])
{
$this->cookies[$name] = $value;
return $this;
}
}
class TestDb implements Database
{
private $registrations = [];
private $deplomyments = [];
public function __construct($registration, $deployment)
{
$this->registrations[$registration->getIssuer()] = $registration;
$this->deployments[$deployment->getDeploymentId()] = $deployment;
}
public function findRegistrationByIssuer($iss, $client_id = null)
{
return $this->registrations[$iss];
}
public function findDeployment($iss, $deployment_id, $client_id = null)
{
return $this->deployments[$iss];
}
}
class Lti13CertificationTest extends TestCase
{
const ISSUER_URL = 'https://ltiadvantagevalidator.imsglobal.org';
const JWKS_FILE = '/tmp/jwks.json';
const CERT_DATA_DIR = __DIR__ . '/../data/certification/';
const PRIVATE_KEY = __DIR__.'/../data/private.key';
const STATE = 'state';
private $issuer;
private $key;
public function setUp(): void
{
$this->issuer = [
'id' => 'issuer_id',
'issuer' => static::ISSUER_URL,
'client_id' => 'imstester_3dfad6d',
'auth_login_url' => 'https://ltiadvantagevalidator.imsglobal.org/ltitool/oidcauthurl.html',
'auth_token_url' => 'https://ltiadvantagevalidator.imsglobal.org/ltitool/authcodejwt.html',
'alg' => 'RS256',
'key_set_url' => static::JWKS_FILE,
'kid' => 'key-id',
'tool_private_key' => file_get_contents(static::PRIVATE_KEY)
];
$this->key = [
'version' => LtiConstants::V1_3,
'issuer_id' => $this->issuer['id'],
'deployment_id' => 'testdeploy',
'campus_id' => 1
];
$this->payload = [
LtiConstants::MESSAGE_TYPE => 'LtiResourceLinkRequest',
LtiConstants::VERSION => LtiConstants::V1_3,
LtiConstants::RESOURCE_LINK => [
'id' => 'd3a2504bba5184799a38f141e8df2335cfa8206d',
'description' => NULL,
'title' => NULL,
'validation_context' => NULL,
'errors' => [
'errors' => [],
],
],
'aud' => $this->issuer['client_id'],
'azp' => $this->issuer['client_id'],
LtiConstants::DEPLOYMENT_ID => $this->key['deployment_id'],
'exp' => Carbon::now()->addDay()->timestamp,
'iat' => Carbon::now()->subDay()->timestamp,
'iss' => $this->issuer['issuer'],
'nonce' => 'nonce-5e73ef2f4c6ea0.93530902',
'sub' => '66b6a854-9f43-4bb2-90e8-6653c9126272',
LtiConstants::TARGET_LINK_URI => 'https://lms-api.packback.localhost/api/lti/launch',
LtiConstants::CONTEXT => [
'id' => 'd3a2504bba5184799a38f141e8df2335cfa8206d',
'label' => 'Canvas Unlauched',
'title' => 'Canvas - A Fresh Course That Remains Unlaunched',
'type' => [
LtiConstants::COURSE_OFFERING,
],
'validation_context' => NULL,
'errors' => [
'errors' => [],
],
],
LtiConstants::TOOL_PLATFORM => [
'guid' => 'FnwyPrXqSxwv8QCm11UwILpDJMAUPJ9WGn8zcvBM:canvas-lms',
'name' => 'Packback Engineering',
'version' => 'cloud',
'product_family_code' => 'canvas',
'validation_context' => NULL,
'errors' => [
'errors' => [],
],
],
LtiConstants::LAUNCH_PRESENTATION => [
'document_target' => 'iframe',
'height' => 400,
'width' => 800,
'return_url' => 'https://canvas.localhost/courses/3/external_content/success/external_tool_redirect',
'locale' => 'en',
'validation_context' => NULL,
'errors' => [
'errors' => [],
],
],
'locale' => 'en',
LtiConstants::ROLES => [
LtiConstants::INSTITUTION_ADMINISTRATOR,
LtiConstants::INSTITUTION_INSTRUCTOR,
LtiConstants::MEMBERSHIP_INSTRUCTOR,
LtiConstants::SYSTEM_SYSADMIN,
LtiConstants::SYSTEM_USER,
],
LtiConstants::CUSTOM => [],
'errors' => [
'errors' => [],
],
];
$this->db = new TestDb(
new LtiRegistration([
'issuer' => static::ISSUER_URL,
'clientId' => $this->issuer['client_id'],
'keySetUrl' => static::JWKS_FILE
]),
(new LtiDeployment)->setDeploymentId(static::ISSUER_URL)
);
$this->cache = new TestCache;
$this->cookie = new TestCookie;
$this->cookie->setCookie(
LtiOidcLogin::COOKIE_PREFIX . static::STATE,
static::STATE
);
}
private function login($loginData = null)
{
$loginData = $loginData ?? [
'iss' => $this->issuer['issuer'],
'login_hint' => '535fa085f22b4655f48cd5a36a9215f64c062838'
];
$loginData['client_id'] = $this->issuer['client_id'];
}
public function buildJWT($data, $header)
{
$jwks = json_encode(JwksEndpoint::new([
$this->issuer['kid'] => $this->issuer['tool_private_key']
])->getPublicJwks());
file_put_contents(static::JWKS_FILE, $jwks);
// If we pass in a header, use that instead of creating one automatically based on params given
if ($header) {
$segments = [];
$segments[] = JWT::urlsafeB64Encode(JWT::jsonEncode($header));
$segments[] = JWT::urlsafeB64Encode(JWT::jsonEncode($data));
$signing_input = \implode('.', $segments);
$signature = JWT::sign($signing_input, $this->issuer['tool_private_key'], $this->issuer['alg']);
$segments[] = JWT::urlsafeB64Encode($signature);
return \implode('.', $segments);
}
return JWT::encode($data, $this->issuer['tool_private_key'], $alg, $this->issuer['kid']);
}
private function launch($payload)
{
$jwt = $this->buildJWT($payload, $this->issuer);
if (isset($payload['nonce'])) {
$this->cache->cacheNonce($payload['nonce']);
}
$params = [
'utf8' => '✓',
'id_token' => $jwt,
'state' => static::STATE,
];
return LtiMessageLaunch::new($this->db, $this->cache, $this->cookie)
->validate($params);
}
// tests
public function testLtiVersionPassedIsNot13()
{
$payload = $this->payload;
$payload[LtiConstants::VERSION] = 'not-1.3';
$this->expectExceptionMessage('Incorrect version, expected 1.3.0');
$this->launch($payload);
}
public function testNoLtiVersionPassedIsInJwt()
{
$payload = $this->payload;
unset($payload[LtiConstants::VERSION]);
$this->expectExceptionMessage('Missing LTI Version');
$this->launch($payload);
}
public function testJwtPassedIsNotLti13Jwt()
{
$jwt = $this->buildJWT([], $this->issuer);
$jwt_r = explode('.', $jwt);
array_pop($jwt_r);
$jwt = implode('.', $jwt_r);
$params = [
'utf8' => '✓',
'id_token' => $jwt,
'state' => static::STATE,
];
$this->expectExceptionMessage('Invalid id_token, JWT must contain 3 parts');
LtiMessageLaunch::new($this->db, $this->cache, $this->cookie)
->validate($params);
}
public function testExpAndIatFieldsInvalid()
{
$payload = $this->payload;
$payload['exp'] = Carbon::now()->subYear()->timestamp;
$payload['iat'] = Carbon::now()->subYear()->timestamp;
$this->expectExceptionMessage('Invalid signature on id_token');
$this->launch($payload);
}
public function testMessageTypeClaimMissing()
{
$payload = $this->payload;
unset($payload[LtiConstants::MESSAGE_TYPE]);
$this->expectExceptionMessage('Invalid message type');
$this->launch($payload);
}
public function testRoleClaimMissing()
{
$payload = $this->payload;
unset($payload[LtiConstants::ROLES]);
$this->expectExceptionMessage('Missing Roles Claim');
$this->launch($payload);
}
public function testDeploymentIdClaimMissing()
{
$payload = $this->payload;
unset($payload[LtiConstants::DEPLOYMENT_ID]);
$this->expectExceptionMessage('No deployment ID was specified');
$this->launch($payload);
}
public function testLaunchWithMissingResourceLinkId()
{
$payload = $this->payload;
unset($payload['sub']);
$this->expectExceptionMessage('Must have a user (sub)');
$this->launch($payload);
}
public function testInvalidCertificationCases()
{
$testCasesDir = static::CERT_DATA_DIR . 'invalid';
$testCases = scandir($testCasesDir);
// Remove . and ..
array_shift($testCases);
array_shift($testCases);
$casesCount = count($testCases);
$testedCases = 0;
foreach ($testCases as $testCase) {
$testCaseDir = $testCasesDir . DIRECTORY_SEPARATOR . $testCase . DIRECTORY_SEPARATOR;
$jwtHeader = null;
if (file_exists($testCaseDir . 'header.json')) {
$jwtHeader = json_decode(
file_get_contents($testCaseDir . 'header.json'),
true
);
}
$payload = json_decode(
file_get_contents($testCaseDir . 'payload.json'),
true
);
$keep = null;
if (file_exists($testCaseDir . 'keep.json')) {
$keep = json_decode(
file_get_contents($testCaseDir . 'keep.json'),
true
);
}
if (!$keep || !in_array('exp', $keep, true)) {
$payload['exp'] = Carbon::now()->addDay()->timestamp;
}
if (!$keep || !in_array('iat', $keep, true)) {
$payload['iat'] = Carbon::now()->subDay()->timestamp;
}
// I couldn't find a better output function
echo PHP_EOL."--> TESTING INVALID TEST CASE: $testCase";
$jwt = $this->buildJWT($payload, $this->issuer, $jwtHeader);
if (isset($payload['nonce'])) {
$this->cache->cacheNonce($payload['nonce']);
}
$params = [
'utf8' => '✓',
'id_token' => $jwt,
'state' => static::STATE,
];
try {
LtiMessageLaunch::new($this->db, $this->cache, $this->cookie)
->validate($params);
} catch (\Exception $e) {
$this->assertInstanceOf(LtiException::class, $e);
}
$testedCases++;
}
echo PHP_EOL;
$this->assertEquals($casesCount, $testedCases);
}
public function testValidCertificationCases()
{
$testCasesDir = static::CERT_DATA_DIR . 'valid';
$testCases = scandir($testCasesDir);
// Remove . and ..
array_shift($testCases);
array_shift($testCases);
$casesCount = count($testCases);
$testedCases = 0;
foreach ($testCases as $testCase) {
$payload = json_decode(
file_get_contents($testCasesDir . DIRECTORY_SEPARATOR . $testCase . DIRECTORY_SEPARATOR . 'payload.json'),
true
);
$payload['exp'] = Carbon::now()->addDay()->timestamp;
$payload['iat'] = Carbon::now()->subDay()->timestamp;
// Set a random context ID to avoid reusing the same LMS Course
$payload[LtiConstants::CONTEXT]['id'] = 'lms-course-id';
// Set a random user ID to avoid reusing the same LmsUser
$payload['sub'] = 'lms-user-id';
// I couldn't find a better output function
echo PHP_EOL."--> TESTING VALID TEST CASE: $testCase";
$jwt = $this->buildJWT($payload, $this->issuer);
$this->cache->cacheNonce($payload['nonce']);
$params = [
'utf8' => '✓',
'id_token' => $jwt,
'state' => static::STATE,
];
$result = LtiMessageLaunch::new($this->db, $this->cache, $this->cookie)
->validate($params);
// Assertions
$this->assertInstanceOf(LtiMessageLaunch::class, $result);
$testedCases++;
}
echo PHP_EOL;
$this->assertEquals($casesCount, $testedCases);
}
}

View File

@@ -0,0 +1,16 @@
<?php namespace Tests\ImsStorage;
use PHPUnit\Framework\TestCase;
use Packback\Lti1p3\ImsStorage\ImsCache;
class ImsCacheTest extends TestCase
{
public function testItInstantiates()
{
$cache = new ImsCache();
$this->assertInstanceOf(ImsCache::class, $cache);
}
}

View File

@@ -0,0 +1,16 @@
<?php namespace Tests\ImsStorage;
use PHPUnit\Framework\TestCase;
use Packback\Lti1p3\ImsStorage\ImsCookie;
class ImsCookieTest extends TestCase
{
public function testItInstantiates()
{
$cookie = new ImsCookie();
$this->assertInstanceOf(ImsCookie::class, $cookie);
}
}

View File

@@ -0,0 +1,78 @@
<?php namespace Tests;
use PHPUnit\Framework\TestCase;
use Mockery;
use Packback\Lti1p3\Interfaces\Database;
use Packback\Lti1p3\Interfaces\LtiRegistrationInterface;
use Packback\Lti1p3\JwksEndpoint;
class JwksEndpointTest extends TestCase
{
public function testItInstantiates()
{
$jwks = new JwksEndpoint([]);
$this->assertInstanceOf(JwksEndpoint::class, $jwks);
}
public function testCreatesANewInstance()
{
$jwks = JwksEndpoint::new([]);
$this->assertInstanceOf(JwksEndpoint::class, $jwks);
}
public function testCreatesANewInstanceFromIssuer()
{
$database = Mockery::mock(Database::class);
$registration = Mockery::mock(LtiRegistrationInterface::class);
$database->shouldReceive('findRegistrationByIssuer')
->once()
->andReturn($registration);
$registration->shouldReceive('getKid')
->once()
->andReturn('kid');
$registration->shouldReceive('getToolPrivateKey')
->once()
->andReturn('private_key');
$jwks = JwksEndpoint::fromIssuer($database, 'issuer');
$this->assertInstanceOf(JwksEndpoint::class, $jwks);
}
public function testCreatesANewInstanceFromRegistration()
{
$registration = Mockery::mock(LtiRegistrationInterface::class);
$registration->shouldReceive('getKid')
->once()
->andReturn('kid');
$registration->shouldReceive('getToolPrivateKey')
->once()
->andReturn('private_key');
$jwks = JwksEndpoint::fromRegistration($registration);
$this->assertInstanceOf(JwksEndpoint::class, $jwks);
}
public function testItGetsJwksForTheProvidedKeys()
{
$jwks = new JwksEndpoint([
'kid' => file_get_contents(__DIR__.'/data/private.key')
]);
$result = $jwks->getPublicJwks();
$this->assertEquals(['keys' => [[
'kty' => 'RSA',
'alg' => 'RS256',
'use' => 'sig',
'e' => 'AQAB',
'n' => '6DzRJzrx0KThi0piO3wdNA3e7-xXly5WJo00CqlKDodtyX6wRT76E4cD57yrr_ZWuaA-6idSFPaEQXw9tCqqTIrS4STIYrlvC0CeEA7m0s2PbI2ffaxv2kofxdmOaUI8YW8NIqNyHMl6Acz1lQOOZ5xSreG5JAqtZpy7AwDdpJo7up9937AD9ZV77qlty6xRKVqOGP1-cH97zMvlQo0EUWUhRAzDlTlCXnbeSjVypET3l93WPT9gnIywt1xX0L6rIJd-4fyU6faaToGN9z4_Q6ay2xFSEJnoNBW9wI886W75vLcVLnT95YKJJwZoKEa9yoV_ZPiTBJcFv1HFPf4ibQ',
'kid' => 'kid',
]]], $result);
}
}

View File

@@ -0,0 +1,24 @@
<?php namespace Tests;
use PHPUnit\Framework\TestCase;
use Mockery;
use Packback\Lti1p3\Interfaces\LtiServiceConnectorInterface;
use Packback\Lti1p3\LtiAssignmentsGradesService;
class LtiAssignmentsGradesServiceTest extends TestCase
{
public function testItInstantiates()
{
$connector = Mockery::mock(LtiServiceConnectorInterface::class);
$service = new LtiAssignmentsGradesService($connector, []);
$this->assertInstanceOf(LtiAssignmentsGradesService::class, $service);
}
/**
* @todo Test this
*/
}

View File

@@ -0,0 +1,24 @@
<?php namespace Tests;
use PHPUnit\Framework\TestCase;
use Mockery;
use Packback\Lti1p3\Interfaces\LtiServiceConnectorInterface;
use Packback\Lti1p3\LtiCourseGroupsService;
class LtiCourseGroupsServiceTest extends TestCase
{
public function testItInstantiates()
{
$connector = Mockery::mock(LtiServiceConnectorInterface::class);
$service = new LtiCourseGroupsService($connector, []);
$this->assertInstanceOf(LtiCourseGroupsService::class, $service);
}
/**
* @todo Test this
*/
}

View File

@@ -0,0 +1,171 @@
<?php namespace Tests;
use PHPUnit\Framework\TestCase;
use Mockery;
use Packback\Lti1p3\LtiLineitem;
use Packback\Lti1p3\LtiDeepLinkResource;
class LtiDeepLinkResourceTest extends TestCase
{
public function setUp(): void
{
$this->deepLinkResource = new LtiDeepLinkResource();
}
public function testItInstantiates()
{
$this->assertInstanceOf(LtiDeepLinkResource::class, $this->deepLinkResource);
}
public function testItCreatesANewInstance()
{
$deepLinkResource = LtiDeepLinkResource::new();
$this->assertInstanceOf(LtiDeepLinkResource::class, $deepLinkResource);
}
public function testItGetsType()
{
$result = $this->deepLinkResource->getType();
$this->assertEquals('ltiResourceLink', $result);
}
public function testItSetsType()
{
$expected = 'expected';
$this->deepLinkResource->setType($expected);
$this->assertEquals($expected, $this->deepLinkResource->getType());
}
public function testItGetsTitle()
{
$result = $this->deepLinkResource->getTitle();
$this->assertNull($result);
}
public function testItSetsTitle()
{
$expected = 'expected';
$this->deepLinkResource->setTitle($expected);
$this->assertEquals($expected, $this->deepLinkResource->getTitle());
}
public function testItGetsText()
{
$result = $this->deepLinkResource->getText();
$this->assertNull($result);
}
public function testItSetsText()
{
$expected = 'expected';
$this->deepLinkResource->setText($expected);
$this->assertEquals($expected, $this->deepLinkResource->getText());
}
public function testItGetsUrl()
{
$result = $this->deepLinkResource->getUrl();
$this->assertNull($result);
}
public function testItSetsUrl()
{
$expected = 'expected';
$this->deepLinkResource->setUrl($expected);
$this->assertEquals($expected, $this->deepLinkResource->getUrl());
}
public function testItGetsLineitem()
{
$result = $this->deepLinkResource->getLineitem();
$this->assertNull($result);
}
public function testItSetsLineitem()
{
$expected = Mockery::mock(LtiLineitem::class);
$this->deepLinkResource->setLineitem($expected);
$this->assertEquals($expected, $this->deepLinkResource->getLineitem());
}
public function testItGetsCustomParams()
{
$result = $this->deepLinkResource->getCustomParams();
$this->assertEquals([], $result);
}
public function testItSetsCustomParams()
{
$expected = 'expected';
$this->deepLinkResource->setCustomParams($expected);
$this->assertEquals($expected, $this->deepLinkResource->getCustomParams());
}
public function testItGetsTarget()
{
$result = $this->deepLinkResource->getTarget();
$this->assertEquals('iframe', $result);
}
public function testItSetsTarget()
{
$expected = 'expected';
$this->deepLinkResource->setTarget($expected);
$this->assertEquals($expected, $this->deepLinkResource->getTarget());
}
public function testItCastsToArray()
{
$expected = [
"type" => 'ltiResourceLink',
"title" => 'a_title',
"text" => 'a_text',
"url" => 'a_url',
"presentation" => [
"documentTarget" => 'iframe',
],
"custom" => [],
"lineItem" => [
"scoreMaximum" => 80,
"label" => 'lineitem_label',
]
];
$lineitem = Mockery::mock(LtiLineitem::class);
$lineitem->shouldReceive('getScoreMaximum')
->once()->andReturn($expected['lineItem']['scoreMaximum']);
$lineitem->shouldReceive('getLabel')
->once()->andReturn($expected['lineItem']['label']);
$this->deepLinkResource->setTitle($expected['title']);
$this->deepLinkResource->setText($expected['text']);
$this->deepLinkResource->setUrl($expected['url']);
$this->deepLinkResource->setLineitem($lineitem);
$result = $this->deepLinkResource->toArray();
$this->assertEquals($expected, $result);
}
}

View File

@@ -0,0 +1,50 @@
<?php namespace Tests;
use PHPUnit\Framework\TestCase;
use Mockery;
use Packback\Lti1p3\Interfaces\LtiRegistrationInterface;
use Packback\Lti1p3\LtiDeepLink;
use Packback\Lti1p3\Nonce;
class LtiDeepLinkTest extends TestCase
{
public function testItInstantiates()
{
$registration = Mockery::mock(LtiRegistrationInterface::class);
$deepLink = new LtiDeepLink($registration, 'test', []);
$this->assertInstanceOf(LtiDeepLink::class, $deepLink);
}
/**
* @todo Figure out how to test this
*/
// public function testItGetsJwtResponse()
// {
// $registration = Mockery::mock(LtiRegistrationInterface::class);
// $registration->shouldReceive('getClientId')
// ->once()->andReturn('client_id');
// $registration->shouldReceive('getIssuer')
// ->once()->andReturn('issuer');
// $registration->shouldReceive('getToolPrivateKey')
// ->once()->andReturn(file_get_contents(__DIR__.'/data/private.key'));
// $registration->shouldReceive('getKid')
// ->once()->andReturn('kid');
// $deepLink = new LtiDeepLink($registration, 'deployment_id', [
// 'data' => 'test_data'
// ]);
// $resource = Mockery::mock();
// $resource->shouldReceive('toArray')
// ->once()->andReturn(['resource']);
// $result = $deepLink->getResponseJwt([ $resource ]);
// $expected = '';
// $this->assertEquals(
// $expected,
// $result
// );
// }
}

View File

@@ -0,0 +1,36 @@
<?php namespace Tests;
use PHPUnit\Framework\TestCase;
use Packback\Lti1p3\LtiDeployment;
class LtiDeploymentTest extends TestCase
{
public function setUp(): void
{
$this->deployment = new LtiDeployment;
}
public function testItInstantiates()
{
$this->assertInstanceOf(LtiDeployment::class, $this->deployment);
}
public function testItGetsDeploymentId()
{
$result = $this->deployment->getDeploymentId();
$this->assertNull($result);
}
public function testItSetsDeploymentId()
{
$expected = 'expected';
$this->deployment->setDeploymentId($expected);
$this->assertEquals($expected, $this->deployment->getDeploymentId());
}
}

View File

@@ -0,0 +1,113 @@
<?php namespace Tests;
use PHPUnit\Framework\TestCase;
use Packback\Lti1p3\LtiGradeSubmissionReview;
class LtiGradeSubmissionReviewTest extends TestCase
{
public function setUp(): void
{
$this->gradeReview = new LtiGradeSubmissionReview;
}
public function testItInstantiates()
{
$this->assertInstanceOf(LtiGradeSubmissionReview::class, $this->gradeReview);
}
public function testItGetsReviewableStatus()
{
$expected = 'ReviewableStatus';
$gradeReview = new LtiGradeSubmissionReview(['reviewableStatus' => 'ReviewableStatus']);
$result = $gradeReview->getReviewableStatus();
$this->assertEquals($expected, $result);
}
public function testItSetsReviewableStatus()
{
$expected = 'expected';
$this->gradeReview->setReviewableStatus($expected);
$this->assertEquals($expected, $this->gradeReview->getReviewableStatus());
}
public function testItGetsLabel()
{
$expected = 'Label';
$gradeReview = new LtiGradeSubmissionReview(['label' => 'Label']);
$result = $gradeReview->getLabel();
$this->assertEquals($expected, $result);
}
public function testItSetsLabel()
{
$expected = 'expected';
$this->gradeReview->setLabel($expected);
$this->assertEquals($expected, $this->gradeReview->getLabel());
}
public function testItGetsUrl()
{
$expected = 'Url';
$gradeReview = new LtiGradeSubmissionReview(['url' => 'Url']);
$result = $gradeReview->getUrl();
$this->assertEquals($expected, $result);
}
public function testItSetsUrl()
{
$expected = 'expected';
$this->gradeReview->setUrl($expected);
$this->assertEquals($expected, $this->gradeReview->getUrl());
}
public function testItGetsCustom()
{
$expected = 'Custom';
$gradeReview = new LtiGradeSubmissionReview(['custom' => 'Custom']);
$result = $gradeReview->getCustom();
$this->assertEquals($expected, $result);
}
public function testItSetsCustom()
{
$expected = 'expected';
$this->gradeReview->setCustom($expected);
$this->assertEquals($expected, $this->gradeReview->getCustom());
}
public function testItCastsFullObjectToString()
{
$expected = [
'reviewableStatus' => 'ReviewableStatus',
'label' => 'Label',
'url' => 'Url',
'custom' => 'Custom',
];
$gradeReview = new LtiGradeSubmissionReview($expected);
$this->assertEquals(json_encode($expected), (string) $gradeReview);
}
public function testItCastsEmptyObjectToString()
{
$this->assertEquals('[]', (string) $this->gradeReview);
}
}

View File

@@ -0,0 +1,220 @@
<?php namespace Tests;
use PHPUnit\Framework\TestCase;
use Packback\Lti1p3\LtiGrade;
class LtiGradeTest extends TestCase
{
public function setUp(): void
{
$this->grade = new LtiGrade;
}
public function testItInstantiates()
{
$this->assertInstanceOf(LtiGrade::class, $this->grade);
}
public function testItCreatesANewInstance()
{
$grade = LtiGrade::new();
$this->assertInstanceOf(LtiGrade::class, $grade);
}
public function testItGetsScoreGiven()
{
$expected = 'expected';
$grade = new LtiGrade([ 'scoreGiven' => $expected ]);
$result = $grade->getScoreGiven();
$this->assertEquals($expected, $result);
}
public function testItSetsScoreGiven()
{
$expected = 'expected';
$this->grade->setScoreGiven($expected);
$this->assertEquals($expected, $this->grade->getScoreGiven());
}
public function testItGetsScoreMaximum()
{
$expected = 'expected';
$grade = new LtiGrade([ 'scoreMaximum' => $expected ]);
$result = $grade->getScoreMaximum();
$this->assertEquals($expected, $result);
}
public function testItSetsScoreMaximum()
{
$expected = 'expected';
$this->grade->setScoreMaximum($expected);
$this->assertEquals($expected, $this->grade->getScoreMaximum());
}
public function testItGetsComment()
{
$expected = 'expected';
$grade = new LtiGrade([ 'comment' => $expected ]);
$result = $grade->getComment();
$this->assertEquals($expected, $result);
}
public function testItSetsComment()
{
$expected = 'expected';
$this->grade->setComment($expected);
$this->assertEquals($expected, $this->grade->getComment());
}
public function testItGetsActivityProgress()
{
$expected = 'expected';
$grade = new LtiGrade([ 'activityProgress' => $expected ]);
$result = $grade->getActivityProgress();
$this->assertEquals($expected, $result);
}
public function testItSetsActivityProgress()
{
$expected = 'expected';
$this->grade->setActivityProgress($expected);
$this->assertEquals($expected, $this->grade->getActivityProgress());
}
public function testItGetsGradingProgress()
{
$expected = 'expected';
$grade = new LtiGrade([ 'gradingProgress' => $expected ]);
$result = $grade->getGradingProgress();
$this->assertEquals($expected, $result);
}
public function testItSetsGradingProgress()
{
$expected = 'expected';
$this->grade->setGradingProgress($expected);
$this->assertEquals($expected, $this->grade->getGradingProgress());
}
public function testItGetsTimestamp()
{
$expected = 'expected';
$grade = new LtiGrade([ 'timestamp' => $expected ]);
$result = $grade->getTimestamp();
$this->assertEquals($expected, $result);
}
public function testItSetsTimestamp()
{
$expected = 'expected';
$this->grade->setTimestamp($expected);
$this->assertEquals($expected, $this->grade->getTimestamp());
}
public function testItGetsUserId()
{
$expected = 'expected';
$grade = new LtiGrade([ 'userId' => $expected ]);
$result = $grade->getUserId();
$this->assertEquals($expected, $result);
}
public function testItSetsUserId()
{
$expected = 'expected';
$this->grade->setUserId($expected);
$this->assertEquals($expected, $this->grade->getUserId());
}
public function testItGetsSubmissionReview()
{
$expected = 'expected';
$grade = new LtiGrade([ 'submissionReview' => $expected ]);
$result = $grade->getSubmissionReview();
$this->assertEquals($expected, $result);
}
public function testItSetsSubmissionReview()
{
$expected = 'expected';
$this->grade->setSubmissionReview($expected);
$this->assertEquals($expected, $this->grade->getSubmissionReview());
}
public function testItGetsCanvasExtension()
{
$expected = 'expected';
$grade = new LtiGrade([ 'https://canvas.instructure.com/lti/submission' => $expected ]);
$result = $grade->getCanvasExtension();
$this->assertEquals($expected, $result);
}
public function testItSetsCanvasExtension()
{
$expected = 'expected';
$this->grade->setCanvasExtension($expected);
$this->assertEquals($expected, $this->grade->getCanvasExtension());
}
public function testItCastsFullObjectToString()
{
$expected = [
'scoreGiven' => 5,
'scoreMaximum' => 10,
'comment' => 'Comment',
'activityProgress' => 'ActivityProgress',
'gradingProgress' => 'GradingProgress',
'timestamp' => 'Timestamp',
'userId' => 'UserId',
'submissionReview' => 'SubmissionReview',
'https://canvas.instructure.com/lti/submission' => 'CanvasExtension'
];
$grade = new LtiGrade($expected);
$this->assertEquals(json_encode($expected), (string) $grade);
}
public function testItCastsEmptyObjectToString()
{
$this->assertEquals('[]', (string) $this->grade);
}
}

View File

@@ -0,0 +1,200 @@
<?php namespace Tests;
use PHPUnit\Framework\TestCase;
use Packback\Lti1p3\LtiLineitem;
class LtiLineitemTest extends TestCase
{
public function setUp(): void
{
$this->lineItem = new LtiLineitem;
}
public function testItInstantiates()
{
$this->assertInstanceOf(LtiLineitem::class, $this->lineItem);
}
public function testItCreatesANewInstance()
{
$grade = LtiLineitem::new();
$this->assertInstanceOf(LtiLineitem::class, $grade);
}
public function testItGetsId()
{
$expected = 'expected';
$grade = new LtiLineitem([ 'id' => $expected ]);
$result = $grade->getId();
$this->assertEquals($expected, $result);
}
public function testItSetsId()
{
$expected = 'expected';
$this->lineItem->setId($expected);
$this->assertEquals($expected, $this->lineItem->getId());
}
public function testItGetsScoreMaximum()
{
$expected = 'expected';
$grade = new LtiLineitem([ 'scoreMaximum' => $expected ]);
$result = $grade->getScoreMaximum();
$this->assertEquals($expected, $result);
}
public function testItSetsScoreMaximum()
{
$expected = 'expected';
$this->lineItem->setScoreMaximum($expected);
$this->assertEquals($expected, $this->lineItem->getScoreMaximum());
}
public function testItGetsLabel()
{
$expected = 'expected';
$grade = new LtiLineitem([ 'label' => $expected ]);
$result = $grade->getLabel();
$this->assertEquals($expected, $result);
}
public function testItSetsLabel()
{
$expected = 'expected';
$this->lineItem->setLabel($expected);
$this->assertEquals($expected, $this->lineItem->getLabel());
}
public function testItGetsResourceId()
{
$expected = 'expected';
$grade = new LtiLineitem([ 'resourceId' => $expected ]);
$result = $grade->getResourceId();
$this->assertEquals($expected, $result);
}
public function testItSetsResourceId()
{
$expected = 'expected';
$this->lineItem->setResourceId($expected);
$this->assertEquals($expected, $this->lineItem->getResourceId());
}
public function testItGetsResourceLinkId()
{
$expected = 'expected';
$grade = new LtiLineitem([ 'resourceLinkId' => $expected ]);
$result = $grade->getResourceLinkId();
$this->assertEquals($expected, $result);
}
public function testItSetsResourceLinkId()
{
$expected = 'expected';
$this->lineItem->setResourceLinkId($expected);
$this->assertEquals($expected, $this->lineItem->getResourceLinkId());
}
public function testItGetsTag()
{
$expected = 'expected';
$grade = new LtiLineitem([ 'tag' => $expected ]);
$result = $grade->getTag();
$this->assertEquals($expected, $result);
}
public function testItSetsTag()
{
$expected = 'expected';
$this->lineItem->setTag($expected);
$this->assertEquals($expected, $this->lineItem->getTag());
}
public function testItGetsStartDateTime()
{
$expected = 'expected';
$grade = new LtiLineitem([ 'startDateTime' => $expected ]);
$result = $grade->getStartDateTime();
$this->assertEquals($expected, $result);
}
public function testItSetsStartDateTime()
{
$expected = 'expected';
$this->lineItem->setStartDateTime($expected);
$this->assertEquals($expected, $this->lineItem->getStartDateTime());
}
public function testItGetsEndDateTime()
{
$expected = 'expected';
$grade = new LtiLineitem([ 'endDateTime' => $expected ]);
$result = $grade->getEndDateTime();
$this->assertEquals($expected, $result);
}
public function testItSetsEndDateTime()
{
$expected = 'expected';
$this->lineItem->setEndDateTime($expected);
$this->assertEquals($expected, $this->lineItem->getEndDateTime());
}
public function testItCastsFullObjectToString()
{
$expected = [
'id' => 'Id',
'scoreMaximum' => 'ScoreMaximum',
'label' => 'Label',
'resourceId' => 'ResourceId',
'tag' => 'Tag',
'startDateTime' => 'StartDateTime',
'endDateTime' => 'EndDateTime',
];
$lineItem = new LtiLineitem($expected);
$this->assertEquals(json_encode($expected), (string) $lineItem);
}
public function testItCastsEmptyObjectToString()
{
$this->assertEquals('[]', (string) $this->lineItem);
}
}

View File

@@ -0,0 +1,45 @@
<?php namespace Tests;
use Mockery;
use PHPUnit\Framework\TestCase;
use Packback\Lti1p3\Interfaces\Cache;
use Packback\Lti1p3\Interfaces\Cookie;
use Packback\Lti1p3\Interfaces\Database;
use Packback\Lti1p3\LtiMessageLaunch;
class LtiMessageLaunchTest extends TestCase
{
public function setUp(): void
{
$this->cache = Mockery::mock(Cache::class);
$this->cookie = Mockery::mock(Cookie::class);
$this->database = Mockery::mock(Database::class);
$this->messageLaunch = new LtiMessageLaunch(
$this->database,
$this->cache,
$this->cookie
);
}
public function testItInstantiates()
{
$this->assertInstanceOf(LtiMessageLaunch::class, $this->messageLaunch);
}
public function testItCreatesANewInstance()
{
$messageLaunch = LtiMessageLaunch::new(
$this->database,
$this->cache,
$this->cookie
);
$this->assertInstanceOf(LtiMessageLaunch::class, $messageLaunch);
}
/**
* @todo Finish testing
*/
}

View File

@@ -0,0 +1,66 @@
<?php namespace Tests;
use PHPUnit\Framework\TestCase;
use Mockery;
use Packback\Lti1p3\Interfaces\LtiServiceConnectorInterface;
use Packback\Lti1p3\LtiNamesRolesProvisioningService;
class LtiNamesRolesProvisioningServiceTest extends TestCase
{
public function setUp(): void
{
$this->connector = Mockery::mock(LtiServiceConnectorInterface::class);
}
public function testItInstantiates()
{
$nrps = new LtiNamesRolesProvisioningService($this->connector, []);
$this->assertInstanceOf(LtiNamesRolesProvisioningService::class, $nrps);
}
public function testItGetsMembers()
{
$expected = [ 'members' ];
$nrps = new LtiNamesRolesProvisioningService($this->connector, [
'context_memberships_url' => 'url'
]);
$this->connector->shouldReceive('makeServiceRequest')
->once()->andReturn([
'headers' => [],
'body' => [ 'members' => $expected ]
]);
$result = $nrps->getMembers();
$this->assertEquals($expected, $result);
}
public function testItGetsMembersIteratively()
{
$response = [ 'members' ];
$expected = array_merge($response, $response);
$nrps = new LtiNamesRolesProvisioningService($this->connector, [
'context_memberships_url' => 'url'
]);
// First response
$this->connector->shouldReceive('makeServiceRequest')
->once()->andReturn([
'headers' => [ 'Link:Something<else>;rel="next"' ],
'body' => [ 'members' => $response ]
]);
// Second response
$this->connector->shouldReceive('makeServiceRequest')
->once()->andReturn([
'headers' => [],
'body' => [ 'members' => $response ]
]);
$result = $nrps->getMembers();
$this->assertEquals($expected, $result);
}
}

View File

@@ -0,0 +1,105 @@
<?php namespace Tests;
use Mockery;
use PHPUnit\Framework\TestCase;
use Packback\Lti1p3\Interfaces\Cache;
use Packback\Lti1p3\Interfaces\Cookie;
use Packback\Lti1p3\Interfaces\Database;
use Packback\Lti1p3\LtiOidcLogin;
use Packback\Lti1p3\OidcException;
class LtiOidcLoginTest extends TestCase
{
public function setUp(): void
{
$this->cache = Mockery::mock(Cache::class);
$this->cookie = Mockery::mock(Cookie::class);
$this->database = Mockery::mock(Database::class);
$this->oidcLogin = new LtiOidcLogin(
$this->database,
$this->cache,
$this->cookie
);
}
public function testItInstantiates()
{
$this->assertInstanceOf(LtiOidcLogin::class, $this->oidcLogin);
}
public function testItCreatesANewInstance()
{
$oidcLogin = LtiOidcLogin::new(
$this->database,
$this->cache,
$this->cookie
);
$this->assertInstanceOf(LtiOidcLogin::class, $this->oidcLogin);
}
public function testItValidatesARequest()
{
$expected = 'expected';
$request = [
'iss' => 'Issuer',
'login_hint' => 'LoginHint',
'client_id' => 'ClientId'
];
$this->database->shouldReceive('findRegistrationByIssuer')
->once()->with($request['iss'], $request['client_id'])
->andReturn($expected);
$result = $this->oidcLogin->validateOidcLogin($request);
$this->assertEquals($expected, $result);
}
public function testValidatesFailsIfIssuerIsNotSet()
{
$request = [
'login_hint' => 'LoginHint',
'client_id' => 'ClientId'
];
$this->expectException(OidcException::class);
$this->expectExceptionMessage(LtiOidcLogin::ERROR_MSG_ISSUER);
$this->oidcLogin->validateOidcLogin($request);
}
public function testValidatesFailsIfLoginHintIsNotSet()
{
$request = [
'iss' => 'Issuer',
'client_id' => 'ClientId'
];
$this->expectException(OidcException::class);
$this->expectExceptionMessage(LtiOidcLogin::ERROR_MSG_LOGIN_HINT);
$this->oidcLogin->validateOidcLogin($request);
}
public function testValidatesFailsIfRegistrationNotFound()
{
$request = [
'iss' => 'Issuer',
'login_hint' => 'LoginHint',
];
$this->database->shouldReceive('findRegistrationByIssuer')
->once()->andReturn(null);
$this->expectException(OidcException::class);
$this->expectExceptionMessage(LtiOidcLogin::ERROR_MSG_REGISTRATION);
$this->oidcLogin->validateOidcLogin($request);
}
/**
* @todo Finish testing
*/
}

View File

@@ -0,0 +1,190 @@
<?php namespace Tests;
use PHPUnit\Framework\TestCase;
use Packback\Lti1p3\LtiRegistration;
class LtiRegistrationTest extends TestCase
{
public function setUp(): void
{
$this->registration = new LtiRegistration;
}
public function testItInstantiates()
{
$this->assertInstanceOf(LtiRegistration::class, $this->registration);
}
public function testItCreatesANewInstance()
{
$registration = LtiRegistration::new();
$this->assertInstanceOf(LtiRegistration::class, $registration);
}
public function testItGetsIssuer()
{
$expected = 'expected';
$registration = new LtiRegistration([ 'issuer' => $expected ]);
$result = $registration->getIssuer();
$this->assertEquals($expected, $result);
}
public function testItSetsIssuer()
{
$expected = 'expected';
$this->registration->setIssuer($expected);
$this->assertEquals($expected, $this->registration->getIssuer());
}
public function testItGetsClientId()
{
$expected = 'expected';
$registration = new LtiRegistration([ 'clientId' => $expected ]);
$result = $registration->getClientId();
$this->assertEquals($expected, $result);
}
public function testItSetsClientId()
{
$expected = 'expected';
$this->registration->setClientId($expected);
$this->assertEquals($expected, $this->registration->getClientId());
}
public function testItGetsKeySetUrl()
{
$expected = 'expected';
$registration = new LtiRegistration([ 'keySetUrl' => $expected ]);
$result = $registration->getKeySetUrl();
$this->assertEquals($expected, $result);
}
public function testItSetsKeySetUrl()
{
$expected = 'expected';
$this->registration->setKeySetUrl($expected);
$this->assertEquals($expected, $this->registration->getKeySetUrl());
}
public function testItGetsAuthTokenUrl()
{
$expected = 'expected';
$registration = new LtiRegistration([ 'authTokenUrl' => $expected ]);
$result = $registration->getAuthTokenUrl();
$this->assertEquals($expected, $result);
}
public function testItSetsAuthTokenUrl()
{
$expected = 'expected';
$this->registration->setAuthTokenUrl($expected);
$this->assertEquals($expected, $this->registration->getAuthTokenUrl());
}
public function testItGetsAuthLoginUrl()
{
$expected = 'expected';
$registration = new LtiRegistration([ 'authLoginUrl' => $expected ]);
$result = $registration->getAuthLoginUrl();
$this->assertEquals($expected, $result);
}
public function testItSetsAuthLoginUrl()
{
$expected = 'expected';
$this->registration->setAuthLoginUrl($expected);
$this->assertEquals($expected, $this->registration->getAuthLoginUrl());
}
public function testItGetsAuthServer()
{
$expected = 'expected';
$registration = new LtiRegistration([ 'authServer' => $expected ]);
$result = $registration->getAuthServer();
$this->assertEquals($expected, $result);
}
public function testItSetsAuthServer()
{
$expected = 'expected';
$this->registration->setAuthServer($expected);
$this->assertEquals($expected, $this->registration->getAuthServer());
}
public function testItGetsToolPrivateKey()
{
$expected = 'expected';
$registration = new LtiRegistration([ 'toolPrivateKey' => $expected ]);
$result = $registration->getToolPrivateKey();
$this->assertEquals($expected, $result);
}
public function testItSetsToolPrivateKey()
{
$expected = 'expected';
$this->registration->setToolPrivateKey($expected);
$this->assertEquals($expected, $this->registration->getToolPrivateKey());
}
public function testItGetsKid()
{
$expected = 'expected';
$registration = new LtiRegistration([ 'kid' => $expected ]);
$result = $registration->getKid();
$this->assertEquals($expected, $result);
}
public function testItGetsKidFromIssuerAndClientId()
{
$expected = '39e02c46a08382b7b352b4f1a9d38698b8fe7c8eb74ead609c804b25eeb1db52';
$registration = new LtiRegistration([
'issuer' => 'Issuer',
'client_id' => 'ClientId'
]);
$result = $registration->getKid();
$this->assertEquals($expected, $result);
}
public function testItSetsKid()
{
$expected = 'expected';
$this->registration->setKid($expected);
$this->assertEquals($expected, $this->registration->getKid());
}
}

View File

@@ -0,0 +1,24 @@
<?php namespace Tests;
use PHPUnit\Framework\TestCase;
use Mockery;
use Packback\Lti1p3\Interfaces\LtiRegistrationInterface;
use Packback\Lti1p3\LtiServiceConnector;
class LtiServiceConnectorTest extends TestCase
{
public function testItInstantiates()
{
$registration = Mockery::mock(LtiRegistrationInterface::class);
$connector = new LtiServiceConnector($registration);
$this->assertInstanceOf(LtiServiceConnector::class, $connector);
}
/**
* @todo Finish testing
*/
}

View File

@@ -0,0 +1,16 @@
<?php namespace Tests\MessageValidators;
use PHPUnit\Framework\TestCase;
use Packback\Lti1p3\MessageValidators\DeepLinkMessageValidator;
class DeepLinkMessageValidatorTest extends TestCase
{
public function testItInstantiates()
{
$validator = new DeepLinkMessageValidator([]);
$this->assertInstanceOf(DeepLinkMessageValidator::class, $validator);
}
}

View File

@@ -0,0 +1,16 @@
<?php namespace Tests\MessageValidators;
use PHPUnit\Framework\TestCase;
use Packback\Lti1p3\MessageValidators\ResourceMessageValidator;
class ResourceMessageValidatorTest extends TestCase
{
public function testItInstantiates()
{
$validator = new ResourceMessageValidator([]);
$this->assertInstanceOf(ResourceMessageValidator::class, $validator);
}
}

View File

@@ -0,0 +1,16 @@
<?php namespace Tests\MessageValidators;
use PHPUnit\Framework\TestCase;
use Packback\Lti1p3\MessageValidators\SubmissionReviewMessageValidator;
class SubmissionReviewMessageValidatorTest extends TestCase
{
public function testItInstantiates()
{
$validator = new SubmissionReviewMessageValidator([]);
$this->assertInstanceOf(SubmissionReviewMessageValidator::class, $validator);
}
}

View File

@@ -0,0 +1,30 @@
<?php namespace Tests;
use PHPUnit\Framework\TestCase;
use Packback\Lti1p3\Redirect;
class RedirectTest extends TestCase
{
public function testItInstantiates()
{
$redirect = new Redirect('test');
$this->assertInstanceOf(Redirect::class, $redirect);
}
public function testItGetsRedirectUrl()
{
$expected = 'expected';
$redirect = new Redirect($expected);
$result = $redirect->getRedirectUrl();
$this->assertEquals($expected, $result);
}
/**
* @todo Finish testing
*/
}

View File

@@ -0,0 +1,4 @@
{
"badtestonly": "12345",
"alg": "RS256"
}

View File

@@ -0,0 +1,48 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "40899",
"aud": "imstester_3dfad6d",
"exp": 1574764165,
"iat": 1574763865,
"nonce": "38a686abdea59",
"name": "Carrie A Lowell",
"given_name": "Carrie",
"family_name": "Lowell",
"middle_name": "A",
"email": "c.lowell@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Learner"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "3622bed7314b4f9c8f0e533e158ff797",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1879",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1879/lineitems"
}
}

View File

@@ -0,0 +1,48 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "40899",
"aud": "imstester_3dfad6d",
"exp": 22222,
"iat": 11111,
"nonce": "c624ec8384a5",
"name": "Carrie A Lowell",
"given_name": "Carrie",
"family_name": "Lowell",
"middle_name": "A",
"email": "c.lowell@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Learner"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "3622bed7314b4f9c8f0e533e158ff797",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1879",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1879/lineitems"
}
}

View File

@@ -0,0 +1,4 @@
{
"kid": "imstester_66067",
"alg": "RS256"
}

View File

@@ -0,0 +1,48 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "40899",
"aud": "imstester_3dfad6d",
"exp": 1574764225,
"iat": 1574763925,
"nonce": "830be2877067",
"name": "Carrie A Lowell",
"given_name": "Carrie",
"family_name": "Lowell",
"middle_name": "A",
"email": "c.lowell@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Learner"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "3622bed7314b4f9c8f0e533e158ff797",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1879",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1879/lineitems"
}
}

View File

@@ -0,0 +1 @@
{ "name" : "badltilaunch" }

View File

@@ -0,0 +1,48 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "40899",
"aud": "imstester_3dfad6d",
"exp": 1574764295,
"iat": 1574763995,
"nonce": "8070d617365e",
"name": "Carrie A Lowell",
"given_name": "Carrie",
"family_name": "Lowell",
"middle_name": "A",
"email": "c.lowell@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "11.3",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Learner"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "3622bed7314b4f9c8f0e533e158ff797",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1879",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1879/lineitems"
}
}

View File

@@ -0,0 +1,40 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "39890",
"aud": "imstester_3dfad6d",
"exp": 1574779693,
"iat": 1574779393,
"nonce": "7964e46f-2f18-4b4c-96eb-ea5e84a77f3c",
"name": "Lauren Colleen Hutton",
"given_name": "Lauren",
"family_name": "Hutton",
"middle_name": "Colleen",
"email": "l.c.hutton@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor"
],
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "a7432159070d4c8b981b51dc1eb982db",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1880",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1880/lineitems"
}
}

View File

@@ -0,0 +1,43 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "40899",
"aud": "imstester_3dfad6d",
"exp": 1574766613,
"iat": 1574766313,
"nonce": "c41c481bea3b",
"name": "Carrie A Lowell",
"given_name": "Carrie",
"family_name": "Lowell",
"middle_name": "A",
"email": "c.lowell@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Learner"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1879",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1879/lineitems"
}
}

View File

@@ -0,0 +1,47 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "40899",
"aud": "imstester_3dfad6d",
"exp": 1574764678,
"iat": 1574764378,
"nonce": "2b9f4c80f4ae6",
"name": "Carrie A Lowell",
"given_name": "Carrie",
"family_name": "Lowell",
"middle_name": "A",
"email": "c.lowell@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Learner"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "3622bed7314b4f9c8f0e533e158ff797",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1879",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1879/lineitems"
}
}

View File

@@ -0,0 +1,43 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "40899",
"aud": "imstester_3dfad6d",
"exp": 1574765110,
"iat": 1574764810,
"nonce": "c73f563cfe17",
"name": "Carrie A Lowell",
"given_name": "Carrie",
"family_name": "Lowell",
"middle_name": "A",
"email": "c.lowell@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "3622bed7314b4f9c8f0e533e158ff797",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1879",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1879/lineitems"
}
}

View File

@@ -0,0 +1,47 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "40899",
"aud": "imstester_3dfad6d",
"exp": 1574766571,
"iat": 1574766271,
"nonce": "15b5502ef6d9b",
"name": "Carrie A Lowell",
"given_name": "Carrie",
"family_name": "Lowell",
"middle_name": "A",
"email": "c.lowell@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Learner"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "3622bed7314b4f9c8f0e533e158ff797",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1879",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1879/lineitems"
}
}

View File

@@ -0,0 +1,47 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "40899",
"aud": "imstester_3dfad6d",
"exp": 1574766462,
"iat": 1574766162,
"nonce": "1344de3bffa6c",
"name": "Carrie A Lowell",
"given_name": "Carrie",
"family_name": "Lowell",
"middle_name": "A",
"email": "c.lowell@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Learner"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "3622bed7314b4f9c8f0e533e158ff797",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1879",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1879/lineitems"
}
}

View File

@@ -0,0 +1,45 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "40899",
"aud": "imstester_3dfad6d",
"exp": 1574766515,
"iat": 1574766215,
"nonce": "3de2defce1635",
"name": "Carrie A Lowell",
"given_name": "Carrie",
"family_name": "Lowell",
"middle_name": "A",
"email": "c.lowell@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "3622bed7314b4f9c8f0e533e158ff797",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1879",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1879/lineitems"
}
}

View File

@@ -0,0 +1,48 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "",
"aud": "imstester_3dfad6d",
"exp": 1574766669,
"iat": 1574766369,
"nonce": "3ce31fd612e1c",
"name": "Carrie A Lowell",
"given_name": "Carrie",
"family_name": "Lowell",
"middle_name": "A",
"email": "c.lowell@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Learner"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "3622bed7314b4f9c8f0e533e158ff797",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1879",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1879/lineitems"
}
}

View File

@@ -0,0 +1,43 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "39890",
"aud": "imstester_3dfad6d",
"exp": 1574779639,
"iat": 1574779339,
"nonce": "2d5be9d404a1c",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "a7432159070d4c8b981b51dc1eb982db",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1880",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1880/lineitems"
}
}

View File

@@ -0,0 +1,44 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "39890",
"aud": "imstester_3dfad6d",
"exp": 1574779416,
"iat": 1574779116,
"nonce": "1c6160abaa34c",
"email": "l.c.hutton@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "a7432159070d4c8b981b51dc1eb982db",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1880",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1880/lineitems"
}
}

View File

@@ -0,0 +1,47 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "39890",
"aud": "imstester_3dfad6d",
"exp": 1574779530,
"iat": 1574779230,
"nonce": "12f8f7e8d9343",
"name": "Lauren Colleen Hutton",
"given_name": "Lauren",
"family_name": "Hutton",
"middle_name": "Colleen",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "a7432159070d4c8b981b51dc1eb982db",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1880",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1880/lineitems"
}
}

View File

@@ -0,0 +1,48 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "39890",
"aud": "imstester_3dfad6d",
"exp": 1574779337,
"iat": 1574779037,
"nonce": "80a3e68b2cb5",
"name": "Lauren Colleen Hutton",
"given_name": "Lauren",
"family_name": "Hutton",
"middle_name": "Colleen",
"email": "l.c.hutton@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
""
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "a7432159070d4c8b981b51dc1eb982db",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1880",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1880/lineitems"
}
}

View File

@@ -0,0 +1,50 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "39890",
"aud": "imstester_3dfad6d",
"exp": 1574778409,
"iat": 1574778109,
"nonce": "9824f85b050f",
"name": "Lauren Colleen Hutton",
"given_name": "Lauren",
"family_name": "Hutton",
"middle_name": "Colleen",
"email": "l.c.hutton@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor",
"http://purl.imsglobal.org/vocab/lis/v2/institution/person#Staff",
"http://purl.imsglobal.org/vocab/lis/v2/institution/person#Other"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "a7432159070d4c8b981b51dc1eb982db",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1880",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1880/lineitems"
}
}

View File

@@ -0,0 +1,48 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "39890",
"aud": "imstester_3dfad6d",
"exp": 1574778959,
"iat": 1574778659,
"nonce": "2cfb292bce9ea",
"name": "Lauren Colleen Hutton",
"given_name": "Lauren",
"family_name": "Hutton",
"middle_name": "Colleen",
"email": "l.c.hutton@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"Instructor"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "a7432159070d4c8b981b51dc1eb982db",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1880",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1880/lineitems"
}
}

View File

@@ -0,0 +1,48 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "39890",
"aud": "imstester_3dfad6d",
"exp": 1574779245,
"iat": 1574778945,
"nonce": "248d630ede7c0",
"name": "Lauren Colleen Hutton",
"given_name": "Lauren",
"family_name": "Hutton",
"middle_name": "Colleen",
"email": "l.c.hutton@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/unknown/unknown#Helper"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "a7432159070d4c8b981b51dc1eb982db",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1880",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1880/lineitems"
}
}

View File

@@ -0,0 +1,48 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "39890",
"aud": "imstester_3dfad6d",
"exp": 1574766741,
"iat": 1574766441,
"nonce": "35d2999e2bcc",
"name": "Lauren Colleen Hutton",
"given_name": "Lauren",
"family_name": "Hutton",
"middle_name": "Colleen",
"email": "l.c.hutton@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "3622bed7314b4f9c8f0e533e158ff797",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1879",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1879/lineitems"
}
}

View File

@@ -0,0 +1,48 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "40899",
"aud": "imstester_3dfad6d",
"exp": 1574780231,
"iat": 1574779931,
"nonce": "3d20d137d3cab",
"name": "Carrie A Lowell",
"given_name": "Carrie",
"family_name": "Lowell",
"middle_name": "A",
"email": "c.lowell@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Learner"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "a7432159070d4c8b981b51dc1eb982db",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1880",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1880/lineitems"
}
}

View File

@@ -0,0 +1,43 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "40899",
"aud": "imstester_3dfad6d",
"exp": 1574780613,
"iat": 1574780313,
"nonce": "82280639-9be0-4527-b43d-5d7637c20849",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Learner"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "0d0b8a77054343a1901d0db481759e84",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1882",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1882/lineitems"
}
}

View File

@@ -0,0 +1,44 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "40899",
"aud": "imstester_3dfad6d",
"exp": 1574780559,
"iat": 1574780259,
"nonce": "5c1192fd-58e8-44e5-a280-8501f442cf5f",
"email": "c.lowell@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Learner"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "0d0b8a77054343a1901d0db481759e84",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1882",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1882/lineitems"
}
}

View File

@@ -0,0 +1,47 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "40899",
"aud": "imstester_3dfad6d",
"exp": 1574780588,
"iat": 1574780288,
"nonce": "02a07b9d-9b46-4afd-9df7-3463f6fe65cd",
"name": "Carrie A Lowell",
"given_name": "Carrie",
"family_name": "Lowell",
"middle_name": "A",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Learner"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "0d0b8a77054343a1901d0db481759e84",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1882",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1882/lineitems"
}
}

View File

@@ -0,0 +1,43 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "40899",
"aud": "imstester_3dfad6d",
"exp": 1574780640,
"iat": 1574780340,
"nonce": "420df5e0-7f4f-4a8c-bec8-0d3fd0579c9c",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Learner"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "0d0b8a77054343a1901d0db481759e84",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1882",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1882/lineitems"
}
}

View File

@@ -0,0 +1,48 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "40899",
"aud": "imstester_3dfad6d",
"exp": 1574780525,
"iat": 1574780225,
"nonce": "23aa93ba-bbcb-460f-ad9f-8a850b39dd90",
"name": "Carrie A Lowell",
"given_name": "Carrie",
"family_name": "Lowell",
"middle_name": "A",
"email": "c.lowell@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
""
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "0d0b8a77054343a1901d0db481759e84",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1882",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1882/lineitems"
}
}

View File

@@ -0,0 +1,50 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "40899",
"aud": "imstester_3dfad6d",
"exp": 1574780329,
"iat": 1574780029,
"nonce": "1304be14-fbc2-4b63-a778-72b34669159f",
"name": "Carrie A Lowell",
"given_name": "Carrie",
"family_name": "Lowell",
"middle_name": "A",
"email": "c.lowell@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Learner",
"http://purl.imsglobal.org/vocab/lis/v2/institution/person#Student",
"http://purl.imsglobal.org/vocab/lis/v2/institution/person#Mentor"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "a7432159070d4c8b981b51dc1eb982db",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1880",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1880/lineitems"
}
}

View File

@@ -0,0 +1,48 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "40899",
"aud": "imstester_3dfad6d",
"exp": 1574780453,
"iat": 1574780153,
"nonce": "b2d3f2da-d4fa-42e9-adc7-513e5ed74715",
"name": "Carrie A Lowell",
"given_name": "Carrie",
"family_name": "Lowell",
"middle_name": "A",
"email": "c.lowell@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"Learner"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "0d0b8a77054343a1901d0db481759e84",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1882",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1882/lineitems"
}
}

View File

@@ -0,0 +1,49 @@
{
"iss": "https://ltiadvantagevalidator.imsglobal.org",
"sub": "40899",
"aud": "imstester_3dfad6d",
"exp": 1574780481,
"iat": 1574780181,
"nonce": "834fe0f9-bc3f-4012-9f21-acbd54ca021a",
"name": "Carrie A Lowell",
"given_name": "Carrie",
"family_name": "Lowell",
"middle_name": "A",
"email": "c.lowell@district1.com",
"locale": "en-US",
"https://purl.imsglobal.org/spec/lti/claim/target_link_uri": "http://localhost:8080/",
"https://purl.imsglobal.org/spec/lti/claim/deployment_id": "testdeploy",
"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest",
"https://purl.imsglobal.org/spec/lti/claim/version": "1.3.0",
"https://purl.imsglobal.org/spec/lti/claim/roles": [
"http://purl.imsglobal.org/vocab/lis/v2/membership#Learner",
"http://purl.imsglobal.org/vocab/lis/v2/uknownrole/unknown#Unknown"
],
"https://purl.imsglobal.org/spec/lti/claim/context": {
"id": "8893483",
"label": "Biology 102",
"title": "Bio Adventures",
"type": [
"http://purl.imsglobal.org/vocab/lis/v2/course#CourseSection"
]
},
"https://purl.imsglobal.org/spec/lti/claim/resource_link": {
"id": "0d0b8a77054343a1901d0db481759e84",
"title": "Introduction Assignment",
"description": "This is the introduction assignment"
},
"https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice": {
"context_memberships_url": "https://ltiadvantagevalidator.imsglobal.org/ltitool/namesandroles.html?memberships=1882",
"service_versions": [
"2.0"
]
},
"https://purl.imsglobal.org/spec/lti-ags/claim/endpoint": {
"scope": [
"https://purl.imsglobal.org/spec/lti-ags/scope/lineitem",
"https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly",
"https://purl.imsglobal.org/spec/lti-ags/scope/score"
],
"lineitems": "https://ltiadvantagevalidator.imsglobal.org/ltitool/rest/assignmentsgrades/1882/lineitems"
}
}

View File

@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDoPNEnOvHQpOGL
SmI7fB00Dd7v7FeXLlYmjTQKqUoOh23JfrBFPvoThwPnvKuv9la5oD7qJ1IU9oRB
fD20KqpMitLhJMhiuW8LQJ4QDubSzY9sjZ99rG/aSh/F2Y5pQjxhbw0io3IcyXoB
zPWVA45nnFKt4bkkCq1mnLsDAN2kmju6n33fsAP1lXvuqW3LrFEpWo4Y/X5wf3vM
y+VCjQRRZSFEDMOVOUJedt5KNXKkRPeX3dY9P2CcjLC3XFfQvqsgl37h/JTp9ppO
gY33Pj9DprLbEVIQmeg0Fb3Ajzzpbvm8txUudP3lgoknBmgoRr3KhX9k+JMElwW/
UcU9/iJtAgMBAAECggEBANO831TNQTvhmGHO59EkT9vt6Z0F9rY34QQ1KYWu435r
q4VSpJP93zN+neji9AXyqw+DMtl6EDRcriimhfuGCs7Oo4Xya2DXgI7Z00MA0yLP
mDx4wzlpxnFXs7BHsrf1U+fhwDAcpSXp6/tIS4AZRfThaeBvNMXPllk//KG4YFx5
Jd+nMHOr+TdGAYQDCCIPjFQ3rRR433+ZdTe7IWg/FHFXuCmJdoVLocIJg4rBHjKm
/UkEhKVINtacpHwSKKBUwnFQs9DhCgus0uCstFHl9AETomrefURESqn4u4LPsGjD
wxqV0rRc2Rr64xrfQpS708y6FrBHa1MoHBOTCuN3+gECgYEA96NBy9pWlkY7dAKx
n9RpnqArT1LOdGNc2sgce8Hqyn8E+JQ83dGTSDPXxUOXuJj8k3/8wFIl4DFwuX4m
5tDpJCQGJMd2c70/Ee3XWTR/NqJf09FrSULGF8CgtHEzITVftn1JQqmhu7GT9KfM
QEPkCBZ0pgZk+KneiwJoy5PgqD0CgYEA8BRuUX1/n8f2530r9A7PD3k6wYy/Y3kH
ZNxOyTfU3T5BaGYLmrUSfvU0/iLN8pTosgjb64v3NX+Odxm3QUcjJfZZvGXFY4LJ
SxrHqUR3pdqEhFo5p//lgTbyfmDTivVEX1N51IgeF383j0v51SKZ/joXEpB0bnip
ifC0D6zp1fECgYEAlfzNxziRJSeYruVKzDGNX0RHtx3CagAcp254wgRrvwY77otq
ajebaynrUFFmPap7oKLuZVXcFvQbAF6GFVsHOpqPFguxlNxUrPlPa3o+asriG5tF
zfOho5VKQMAnZb+8Hv23N6cijFo78P0I2wvDu5pOQJiy42GPpsZozpTch0kCgYBh
bpk63yi9SqTsW4NL//qOeA+dXyaJEyQqDbK3vL3ZsBtRaCCLf7Lq7U69WJimO0KY
hjniRSJlhsflk/0oM9uS24Cdkdviv8A7h7nB+zRnjeA76nX9tT+KCietnFQdz94Y
pcMKutcjiBCfSiExG2LNpvuYICHwd22uuo4I0o7vsQKBgQDexwa/iM+ZStTFqbc1
ES4a0F+LAccVzTnqs156hHbvl3DEPstkn6YbeCRttdP0HYGst8kL1SbGiCnT3QDr
w0uJyJvV6cQ+kTIUj+Z/565rqknqmF4PUdN2zM6m7abNf8AoEvxDk+htG7ZDCvSH
ikLoBvdctqsEWGB4SAGpZF45qw==
-----END PRIVATE KEY-----