Skip to content

Conversation

dbhynds
Copy link

@dbhynds dbhynds commented Mar 26, 2020

This PR addresses numerous issues with the library:

  • The documentation for the Cookie and Cache objects indicates that they are interfaces, when in fact they implementations. The converts them to interfaces and builds out separate implementations for them.
  • Removes a number of ?> tags per PSR-2 2.2
  • Create a class for launch-related constants and removes magic strings.
  • Fixes several issues with LTI_Launch_message::validate_jwt_signature() to allow these failures to be properly handled per the LTI 1.3 certification process (specifically, no kid specified, and expired jwt token)
  • Throws an exception when no Deployment ID is specified
  • Exposes the cookie prefix so the cookie can be referenced outside of the context of this library without using magic strings

This PR is dependent on EricTendian's PR: #44

@dbhynds
Copy link
Author

dbhynds commented May 5, 2020

@MartinLenord do you have any feedback on these changes?

Copy link
Collaborator

@MartinLenord MartinLenord left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution, i'm sorry that i've been so slow to look at it (with the cancellation of the Europe meet and LILI, the plans i had for updating this have been pushed back a little)

I've made a couple of small suggestions, but otherwise i'd be happy to merge in the changes

@@ -191,7 +192,11 @@ private function get_public_key() {
foreach ($public_key_set['keys'] as $key) {
if ($key['kid'] == $this->jwt['header']['kid']) {
try {
return openssl_pkey_get_details(JWK::parseKey($key));
return openssl_pkey_get_details(
JWK::parseKeySet([
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a shame that parseKey is private in the firebase implementation,

It might be neater here to just parse the keyset then check for the key we are looking for is there, then we can avoid the whole for loop here.

try {
    $parsed_key_set = JWK::parseKeySet($_public_key_set);
    if (isset($parsed_key_set[$this->jwt['header']['kid']])) {
        return openssl_pkey_get_details($parsed_key_set[$this->jwt['header']['kid']);
    }
} catch(\Exception $e) {
    throw new LTI_Exception("Unable to parse public key", 1);
}

Copy link
Author

Choose a reason for hiding this comment

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

It's made public in the latest version thanks to EricTendian :)
https://github.com/firebase/php-jwt/blob/v5.2.0/src/JWK.php#L35


namespace IMSGlobal\LTI;

class LTI_Constants
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is super neat and something i've been meaning to do for an age but never brought myself to do it, so thanks for that

public const DL_DEEP_LINK_SETTINGS = 'https://purl.imsglobal.org/spec/lti-dl/claim/deep_linking_settings';

// LTI NRPS
public const NRPS_NAMESROLESPROVISIONINGSERVICE = 'https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Naming is always a pain, it would be clearer if we did <SERVICE>_<TYPE>_<NAME> e.g. NRPS_CLAIM_SERVICE and NRPS_SCOPE_READ_ONLY

Copy link
Author

Choose a reason for hiding this comment

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

Sounds good. I'll implement this as soon as I get a chance.

@dbhynds dbhynds requested a review from MartinLenord June 8, 2020 15:22
@dbhynds
Copy link
Author

dbhynds commented Jun 8, 2020

@MartinLenord I finally got some time to go back and implement the feedback. Let me know if you have any additional comments.

Also, can we get this repo added to packagist? It makes me a little nervous that our composer.json is just pointing to the master branch. As it stands, anyone could push breaking changes to master and we'd have no idea and no easy way to lock it down to a specific version.

@mumitr0ll
Copy link

@dbhynds - IMS will discuss the possible movement of a point-in-time copy of the master to a repo site. Martin L can't do that on his own - that must be a change from IMS Global.

However, you worries are real and we will look into it. If IMS doesn't want to (for some technical reason unknown to me) use pakagist or some other repo site, could we do Releases here in Github? Would your php composer suite be able to query and use named/numbered Releases?
-Dereck

@dbhynds
Copy link
Author

dbhynds commented Jun 8, 2020

@mumitr0ll Thanks for sharing that context. Github releases would be an acceptable fallback if the packagist option doesn't work out.

@ernst77
Copy link

ernst77 commented Oct 21, 2020

Any update on the merge? I will be using this branch instead of the official one.

@tijsverwest
Copy link

Hi, any updates on this? Would be nice to have it merged, if possible. Thanks!

@dbhynds
Copy link
Author

dbhynds commented Jan 14, 2021

Thanks for those who have asked. Yesterday, I actually released a large refactor to this library (based on this fork) to Packagist: https://packagist.org/packages/packbackbooks/lti-1p3-tool. We're still doing final testing on it to ensure it's stable, but should be releasing 1.0 of the package early next week. There are some considerable changes as part of the upgrade (most classes and methods got renamed). However, if you want to start using the new package, do:

composer require packbackbooks/lti-1p3-tool

Thanks for the interest.

snake pushed a commit to snake/lti-1-3-php-library that referenced this pull request Jan 19, 2022
Fix a PHP warning when optional 'data' property of deep link settings is not present in message launch.
@dbhynds dbhynds closed this by deleting the head repository Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants