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