Skip to content

Commit

Permalink
chore(deps): Add Laravel 10 support (#2210)
Browse files Browse the repository at this point in the history
* chore(deps): Add Laravel 10 support

* Apply fixes from StyleCI (#2211)

[ci skip] [skip ci]

* cleanup readme

* add compat table and alias
  • Loading branch information
tymondesigns authored Feb 16, 2023
1 parent 014be8d commit b0868a5
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 375 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [7.4, 8.0, 8.1]
laravel: [6.*, 7.*, 8.*, 9.*]
php: [8.0, 8.1, 8.2]
laravel: [9.*, 10.*]
os: [ubuntu-latest]
coverage: [none]
include:
- php: 8.1
laravel: 9.*
- php: 8.2
laravel: 10.*
os: ubuntu-latest
coverage: xdebug
exclude:
- php: 7.4
laravel: 9.*
- php: 8.0
laravel: 10.*

name: '[P${{ matrix.php }}] [L${{ matrix.laravel }}] [${{ matrix.coverage }}]'

Expand All @@ -43,10 +43,10 @@ jobs:

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: "php-${{ matrix.php }}-laravel-${{ matrix.laravel }}-${{ hashFiles('**/composer.json') }}"
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@

## Documentation

Documentation for `1.*` [here](http://jwt-auth.com)
[jwt-auth.com](https://jwt-auth.com)

| jwt-auth version | Laravel version(s) |
|---|---|
| 1.x | 6 / 7 / 8 |
| 2.x | 9 / 10 |

For version `0.5.*` See the [WIKI](https://github.com/tymondesigns/jwt-auth/wiki) for documentation.

[<img src="https://user-images.githubusercontent.com/1801923/57975478-a7a88900-79c1-11e9-924b-d7fa742f743b.png" height="40">](https://www.patreon.com/bePatron?u=11815122)

Expand All @@ -28,5 +32,3 @@ If you discover any security related issues, please email tymon148@gmail.com ins
## License

The MIT License (MIT)

[![SensioLabs Insight](https://insight.sensiolabs.com/projects/ba600082-7869-4ea8-b877-0bf6a86d4988/big.svg)](https://insight.sensiolabs.com/projects/ba600082-7869-4ea8-b877-0bf6a86d4988)
27 changes: 13 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,20 @@
}
],
"require": {
"php": "^7.4|^8.0",
"illuminate/auth": "^5.2|^6|^7|^8|^9",
"illuminate/contracts": "^5.2|^6|^7|^8|^9",
"illuminate/http": "^5.2|^6|^7|^8|^9",
"illuminate/support": "^5.2|^6|^7|^8|^9",
"lcobucci/jwt": "^3.4|^4.0",
"namshi/jose": "^7.0",
"nesbot/carbon": "^1.0|^2.0"
"php": "^8.0",
"illuminate/auth": "^9.0|^10.0",
"illuminate/contracts": "^9.0|^10.0",
"illuminate/http": "^9.0|^10.0",
"illuminate/support": "^9.0|^10.0",
"lcobucci/jwt": "^4.0",
"nesbot/carbon": "^2.0"
},
"require-dev": {
"illuminate/console": "^5.2|^6|^7|^8|^9",
"illuminate/database": "^5.2|^6|^7|^8|^9",
"illuminate/routing": "^5.2|^6|^7|^8|^9",
"illuminate/console": "^9.0|^10.0",
"illuminate/database": "^9.0|^10.0",
"illuminate/routing": "^9.0|^10.0",
"mockery/mockery": ">=0.9.9",
"phpunit/phpunit": "^8.5|^9.4",
"yoast/phpunit-polyfills": "^0.2.0"
"phpunit/phpunit": "^9.4"
},
"autoload": {
"psr-4": {
Expand All @@ -52,7 +50,8 @@
},
"extra": {
"branch-alias": {
"dev-develop": "1.0-dev"
"dev-develop": "1.0-dev",
"dev-2.x": "2.0-dev"
},
"laravel": {
"aliases": {
Expand Down
103 changes: 0 additions & 103 deletions src/Providers/JWT/Namshi.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/AbstractTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use Carbon\Carbon;
use Mockery;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
use PHPUnit\Framework\TestCase;

abstract class AbstractTestCase extends TestCase
{
Expand Down
17 changes: 9 additions & 8 deletions tests/Providers/JWT/LcobucciTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Tymon\JWTAuth\Test\Providers\JWT;

use Illuminate\Support\Str;
use Tymon\JWTAuth\Exceptions\JWTException;
use Tymon\JWTAuth\Exceptions\TokenInvalidException;
use Tymon\JWTAuth\Providers\JWT\Lcobucci;
Expand All @@ -30,7 +31,7 @@ public function it_can_encode_claims_using_a_symmetric_key()
'custom_claim' => 'foobar',
];

$token = $this->getProvider('secret', Provider::ALGO_HS256)->encode($payload);
$token = $this->getProvider(Str::random(64), Provider::ALGO_HS256)->encode($payload);
[$header, $payload, $signature] = explode('.', $token);

$claims = json_decode(base64_decode($payload), true);
Expand All @@ -57,7 +58,7 @@ public function it_can_encode_and_decode_a_token_using_a_symmetric_key()
'custom_claim' => 'foobar',
];

$provider = $this->getProvider('secret', Provider::ALGO_HS256);
$provider = $this->getProvider(Str::random(64), Provider::ALGO_HS256);

$token = $provider->encode($payload);
$claims = $provider->decode($token);
Expand All @@ -81,7 +82,7 @@ public function it_can_encode_and_decode_a_token_using_an_asymmetric_RS256_key()
];

$provider = $this->getProvider(
'secret',
Str::random(64),
Provider::ALGO_RS256,
['private' => $this->getDummyPrivateKey(), 'public' => $this->getDummyPublicKey()]
);
Expand Down Expand Up @@ -115,7 +116,7 @@ public function it_should_throw_an_invalid_exception_when_the_payload_could_not_
'invalid_utf8' => "\xB1\x31", // cannot be encoded as JSON
];

$this->getProvider('secret', Provider::ALGO_HS256)->encode($payload);
$this->getProvider(Str::random(64), Provider::ALGO_HS256)->encode($payload);
}

/** @test */
Expand All @@ -125,8 +126,8 @@ public function it_should_throw_a_token_invalid_exception_when_the_token_could_n
$this->expectExceptionMessage('Token Signature could not be verified.');

// This has a different secret than the one used to encode the token
$this->getProvider('secret', Provider::ALGO_HS256)
->decode('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiZXhwIjoxNjQ5MjYxMDY1LCJpYXQiOjE2NDkyNTc0NjUsImlzcyI6Ii9mb28iLCJjdXN0b21fY2xhaW0iOiJmb29iYXIifQ.jZufNqDHAxtboUIPmDp4ZFOIQxK-B5G6vNdBEp-9uL8');
$this->getProvider(Str::random(64), Provider::ALGO_HS256)
->decode('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiZXhwIjoxNjQ5MjYxMDY1LCJpYXQiOjE2NDkyNTc0NjUsImlzcyI6Ii9mb28iLCJjdXN0b21fY2xhaW0iOiJmb29iYXIifQ.jamiInQiin-1RUviliPjZxl0MLEnQnVTbr2sGooeXBY');
}

/** @test */
Expand All @@ -136,8 +137,8 @@ public function it_should_throw_a_token_invalid_exception_when_the_token_could_n
$this->expectExceptionMessage('Token Signature could not be verified.');

// This sub claim for this token has been tampered with so the signature will not match
$this->getProvider('secret', Provider::ALGO_HS256)
->decode('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIyIiwiZXhwIjoxNjQ5MjY0OTA2LCJpYXQiOjE2NDkyNjEzMDYsImlzcyI6Ii9mb28iLCJjdXN0b21fY2xhaW0iOiJmb29iYXIifQ.IcJvMvwMXf8oEpnz8-hvAy60QDE_o8XFaxhbZIGVy0U');
$this->getProvider(Str::random(64), Provider::ALGO_HS256)
->decode('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiZXhwIjoxNjQ5MjYxMDY1LCJpYXQiOjE2NDkyNTc0NjUsImlzcyI6Ii9mb29iYXIiLCJjdXN0b21fY2xhaW0iOiJmb29iYXIifQ.jamiInQiin-1RUviliPjZxl0MLEnQnVTbr2sGooeXBY');
}

/** @test */
Expand Down
Loading

0 comments on commit b0868a5

Please sign in to comment.