Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Lti 1.3 plus roster update #640

Closed
wants to merge 225 commits into from
Closed
Show file tree
Hide file tree
Changes from 175 commits
Commits
Show all changes
225 commits
Select commit Hold shift + click to select a range
0204720
Added composer.lock and .phar to .gitignore
Nov 21, 2019
d9bef9c
Added lti-1p3-tool composer package
Nov 28, 2019
76364ac
Added Lti13 files.
Nov 28, 2019
a50d777
Updated touched files.
Dec 11, 2019
c268c36
Created docs
Dec 11, 2019
eba36d1
Updated docs
Dec 11, 2019
57e768c
Updated docs
Dec 11, 2019
ec0012f
Removed index and added launch controller actions and views.
Dec 11, 2019
cf0bb45
Updated docs
Dec 11, 2019
f098c9d
Moved docs in app folder.
Dec 11, 2019
09dd040
Added key files to .gitignore
Dec 11, 2019
8ec0e0a
Added Lib, Model, Controller, routes.
Dec 12, 2019
8da4cee
Added lti13_bootstrap.php. Added routes. Renamed files and classes to…
Dec 12, 2019
9a49963
Corrected path for registration JSON file.
Dec 12, 2019
5f18bba
Removed unneeded line in model.
Dec 12, 2019
95945c6
Corrected path for registration JSON file and key files.
Dec 12, 2019
546ffa3
Corrected url route.
Dec 12, 2019
5127731
Added JWK loading in bootstrap.
Dec 12, 2019
b9cac25
Added JWK loading in bootstrap.
Dec 12, 2019
b4d6da1
Updated docblock in lti13_bootstrap.php.
Dec 12, 2019
b1338f5
Updated docs after LTI-RI.
Dec 12, 2019
2ae447f
Moved docs to docs/lti13.
Dec 12, 2019
a9dab4d
Added isset condition to $_SERVER['HTTP_X_FORWARDED_PROTO'] in bootst…
Dec 13, 2019
54be131
Added @ in condition.
Dec 13, 2019
534cdac
Corrected the 'glob' path in Lti13Database::set_issuers().
Dec 13, 2019
f5b0dfc
Monospace font in temp launch view.
Dec 13, 2019
a3444ed
Updated docs.
Dec 13, 2019
cb1e297
Updated docs.
Dec 13, 2019
5e4c808
Updated docs.
Dec 13, 2019
d15d25c
Refactored model call in Lti13Controller.
Dec 16, 2019
6ac41c0
Updated launch view.
Dec 16, 2019
814aa7f
Updated launch view.
Dec 16, 2019
662a98d
Updated docs.
Dec 16, 2019
40e95bf
Added lti13 index page.
Dec 16, 2019
183c317
Added test links to LTI 1.3 index.
Dec 16, 2019
19d118a
Updated doc.
Dec 16, 2019
1d39a26
Updated doc.
Dec 17, 2019
9134070
Moved LTI13Database from Controller to Model.
Dec 17, 2019
0bd530f
Updated controller.
Dec 17, 2019
78133fa
Added try-catch blocks around LTI_OIDC_Login->do_oidc_login_redirect(…
Dec 18, 2019
f292ff2
Added NRPS members to LTI13 launch view.
Dec 18, 2019
cfa0602
Added check in Lti13::get_members()
Dec 19, 2019
fdb84e7
Added @ for check in Lti13::get_members()
Dec 19, 2019
72a6c5a
Added ags and deep link data display.
Dec 20, 2019
ca7797a
namespace up
Dec 20, 2019
d5b0d78
Renamed lti13_database.php to LTI13Database.php.
Dec 20, 2019
ab70f40
Updated docs
Dec 20, 2019
09840c7
Added get_course_info() plus unit tests.
Dec 24, 2019
cee4390
Ported LTI 1.1 controller and components to LTI 1.3 controller and mo…
Jan 4, 2020
851173b
Added update() model method. Added getUserType() model method. Added …
Jan 6, 2020
afdbdda
Updated unit test doc.
Jan 6, 2020
691dc5b
Moved launch functionality from controller to model.
Jan 6, 2020
22b65a2
Updated unit test doc.
Jan 7, 2020
c9988c3
Added phpdoc @deprecated to LTI 1.1 classes.
Jan 7, 2020
ed71ee5
Removed duplicate entry in docker-compose.yml
Jan 7, 2020
52e3503
Added phpdoc block in unit test.
Jan 7, 2020
2cc7f6d
Added links to previous code on GitHub.
Jan 7, 2020
0d9526b
Added getNrps() and getNrpsMembers() in model. Modified isInstructor(…
Jan 7, 2020
e116ac2
Removed unneeded model class properties.
Jan 7, 2020
251c58b
Refactored getNrpsMembers() in model.
Jan 7, 2020
7f3845e
Refactored findUserByLtiId() in model.
Jan 7, 2020
dfbcc55
Modified controller's update() and signInUser().
Jan 7, 2020
a0af558
Modified addUser() and added getUsername() in model.
Jan 7, 2020
ebcd75b
Added try-catch blocks in model.
Jan 7, 2020
a669c78
Added test_getUsername() unit test.
Jan 7, 2020
48b285b
Corrected test_getLtiCourseDataEmptyJwtPayload() unit test.
Jan 7, 2020
dcc4e89
Removed unneeded try-catch in model's addUser()
Jan 7, 2020
edc72a7
Added exception in model's getNrpsMembers().
Jan 7, 2020
9d45e1b
Renamed findUserByLtiId() to findUserByLtiUserId(). Added exception i…
Jan 7, 2020
a16ea1b
Updated docs.
Jan 8, 2020
8f25396
Updated readme.
Jan 8, 2020
bb898a4
Fixed unit test fixtures loading. Fixed model's getUsername().
Jan 8, 2020
f184d42
Added test_findUserByLtiUserId().
Jan 8, 2020
e2a4d1d
Added test_findCourseByLabel().
Jan 8, 2020
68bd747
Added test_getNrpsMembers() and test_createCourseRoster(). Removed me…
Jan 8, 2020
5259dce
Added casting of arrays in model. Added test_updateCourseRoster() and…
Jan 9, 2020
faca0f0
Fixed test_getUserType().
Jan 9, 2020
cdfec9c
Added intl library to ipeer_app_unittest container to fix phing SQL d…
Jan 9, 2020
d01289e
Cloned master branch readme.md.
Jan 9, 2020
63c7d0d
Updated unit test doc with phing fix.
Jan 9, 2020
3884d1a
Fixed addUserToCourse() in model. Added test_saveExistingUserToCourse().
Jan 9, 2020
d24446c
Removed App::import line and changed class property name.
Jan 14, 2020
74fab32
Removed App::import line and changed class property name.
Jan 14, 2020
8df668c
Renamed class properties: removed the 'Test' part.
Jan 14, 2020
695e924
Updated LTI13Database::find_deployment() after Composer update of ims…
Jan 14, 2020
819e5ba
Added initial system web test and doc.
Jan 17, 2020
ac0a504
Modified initial system web test.
Jan 17, 2020
eece085
Modified initial system web test and added screenshot.
Jan 17, 2020
26a9251
Modified Lti13LoginTestCase::errorReporting var name.
Jan 17, 2020
32ed263
Added error handler to hide php warning.
Jan 21, 2020
a7c26e4
Added php doc vars for error_handler().
Jan 21, 2020
28471f0
Added php doc vars for Lti13LoginTestCase::error().
Jan 21, 2020
94b90ed
Added intl library to 'app' docker container.
Jan 25, 2020
5f486e0
Updated 10 Web tests.md
Jan 25, 2020
3ee9383
Updated canvas_integration.test.php and documented my process.
Jan 25, 2020
0a69644
Updated docs and added Canvas-related docs.
Feb 11, 2020
4991f4e
Modified error_handler().
Feb 11, 2020
0f2bfdf
Updated docs.
Feb 11, 2020
e04012d
Deleted phpunit.phar
Feb 11, 2020
79cc604
Reinserted launch response data methods.
Feb 11, 2020
7fb624b
Formatted Exception messages.
Feb 11, 2020
2086aa8
Added logs and fixed errors to successfully launch and update roster.
Feb 13, 2020
532124e
Moved docs in subdir. Updated docs.
Feb 14, 2020
0d319bc
Added canvas.docker data to registration.json. Modified split(). Remo…
Feb 14, 2020
156deee
Modified index view.
Feb 14, 2020
f421a83
Updated docs
Feb 18, 2020
b6978a8
Updated docs
Feb 19, 2020
8eb5aa0
Added upgrade_345.php
Feb 19, 2020
f5e8d2e
Updated docs
Feb 19, 2020
7979c37
Updated docs
Feb 20, 2020
d9c603e
Added Canvas PostgreSQL dump and Canvas patches.
Feb 20, 2020
b968204
Modified Lti13Controller::beforeFilter().
Feb 20, 2020
e869c72
Modified registration.json. Updated docs.
Feb 20, 2020
a2835ea
Added Canvas patch files
Feb 20, 2020
30d9854
Added links to index view
Feb 20, 2020
da13c32
Removed Canvas patched files
Feb 20, 2020
4044545
Updated registration.json with course-specific deployment_id. Updated…
Feb 21, 2020
563975e
Deleted LTI_Assignments_Grades_Service_Override::get_grades()
Feb 21, 2020
9dd6659
Updated docs after review for ultimate test.
Feb 25, 2020
dd2a9e7
Updated diff and sql dumps, and index view.
Feb 25, 2020
f607744
Updated doc.
Feb 25, 2020
dee7a0c
Updated doc.
Feb 25, 2020
b73be9a
Fixed registration.json's client_id.
Feb 25, 2020
f06ef07
Redid iPeer original fixture
Feb 25, 2020
0c12436
Modified Canvas course names to match iPeer in postgresql dump.
Feb 25, 2020
2ccb3bf
Updated docs.
Feb 25, 2020
8d3a1db
Modified roster updates log.
Feb 25, 2020
82f7e2c
Split run demo doc in two.
Feb 26, 2020
7ee7b18
Updated doc titles.
Feb 26, 2020
f757ea6
Updated docs.
Feb 26, 2020
40e1ef4
Modified ipeer dB table.
Feb 26, 2020
0598b22
Updated docs.
Feb 26, 2020
a2ed957
Updated ipeer dB reset SQL
Feb 26, 2020
781a18d
Updated unit test.
Feb 26, 2020
706f6c5
Added success message
Feb 26, 2020
93db1a7
Modified doc on dinghy restart instead of rebuilding Canvas.
Feb 27, 2020
daa14b9
Added logging of adding new users in a new course.
Feb 27, 2020
a7e7f26
Moved resetLogs() from controller to model.
Mar 4, 2020
19e8d24
Updated IMS Global LTI PHP library.
Mar 26, 2020
c6f0d47
Update docs on dinghy start
Mar 26, 2020
1b0f062
Started test button for Update roster from Canvas.
Mar 26, 2020
8ab8284
Patched IMS Global's LTI 1.3 PHP library's Cookie.php
Mar 27, 2020
a1263fe
Removed Lti13 routes in routes.php. Modified launch view. Added launc…
Mar 31, 2020
53b3e14
Corrected Cookie::set_cookie in diff.
Mar 31, 2020
51099ad
Made roster work for Canvas but inside Lti13Controller::launch(). I n…
Apr 1, 2020
4bf3841
Implemention doc for April.
Apr 1, 2020
380a913
Fixed jwt header array vs json bug.
Apr 1, 2020
36b1a2c
Added 'updateRosterFromCanvas' to 'acos' mysql table.
Apr 2, 2020
1beba4b
Separated the login&launch actions from the roster update action. Rem…
Apr 8, 2020
813c035
Added try catch to Lti13Controller::getCourseId()
Apr 9, 2020
e6ce51a
Updated docs with dos2unix and Cookie patch.
Apr 16, 2020
25635fb
Added courses_lti_platform_deployments to schema.
Apr 16, 2020
c176a24
Updated unit tests.
Apr 16, 2020
229a3cb
Added fixtures, schema changes for LTI 1.3 registration and deploymen…
Apr 18, 2020
227077e
Created tool registration model and its deployments' model.
Apr 20, 2020
4b649b7
Updated docs.
Apr 21, 2020
3f7ed14
Moved try-catch blocks from Model to Controller.
Apr 21, 2020
4687826
Added Lti13::getDeploymentId() and LtiPlatformDeployment::saveDeploym…
Apr 21, 2020
0f0bcfd
Updated LtiToolRegistration::findIssuers()
Apr 21, 2020
bce5ed8
Updated and added docs.
Apr 21, 2020
177c626
Updated Lti13::updateRoster()'s error message.
Apr 21, 2020
7bbbbb9
Fixed redirection with different iPeer logged-in situations.
Apr 28, 2020
b35989c
Fixed Student user home page scenario.
Apr 29, 2020
96defb9
Retested workflow scenarios and updated docs.
May 4, 2020
5071516
Updated markdown tables in doc.
May 4, 2020
7beb49f
Updated markdown tables in doc.
May 4, 2020
a826717
Updated markdown tables in doc.
May 4, 2020
9e285f9
Updated path in doc.
May 4, 2020
2fddb7f
Updated readme.md
May 4, 2020
3c6c341
Added Transfer codebase to GitHub doc.
May 4, 2020
94513ec
Merge branch 'master' into lti-1.3-roster-update
stemar May 4, 2020
6e194f2
Corrected comma in composer.json
May 4, 2020
9d14053
Corrected DROP INDEX IF EXISTS for Travis-CI
May 4, 2020
e5153f8
Corrected DROP INDEX IF EXISTS for Travis-CI
May 4, 2020
82a80ec
Updated doc.
May 5, 2020
a645161
Removed composer.lock from .gitignore
May 21, 2020
8e4be9b
Changed DATABASE_VERSION to 18
May 21, 2020
d891e92
Changed version.txt to 3.4.5
May 21, 2020
cc149ec
Turned off ENABLE_CANVAS_TEST
May 21, 2020
73572b3
Restored original port 8081 for unit test docker image
May 21, 2020
d9480b5
Changed composer package imsglobal/lti-1-3-php-library to forked ubc/…
May 25, 2020
2cae9e6
Updated docs on forking IMSGlobal LTI 1.3 library.
May 27, 2020
39b487f
Deleted development notes from version control.
Jun 2, 2020
e1f1d1f
Updated docs.
Jun 14, 2020
463de19
Updated docs.
Jun 14, 2020
b5991d5
Removed app/config/lti13 path that was for development only.
Jun 14, 2020
e495d7b
Modified SQL and LTI13Database class for lti_tool_registrations.tool_…
Jun 14, 2020
269a22f
Added unique index on lti_tool_registrations.(,)
Jun 14, 2020
1af6bd8
Restored private key file after Jenkins fail: Jenkins parses -- as a …
Jun 14, 2020
a08aafb
Changed column name in lti_tool_registrations.private_key_file to too…
Jun 14, 2020
d4181e5
Deleted INSERT statements in delta_18.sql.
Jun 14, 2020
a7eae95
Added admin page to add/edit/delete tool registrations.
Jun 20, 2020
da70635
Moved filter and replace deployment methods from controller to model.
Jun 20, 2020
d02ff07
Removed DROP INDEX line from delta_18.sql MariaDB version incompatibi…
Jun 22, 2020
492002e
Updated IPEER_VERSION in core.php
Jun 23, 2020
efa1f45
Merge branch 'master' of github.com:ubc/iPeer into lti-1.3-roster-update
Jun 24, 2020
7f1e2c1
Adding intl library
Jun 24, 2020
1fd29c8
Modified delta_18.sql with new numbers for LtiToolRegistrations in 'a…
Jun 29, 2020
d4d6d8b
Fixed 500 error permissions for admin page Lti 1.3 Tool Registrations
Jun 29, 2020
7c0448f
Updated schema dumps.
Jun 29, 2020
f848aa2
Added view to permissions
Jun 30, 2020
fd80b96
Fix controller permissions in renaming controller file, updating acos…
Jun 30, 2020
6345a26
Debug mode on staging
Jun 30, 2020
1dac549
Debug mode on staging OFF
Jun 30, 2020
c4f6e9f
Updated Dockerfiles and composer.json to match lastest master branch.
Jul 9, 2020
c3398be
Composer update
Jul 10, 2020
75097ff
Added unit tests for LtiToolRegistration and LtiPlatformDeployment.
Jul 12, 2020
8a9f7ce
Corrected ubc/lti-1-3-php-library branch to master
Jul 12, 2020
1aaa4fb
Merge branch 'master' into lti-1.3-roster-update
stemar Jul 12, 2020
10152e9
Edited Lti13::addUserToCourse() to call constant instead of hardcoded…
Jul 15, 2020
0901224
Added automatic user login by puid.
Jul 31, 2020
300f060
Added test page for LTI 1.3 launch.
Aug 11, 2020
3a9544d
Added test page for LTI 1.3 launch.
Aug 11, 2020
e86bc98
Commented out the test code.
Aug 12, 2020
48e1bbe
Added kid field to dB and admin views.
Aug 13, 2020
5ad4dce
Removed getNrpsMembers() call in Lti13::getData().
Aug 13, 2020
5e46093
Modified Lti13Controller::launch() redirect checks.
Aug 13, 2020
f38fa5c
Modified Lti13Controller::launch() redirect checks.
Aug 13, 2020
1361571
Modified Lti13Controller::launch() redirect checks.
Aug 13, 2020
28666eb
Modified Lti13Controller::launch() redirect checks.
Aug 13, 2020
fe9a8a1
Revert "Modified Lti13Controller::launch() redirect checks."
ionparticle Aug 14, 2020
4c60730
FIX redirect loop after LTI 1.3 launch login
ionparticle Aug 14, 2020
a849657
Added false to avoid automatic redirect.
Aug 14, 2020
76f0bf6
Cleaned up test code in Lti13Controller model.
Aug 17, 2020
02f4cf7
Cleaned up test code in Lti13Controller model.
Aug 17, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ tags
vendor/
.idea
.data
composer.phar
composer.lock
stemar marked this conversation as resolved.
Show resolved Hide resolved
app/config/**/*.key
.DS_Store
2 changes: 1 addition & 1 deletion Dockerfile-app
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN apt-get update && apt-get install --no-install-recommends --no-install-sugge
&& rm -rf /var/lib/apt/lists/* \
&& ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so \
&& ln -s /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so \
&& docker-php-ext-install -j$(nproc) xml gd ldap mysqli \
&& docker-php-ext-install -j$(nproc) xml gd ldap mysqli intl \
&& pecl install timezonedb \
&& docker-php-ext-enable timezonedb \
&& curl https://getcomposer.org/download/1.8.4/composer.phar -o /usr/local/bin/composer \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-app-unittest
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN apt-get update && apt-get install --no-install-recommends --no-install-sugge
&& rm -rf /var/lib/apt/lists/* \
&& ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so \
&& ln -s /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so \
&& docker-php-ext-install -j$(nproc) xml gd ldap mysqli pdo_mysql\
&& docker-php-ext-install -j$(nproc) xml gd ldap mysqli pdo_mysql intl \
&& pecl install timezonedb \
&& docker-php-ext-enable timezonedb \
&& curl https://getcomposer.org/download/1.8.4/composer.phar -o /usr/local/bin/composer \
Expand Down
5 changes: 5 additions & 0 deletions app/config/lti13/canvas/Dockerfile.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
105c105,106
< RUN COMPILE_ASSETS_NPM_INSTALL=0 bundle exec rake canvas:compile_assets
---
> # RUN COMPILE_ASSETS_NPM_INSTALL=0 bundle exec rake canvas:compile_assets
> RUN COMPILE_ASSETS_BUILD_JS=0 bundle exec rake canvas:compile_assets_dev
Binary file added app/config/lti13/canvas/canvas.postgresql.dump
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions app/config/lti13/canvas/postgres-Dockerfile.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
18a19
> postgresql-server-dev-9.6 \
32a34,35
> postgresql-server-dev-9.6 \
> postgresql-client-9.6 \
13 changes: 13 additions & 0 deletions app/config/lti13/ipeer/Cookie.php.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
26a27,38
> if (PHP_VERSION_ID < 70300) {
> $options += [
> 'path' => "/",
> 'domain' => "",
> 'secure' => false,
> 'httponly' => false
> ];
> extract(array_merge($cookie_options, $options)); // => $expires, $path, $domain, $secure, $httponly
> setcookie("LEGACY_" . $name, $value, $expires, $path, $domain, $secure, $httponly);
> return $this;
> }
>
1,769 changes: 1,769 additions & 0 deletions app/config/lti13/ipeer/ipeer.reset.sql

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions app/config/lti13/registration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
stemar marked this conversation as resolved.
Show resolved Hide resolved
"https://lti-ri.imsglobal.org": {
"client_id": "ipeer-lti13-001",
"auth_login_url": "https://lti-ri.imsglobal.org/platforms/652/authorizations/new",
"auth_token_url": "https://lti-ri.imsglobal.org/platforms/652/access_tokens",
"key_set_url": "https://lti-ri.imsglobal.org/platforms/652/platform_keys/654.json",
"private_key_file": "app/config/lti13/tool.private.key",
"deployment": [
"1"
]
},
"https://canvas.instructure.com": {
"client_id": "10000000000001",
"auth_login_url": "http://canvas.docker/api/lti/authorize_redirect",
"auth_token_url": "http://canvas.docker/login/oauth2/token",
"key_set_url": "http://canvas.docker/api/lti/security/jwks",
"private_key_file": "app/config/lti13/tool.private.key",
"deployment": [
"1:4dde05e8ca1973bcca9bffc13e1548820eee93a3",
"2:f97330a96452fc363a34e0ef6d8d0d3e9e1007d2",
"3:d3a2504bba5184799a38f141e8df2335cfa8206d"
]
}
}
1 change: 1 addition & 0 deletions app/config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* */

if (IS_INSTALLED) {

stemar marked this conversation as resolved.
Show resolved Hide resolved
// Disable access to the installer by redirecting all attempts to access
// the installer to the index page. Except for install5, which is needed
// to tell the user that an install was successful.
Expand Down
47 changes: 47 additions & 0 deletions app/config/sql/delta_18.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
ALTER TABLE `users` MODIFY `lti_id` varchar(64) NULL DEFAULT NULL;

ALTER TABLE `courses` MODIFY `canvas_id` varchar(64) NULL DEFAULT NULL;
DROP INDEX IF EXISTS `canvas_id` ON `courses`;
ALTER TABLE `courses` ADD INDEX `canvas_id` (`canvas_id`);

DROP TABLE IF EXISTS `lti_platform_deployments`;
CREATE TABLE `lti_platform_deployments` (
`iss` varchar(255) NOT NULL,
`deployment` varchar(64) NOT NULL COMMENT 'Platform deployment ID hash. https://purl.imsglobal.org/spec/lti/claim/deployment_id',
KEY `iss` (`iss`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;

INSERT INTO `lti_platform_deployments` VALUES
('https://lti-ri.imsglobal.org', '1'),
stemar marked this conversation as resolved.
Show resolved Hide resolved
('https://canvas.instructure.com', '1:4dde05e8ca1973bcca9bffc13e1548820eee93a3'),
('https://canvas.instructure.com', '2:f97330a96452fc363a34e0ef6d8d0d3e9e1007d2'),
('https://canvas.instructure.com', '3:d3a2504bba5184799a38f141e8df2335cfa8206d');

DROP TABLE IF EXISTS `lti_tool_registrations`;
CREATE TABLE `lti_tool_registrations` (
`iss` varchar(255) NOT NULL,
`client_id` varchar(255) NOT NULL,
`auth_login_url` varchar(255) NOT NULL,
`auth_token_url` varchar(255) NOT NULL,
`key_set_url` varchar(255) NOT NULL,
`private_key_file` varchar(255) NOT NULL,
PRIMARY KEY `iss` (`iss`)
stemar marked this conversation as resolved.
Show resolved Hide resolved
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;

INSERT INTO `lti_tool_registrations` VALUES
(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to above, probably shouldn't put example/test data into the delta

'https://lti-ri.imsglobal.org',
'ipeer-lti13-001',
'https://lti-ri.imsglobal.org/platforms/652/authorizations/new',
'https://lti-ri.imsglobal.org/platforms/652/access_tokens',
'https://lti-ri.imsglobal.org/platforms/652/platform_keys/654.json',
'app/config/lti13/tool.private.key'
),
(
'https://canvas.instructure.com',
'10000000000001',
'http://canvas.docker/api/lti/authorize_redirect',
'http://canvas.docker/login/oauth2/token',
'http://canvas.docker/api/lti/security/jwks',
'app/config/lti13/tool.private.key'
);
49 changes: 49 additions & 0 deletions app/config/sql/ipeer_samples_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2391,3 +2391,52 @@ CREATE TABLE IF NOT EXISTS `jobs` (
-- store course term
ALTER TABLE `courses` ADD COLUMN `term` VARCHAR(50) NULL DEFAULT NULL;
--- END: Added by DB upgrade to version 17

--- START: Added by DB upgrade to version 18
ALTER TABLE `users` MODIFY `lti_id` varchar(64) NULL DEFAULT NULL;

ALTER TABLE `courses` MODIFY `canvas_id` varchar(64) NULL DEFAULT NULL;
ALTER TABLE `courses` ADD INDEX `canvas_id` (`canvas_id`);

DROP TABLE IF EXISTS `lti_platform_deployments`;
CREATE TABLE `lti_platform_deployments` (
`iss` varchar(255) NOT NULL,
`deployment` varchar(64) NOT NULL COMMENT 'Platform deployment ID hash. https://purl.imsglobal.org/spec/lti/claim/deployment_id',
KEY `iss` (`iss`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;

INSERT INTO `lti_platform_deployments` VALUES
('https://lti-ri.imsglobal.org', '1'),
('https://canvas.instructure.com', '1:4dde05e8ca1973bcca9bffc13e1548820eee93a3'),
('https://canvas.instructure.com', '2:f97330a96452fc363a34e0ef6d8d0d3e9e1007d2'),
('https://canvas.instructure.com', '3:d3a2504bba5184799a38f141e8df2335cfa8206d');

DROP TABLE IF EXISTS `lti_tool_registrations`;
CREATE TABLE `lti_tool_registrations` (
`iss` varchar(255) NOT NULL,
`client_id` varchar(255) NOT NULL,
`auth_login_url` varchar(255) NOT NULL,
`auth_token_url` varchar(255) NOT NULL,
`key_set_url` varchar(255) NOT NULL,
`private_key_file` varchar(255) NOT NULL,
PRIMARY KEY `iss` (`iss`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;

INSERT INTO `lti_tool_registrations` VALUES
(
'https://lti-ri.imsglobal.org',
'ipeer-lti13-001',
'https://lti-ri.imsglobal.org/platforms/652/authorizations/new',
'https://lti-ri.imsglobal.org/platforms/652/access_tokens',
'https://lti-ri.imsglobal.org/platforms/652/platform_keys/654.json',
'app/config/lti13/tool.private.key'
),
(
'https://canvas.instructure.com',
'10000000000001',
'http://canvas.docker/api/lti/authorize_redirect',
'http://canvas.docker/login/oauth2/token',
'http://canvas.docker/api/lti/security/jwks',
'app/config/lti13/tool.private.key'
);
--- END: Added by DB upgrade to version 18
12 changes: 7 additions & 5 deletions app/controllers/components/lti_requester.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
* is that some of the libraries aren't compliant, so couldn't talk to Moodle's
* OAuth module.
* ***************************/

/**
* LtiRequesterComponent
*
* @uses Object
* @package CTLT.iPeer
* @author John Hsu <[email protected]>
* @copyright 2012 All rights reserved.
* @license MIT {@link http://www.opensource.org/licenses/MIT}
* @deprecated since 3.4.5
* @uses Object
* @package CTLT.iPeer
* @author John Hsu <[email protected]>
* @copyright 2012 All rights reserved.
* @license MIT {@link http://www.opensource.org/licenses/MIT}
*/
class LtiRequesterComponent extends CakeObject
{
Expand Down
11 changes: 6 additions & 5 deletions app/controllers/components/lti_verifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
/**
* LtiVerifierComponent
*
* @uses Object
* @package CTLT.iPeer
* @author John Hsu <[email protected]>
* @copyright 2012 All rights reserved.
* @license MIT {@link http://www.opensource.org/licenses/MIT}
* @deprecated since 3.4.5
* @uses Object
* @package CTLT.iPeer
* @author John Hsu <[email protected]>
* @copyright 2012 All rights reserved.
* @license MIT {@link http://www.opensource.org/licenses/MIT}
*/
class LtiVerifierComponent extends CakeObject
{
Expand Down
149 changes: 149 additions & 0 deletions app/controllers/lti13_controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
<?php
App::import('Lib', 'Lti13Bootstrap');
App::import('Model', 'Lti13');

use IMSGlobal\LTI\LTI_Exception;
use IMSGlobal\LTI\LTI_OIDC_Login;
use IMSGlobal\LTI\OIDC_Exception;

/**
* LTI 1.3 Controller
*
* @uses AppController
* @package CTLT.iPeer
* @since 3.4.5
* @author Steven Marshall <[email protected]>
* @copyright 2019 All rights reserved.
* @license MIT {@link http://www.opensource.org/licenses/MIT}
* @link https://www.imsglobal.org/spec/security/v1p0/#fig_oidcflow
*/
class Lti13Controller extends AppController
{
public $uses = array('Lti13');

public function __construct()
{
parent::__construct();
}

public function beforeFilter()
{
$this->Auth->allow();
}

/**
* OIDC login action called by platform.
*/
public function login()
{
try {

$login = LTI_OIDC_Login::new($this->Lti13->db);
$url = Router::url('/lti13/launch', true);
$redirect = $login->do_oidc_login_redirect($url);
$redirect->do_redirect();

} catch (OIDC_Exception $e) {

$this->Session->setFlash(sprintf("Error doing OIDC login: %s", $e->getMessage()));
$this->redirect(array('controller'=>'home', 'action'=>'index'));

}
}

/**
* Launch action called by platform.
*/
public function launch()
{
try {

$launch = $this->Lti13->launch();
$data = $this->Lti13->getData($launch->get_launch_id());
$this->Lti13->resetLogs();
$this->log(json_encode($data, 448), 'lti13/launch');

stemar marked this conversation as resolved.
Show resolved Hide resolved
$this->Session->setFlash(__('LTI 1.3 launch success', true), 'good');

if (!$this->Auth->isLoggedIn()) {
$this->redirect('/');
}

$user = $this->checkUser();

if ($this->isAdminOrInstructor($user)) {
if ($courseId = @$this->Lti13->getCourseId()) {
$this->redirect(array('controller'=>'courses', 'action'=>'home', $courseId));
}
$this->redirect(array('controller'=>'courses', 'action'=>'index'));
}

$this->redirect(array('controller'=>'home', 'action'=>'index'));

} catch (LTI_Exception $e) {

$this->Session->setFlash($e->getMessage());
$this->redirect('/logout');

}
}

/**
* Update roster by course ID from platform.
*
* Called by tool, not platform.
* @param string $courseId
*/
public function roster($courseId)
{
try {

$this->Lti13->updateRoster($courseId);
$this->log($this->Lti13->rosterUpdatesLog, 'lti13/roster');

$this->Session->setFlash(__('Updated roster from Canvas', true), 'good');
$this->redirect($this->referer(array('controller'=>'home', 'action'=>'index')));

} catch (LTI_Exception $e) {

$this->Session->setFlash($e->getMessage());
$this->redirect($this->referer(array('controller'=>'home', 'action'=>'index')));

}
}

/**
* Check if current user has LTI user ID in dB.
*
* @return array
*/
private function checkUser()
{
if (!$user = $this->Lti13->findUserByLtiUserId()) {
throw new LTI_Exception("LTI user ID not found.");
return;
}

if ($user['User']['id'] != $this->Auth->user('id')) {
throw new LTI_Exception("Mismatched user logged in.");
return;
}

$this->log($user, 'lti13/user');

return $user;
}

/**
* Check if current user is in ['superadmin', 'admin', 'instructor']
*
* @param array $user
* @return bool
*/
private function isAdminOrInstructor($user)
{
$roles = array_column($user['Role'], 'name');
return (bool)preg_grep('/superadmin|admin|instructor/i', $roles);
}

}
11 changes: 6 additions & 5 deletions app/controllers/lti_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
/**
* LtiController
*
* @uses AppController
* @package CTLT.iPeer
* @author John Hsu <[email protected]>
* @copyright 2012 All rights reserved.
* @license MIT {@link http://www.opensource.org/licenses/MIT}
* @deprecated since 3.4.5
* @uses AppController
* @package CTLT.iPeer
* @author John Hsu <[email protected]>
* @copyright 2012 All rights reserved.
* @license MIT {@link http://www.opensource.org/licenses/MIT}
*/
class LtiController extends AppController
{
Expand Down
Loading