-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from RobDWaller/0.1.0-beta
0.1.0 beta
- Loading branch information
Showing
24 changed files
with
489 additions
and
66 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
composer.lock | ||
vendor | ||
coverage | ||
infection.log |
This file contains 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 |
---|---|---|
@@ -1,19 +1,19 @@ | ||
language: php | ||
|
||
php: | ||
- 7.1 | ||
- 7.2 | ||
- 7.3 | ||
|
||
- 7.1 | ||
- 7.2 | ||
- 7.3 | ||
before_script: | ||
- travis_retry composer self-update | ||
- travis_retry composer install --no-interaction --prefer-source --dev | ||
|
||
- travis_retry composer self-update | ||
- travis_retry composer install --no-interaction --prefer-source --dev | ||
script: | ||
- vendor/bin/phpcs --standard=psr12 src tests | ||
- vendor/bin/phpstan analyse -l 7 src tests | ||
- vendor/bin/phpmd src text ruleset.xml | ||
- vendor/bin/phpunit --coverage-clover=coverage.xml | ||
|
||
- vendor/bin/phpcs --standard=psr12 src tests | ||
- vendor/bin/phpstan analyse -l 7 src tests | ||
- vendor/bin/phpmd src text ruleset.xml | ||
- vendor/bin/phpunit --coverage-clover=coverage.xml | ||
- vendor/bin/infection -s --min-msi=90 | ||
after_success: | ||
- bash <(curl -s https://codecov.io/bash) | ||
- bash <(curl -s https://codecov.io/bash) | ||
env: | ||
global: | ||
secure: oaOExVMXXbPswvGD2IfSM1t9iVybKhui5C4LyoVwvSoyWmkZU2YmS5Yf7Z2oCjbjzTq6b20iswVjlfakrgd2IzlvpvELu7N/jgPylfKLmG4/mvOxK53FujILsOYd8Np90zlvJb4fRcxYp/iHAmJpJEVz6J7keoRFLR8JVyF7TmbNah40Bog2pG6KaNgQ1xabGTRNDf8Vo6SJtMNrgDxv2LBLBY566QTXH8fuTmijkqsVM/r/N49Pa+2EnE26O4t25HJsBDmEbRWWHAxw7SMxrneLG98dg/GqjroqOJ5h2S2ud3I6l2kI8wtKp0bcosMiijcTZ+z7J9STrrzPIVRLVHYrLQ38+N4FaaS94k87Hk0Ywin4gPqLWU9cTtb/R4/3bE25rGTnxn/Gdm6RtniexcMDcqyjqfv65Iq5RX/mTyIDpFRNUn7M22KitTp/7jULZIVtOgHOxd27TseKgOUcPt8OavPsaakb5voL+aCWZMov1kE6H3p5ZsoDyaMusb4sJHFt63aGegtTrm4cjHKU0qO9L7y/ivI9tK/lVenUbzy+Drt5Jdp40jD5AQ8kxvB96QkxZa6DeFkidl0chwC/GgMSWx9lEMHhO5G0RJAWqWgp+wDBl+u0Wki6NlmPdlk72EbjzSWarK5ddhwElO2QTWGumw+AzfmYUNZiwQr/fJo= |
This file contains 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 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 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,17 @@ | ||
{ | ||
"timeout": 10, | ||
"source": { | ||
"directories": [ | ||
"src" | ||
] | ||
}, | ||
"logs": { | ||
"text": "infection.log", | ||
"badge": { | ||
"branch": "master" | ||
} | ||
}, | ||
"mutators": { | ||
"@default": true | ||
} | ||
} |
This file contains 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 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 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 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 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 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,15 +12,37 @@ | |
use PsrJwt\Auth\Authenticate; | ||
use PsrJwt\Auth\Auth; | ||
|
||
/** | ||
* Psr-Jwt provides a simple means by which to add JSON Web Token | ||
* authentication middleware to PSR-7 and PSR-15 compliant frameworks such as | ||
* Slim PHP and Zend Expressive. It also allows for the generation of JSON | ||
* Web Tokens via its integration with ReallySimpleJWT. | ||
* | ||
* @author Rob Waller <[email protected]> | ||
*/ | ||
class JwtAuthMiddleware implements MiddlewareInterface | ||
{ | ||
/** | ||
* @var Authenticate $authenticate | ||
*/ | ||
private $authenticate; | ||
|
||
/** | ||
* @param Authenticate $authenticate | ||
*/ | ||
public function __construct(Authenticate $authenticate) | ||
{ | ||
$this->authenticate = $authenticate; | ||
} | ||
|
||
/** | ||
* PSR-7 compliant middleware compatible with frameworks like Slim PHP v3. | ||
* | ||
* @param ServerRequestInterface $request | ||
* @param ResponseInterface $response | ||
* @param callable $next | ||
* @return ResponseInterface | ||
*/ | ||
public function __invoke( | ||
ServerRequestInterface $request, | ||
ResponseInterface $response, | ||
|
@@ -35,6 +57,14 @@ public function __invoke( | |
return $this->failResponse($auth); | ||
} | ||
|
||
/** | ||
* PSR-15 compliant middleware compatible with frameworks like | ||
* Zend Expressive. | ||
* | ||
* @param ServerRequestInterface $request | ||
* @param RequestHandlerInterface $handler | ||
* @return ResponseInterface | ||
*/ | ||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface | ||
{ | ||
$auth = $this->authenticate->authenticate($request); | ||
|
@@ -46,6 +76,12 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface | |
return $this->failResponse($auth); | ||
} | ||
|
||
/** | ||
* Return a failure response if JSON Web Token authentication fails. | ||
* | ||
* @param Auth $auth | ||
* @return ResponseInterface | ||
*/ | ||
private function failResponse(Auth $auth): ResponseInterface | ||
{ | ||
$factory = new Psr17Factory(); | ||
|
This file contains 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 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
Oops, something went wrong.