Skip to content

Commit beabf63

Browse files
authored
Merge pull request #127 from packbackbooks/v6.0-beta
v6.0 beta
2 parents b09f311 + df9b2da commit beabf63

File tree

84 files changed

+2696
-2163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+2696
-2163
lines changed

.githooks/pre-commit

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,16 @@ function lint_php {
9292
return 0 # There's nothing to lint.
9393
fi
9494

95-
phpcsfixer="vendor/bin/php-cs-fixer"
95+
pint="vendor/bin/pint"
9696

97-
if ! [ -x "$phpcsfixer" ]; then
98-
echo -e "${C_RED}PHP-CS-Fixer is not installed. Install it with \`composer install\`.${NO_FORMAT}" && return 1
97+
if ! [ -x "$pint" ]; then
98+
echo -e "${C_RED}Pint is not installed. Install it with \`composer install\`.${NO_FORMAT}" && return 1
9999
fi
100100

101101
php_files_arg=$(echo "$php_files" | tr '\n' ' ')
102102

103-
echo -e "${C_CYAN}Linting PHP-CS-Fixer...${NO_FORMAT}"
104-
$phpcsfixer fix -q || return 1
103+
echo -e "${C_CYAN}Linting Pint...${NO_FORMAT}"
104+
$pint || return 1
105105

106106
git add $php_files_arg
107107
}

.github/workflows/run_tests.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
name: Tests & style checks
1+
name: Tests & Style Checks
22
on:
3-
# Trigger on any PR being opened, or on a merge to master (to update the badge)
3+
# Trigger on any PR being opened
44
pull_request:
5+
# Or weekly and on a merge to master (to update the badge)
56
push:
67
branches:
78
- master
9+
schedule:
10+
- cron: 0 0 * * 0
811
jobs:
912
lint:
1013
name: Lint
@@ -21,7 +24,7 @@ jobs:
2124
strategy:
2225
matrix:
2326
php:
24-
- "7.4"
27+
- "8.0"
2528
- "latest"
2629
steps:
2730
- uses: "actions/checkout@v3"
@@ -34,3 +37,19 @@ jobs:
3437
composer-options: "${{ matrix.composer-options }}"
3538
- name: Run tests
3639
run: composer test
40+
41+
coverage:
42+
name: Code Coverage
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: "actions/checkout@v3"
46+
- uses: "shivammathur/setup-php@v2"
47+
with:
48+
php-version: latest
49+
coverage: xdebug
50+
- uses: "ramsey/composer-install@v2"
51+
- uses: paambaati/[email protected]
52+
env:
53+
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
54+
with:
55+
coverageCommand: composer test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
.phpunit.result.cache
55
.php_cs.cache
66
.php-cs-fixer.cache
7+
.pint.cache
78
.vscode
89

910
build
@@ -14,4 +15,5 @@ tests/_support/_generated/*
1415
vendor
1516

1617
# ignore the coverage folders
18+
**/.phpunit.cache
1719
**/coverage

.php-cs-fixer.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# LTI 1.3 Tool Library
22

3-
![Test status](https://github.com/packbackbooks/lti-1-3-php-library/actions/workflows/run_tests.yml/badge.svg?branch=master)
3+
![Test status](https://github.com/packbackbooks/lti-1-3-php-library/actions/workflows/run_tests.yml/badge.svg?branch=master) [![Maintainability](https://api.codeclimate.com/v1/badges/16055e83ea04ad95a2f9/maintainability)](https://codeclimate.com/github/packbackbooks/lti-1-3-php-library/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/16055e83ea04ad95a2f9/test_coverage)](https://codeclimate.com/github/packbackbooks/lti-1-3-php-library/test_coverage)
44

55
A library used for building IMS-certified LTI 1.3 tool providers in PHP.
66

@@ -34,7 +34,7 @@ This library uses three methods for storing and accessing data: cache, cookie, a
3434
- `Packback\Lti1p3\Interfaces\ICookie`
3535
- `Packback\Lti1p3\Interfaces\IDatabase` or optionally `Packback\Lti1p3\Interfaces\IMigrationDatabase`
3636

37-
View the [Laravel Implementation Guide](https://github.com/packbackbooks/lti-1-3-php-library/wiki/Laravel-Implementation-Guide) to see examples (or copy/paste the code outright). 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.
37+
View the [Laravel Implementation Guide](https://github.com/packbackbooks/lti-1-3-php-library/wiki/Laravel-Implementation-Guide) to see examples (or copy/paste the code outright).
3838

3939
### Create a JWKS endpoint
4040

SECURITY.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
## Supported Versions
44

5-
| Version | Supported |
6-
| ------- | ------------------ |
7-
| 5.0.x | :white_check_mark: |
8-
| < 5.0 | :x: |
5+
| Version | Supported |
6+
| ------- | --------------------------------- |
7+
| 6.0.x | :white_check_mark: Active support |
8+
| 5.7.x | :wrench: Security fixes only |
9+
| < 5.7 | :x: End of life |
910

1011
## Reporting a Vulnerability
1112

UPGRADES.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,103 @@
1+
## 5.x to 6.0
2+
3+
### HIGH LIKELIHOOD OF IMPACT: Changes to `LtiMessageLaunch`
4+
5+
When handling a new launch, the new `initialize()` method should be used instead of the previous `validate()` method. The validate method no longer accepts arguments, and requires that the request be set on the message launch object first (which happens in `initialize()`). This fixes some separation-of-concern issues with the `validate()` method, and allows for seamless integration of LTI 1.1 to 1.3 migrations if enabled.
6+
7+
```php
8+
// instead of doing this:
9+
$message->validate($request);
10+
11+
// you should do this:
12+
$message->inilialize($request);
13+
```
14+
15+
### HIGH LIKELIHOOD OF IMPACT: Changed how the OIDC Login URL is retrieved, deprecated the `Redirect` object
16+
17+
When redirecting to the OIDC Login URL, the `Packback\Lti1p3\LtiOidcLogin::getOidcLoginUrl()` method should be used to retrieve the URL. Your application should use this to build the redirect response in whatever way is appropriate for your framework. This replaces `Packback\Lti1p3\LtiOidcLogin::doOidcLoginRedirect()`, which returned a `Redirect` object. See: https://github.com/packbackbooks/lti-1-3-php-library/pull/116
18+
19+
```php
20+
// instead of doing this:
21+
$redirect = $oidLogin->doOidcLoginRedirect($launchUrl, $request);
22+
return redirect($redirect->getRedirectUrl());
23+
24+
// you should do this:
25+
return redirect($oidLogin->getRedirectUrl($launchUrl, $request));
26+
```
27+
28+
### HIGH LIKELIHOOD OF IMPACT - Strict typing added
29+
30+
All arguments and returns are now strictly typed. This includes interfaces that require custom implementations. Notable changes:
31+
32+
```php
33+
Packback\Lti1p3\Interfaces\ICookie
34+
setCookie(string $name, string $value, int $exp = 3600, array $options = []): void;
35+
36+
Packback\Lti1p3\Interfaces\IDatabase
37+
findRegistrationByIssuer(string $iss, ?string $clientId = null): ?ILtiRegistration;
38+
findDeployment(string $iss, string $deploymentId, ?string $clientId = null): ?ILtiDeployment;
39+
40+
Packback\Lti1p3\Interfaces\IMigrationDatabase
41+
migrateFromLti1p1(LtiMessageLaunch $launch): ?ILtiDeployment;
42+
```
43+
44+
### Dropped support for PHP 7 and PHP-JWT 5
45+
46+
This library now requires PHP 8 and firebase/php-jwt 6.
47+
48+
### `Packback\Lti1p3\DeepLinkResource*` objects moved to their own namespace
49+
50+
Objects named `DeepLinkResource*` have been moved to their own namespace: `Packback\Lti1p3\DeepLinkResources`. The following classes have been moved:
51+
52+
- `Packback\Lti1p3\DeepLinkResourceDateTimeInterval` is now `Packback\Lti1p3\DeepLinkResources\DateTimeInterval`
53+
- `Packback\Lti1p3\DeepLinkResourceIcon` is now `Packback\Lti1p3\DeepLinkResources\Icon`
54+
- `Packback\Lti1p3\DeepLinkResourceIframe` is now `Packback\Lti1p3\DeepLinkResources\Iframe`
55+
- `Packback\Lti1p3\DeepLinkResource` is now `Packback\Lti1p3\DeepLinkResources\Resource`
56+
- `Packback\Lti1p3\DeepLinkResourceWindow` is now `Packback\Lti1p3\DeepLinkResources\Window`
57+
58+
### `Packback\Lti1p3\DeepLinkResources\Iframe` constructor arguments changed order
59+
60+
To make the interface consistent with other deep link resources, `src` is now the first argument in the constructor:
61+
62+
```php
63+
class Iframe
64+
{
65+
public function __construct(
66+
private ?string $src = null,
67+
private ?int $width = null,
68+
private ?int $height = null
69+
) {
70+
}
71+
}
72+
```
73+
74+
### Removed `ImsStorage` classes
75+
76+
Everything in the `Packback\Lti1p3\ImsStorage` namespace has been removed, specifically the `Packback\Lti1p3\ImsStorage\ImsCache` and `Packback\Lti1p3\ImsStorage\ImsCookie`. If you were using these classes, you will need to implement your own custom storage services. See the [Laravel Implementation Guide](https://github.com/packbackbooks/lti-1-3-php-library/wiki/Laravel-Implementation-Guide#sample-data-store-implementations) for an example.
77+
78+
### Removed deprecated methods and classes
79+
80+
The following classes have been removed:
81+
82+
* `Packback\Lti1p3\ImsStorage\ImsCache`
83+
* `Packback\Lti1p3\ImsStorage\ImsCookie`
84+
* `Packback\Lti1p3\Redirect`
85+
86+
The following methods have been removed:
87+
88+
* `Packback\Lti1p3\JwksEndpoint::outputJwks()` - use `getPublicJwks()` to build your own output
89+
* `Packback\Lti1p3\LtiDeepLink::outputResponseForm()` - use `getResponseJwt()` to build your own output
90+
* `Packback\Lti1p3\LtiDeepLinkResources\Resource::getTarget()` - consider using `getIframe()` or `getWindow()` instead
91+
* `Packback\Lti1p3\LtiDeepLinkResources\Resource::setTarget()` - consider using `setIframe()` or `setWindow()` instead
92+
* `Packback\Lti1p3\Redirect::doHybridRedirect()`
93+
* `Packback\Lti1p3\Redirect::getRedirectUrl()`
94+
95+
### Changes to method signatures
96+
97+
* When instantiating `LtiMessageLaunch`, `LtiOidcLogin`, and `LtiServiceConnector` objects, all arguments are required now (instead of some being optional).
98+
* `Lti1p1Key` methods `setKey()` and `setSecret()` accept strings instead of arrays.
99+
* `LtiServiceConnector::setDebuggingMode()` now returns self instead of void.
100+
1101
## 5.6 to 5.7
2102

3103
No breaking changes were introduced. However, going forward when processing a `LtiOidcLogin`, it is recommended to use the new `getRedirectUrl()` method:

composer.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@
2121
}
2222
],
2323
"require": {
24-
"firebase/php-jwt": "^5.5|^6.0",
24+
"firebase/php-jwt": "^6.6",
2525
"guzzlehttp/guzzle": "^7.0",
2626
"phpseclib/phpseclib": "^3.0"
2727
},
2828
"require-dev": {
29-
"jubeki/laravel-code-style": "^1.0|^2.0",
3029
"mockery/mockery": "^1.4",
3130
"nesbot/carbon": "^2.43",
32-
"phpunit/phpunit": "^9.5"
31+
"laravel/pint": "^1.0",
32+
"phpstan/phpstan": "^1.10",
33+
"phpunit/phpunit": "^9.0|^10.0"
3334
},
3435
"autoload": {
3536
"psr-4": {
@@ -43,7 +44,10 @@
4344
},
4445
"scripts": {
4546
"test": "phpunit",
46-
"lint": "php-cs-fixer fix -v --dry-run",
47-
"lint-fix": "php-cs-fixer fix -v"
47+
"lint": [
48+
"pint --test",
49+
"phpstan analyse"
50+
],
51+
"lint-fix": "pint -v"
4852
}
4953
}

phpstan.neon

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
parameters:
2+
level: 5
3+
paths:
4+
- src
5+
- tests
6+
7+
ignoreErrors:
8+
-
9+
message: "#^Call to an undefined method Packback\\\\Lti1p3\\\\Interfaces\\\\IDatabase\\:\\:[a-zA-Z0-9]+\\(\\)\\.$#"
10+
count: 3
11+
path: src/LtiMessageLaunch.php
12+
13+
-
14+
message: "#Call to an undefined method Mockery\\\\#"
15+
paths:
16+
- tests/*
17+
18+
-
19+
message: "# Mockery\\\\(Legacy)*MockInterface given\\.$#"
20+
paths:
21+
- tests/*
22+
23+
-
24+
message: "# \\(Mockery\\\\MockInterface\\) does not accept Mockery\\\\LegacyMockInterface\\.$#"
25+
paths:
26+
- tests/*
27+
28+
-
29+
message: "#^Result of static method Packback\\\\Lti1p3\\\\MessageValidators\\\\[A-Za-z]+MessageValidator\\:\\:validate\\(\\) \\(void\\) is used\\.$#"
30+
path: tests/MessageValidators/*
31+

phpunit.xml.dist

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<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">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
33
<coverage>
4-
<include>
5-
<directory suffix=".php">src/</directory>
6-
</include>
74
<report>
85
<clover outputFile="build/logs/clover.xml"/>
96
<html outputDirectory="build/coverage"/>
@@ -18,4 +15,9 @@
1815
<logging>
1916
<junit outputFile="build/report.junit.xml"/>
2017
</logging>
18+
<source>
19+
<include>
20+
<directory suffix=".php">src/</directory>
21+
</include>
22+
</source>
2123
</phpunit>

0 commit comments

Comments
 (0)