forked from sizeg/yii2-jwt
-
-
Notifications
You must be signed in to change notification settings - Fork 10
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 #1 from bizley/2.0.1
2.0.1
- Loading branch information
Showing
17 changed files
with
223 additions
and
86 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/.github export-ignore | ||
/tests export-ignore | ||
/phpunit.xml.dist export-ignore |
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,10 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
- package-ecosystem: "composer" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
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,47 @@ | ||
name: Tests | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- "2.x" | ||
|
||
jobs: | ||
Infection: | ||
name: PHP ${{ matrix.php }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php: ['7.1', '7.2', '7.3', '7.4'] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: mbstring, intl, mysql | ||
coverage: "none" | ||
env: | ||
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
update: true | ||
|
||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
|
||
- name: Cache composer dependencies | ||
uses: actions/[email protected] | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
|
||
- name: Install dependencies | ||
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader | ||
|
||
- name: Run PHPUnit | ||
run: vendor/bin/phpunit |
This file was deleted.
Oops, something went wrong.
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,76 @@ | ||
# Contributor Covenant Code of Conduct | ||
|
||
## Our Pledge | ||
|
||
In the interest of fostering an open and welcoming environment, we as | ||
contributors and maintainers pledge to making participation in our project and | ||
our community a harassment-free experience for everyone, regardless of age, body | ||
size, disability, ethnicity, sex characteristics, gender identity and expression, | ||
level of experience, education, socio-economic status, nationality, personal | ||
appearance, race, religion, or sexual identity and orientation. | ||
|
||
## Our Standards | ||
|
||
Examples of behavior that contributes to creating a positive environment | ||
include: | ||
|
||
* Using welcoming and inclusive language | ||
* Being respectful of differing viewpoints and experiences | ||
* Gracefully accepting constructive criticism | ||
* Focusing on what is best for the community | ||
* Showing empathy towards other community members | ||
|
||
Examples of unacceptable behavior by participants include: | ||
|
||
* The use of sexualized language or imagery and unwelcome sexual attention or | ||
advances | ||
* Trolling, insulting/derogatory comments, and personal or political attacks | ||
* Public or private harassment | ||
* Publishing others' private information, such as a physical or electronic | ||
address, without explicit permission | ||
* Other conduct which could reasonably be considered inappropriate in a | ||
professional setting | ||
|
||
## Our Responsibilities | ||
|
||
Project maintainers are responsible for clarifying the standards of acceptable | ||
behavior and are expected to take appropriate and fair corrective action in | ||
response to any instances of unacceptable behavior. | ||
|
||
Project maintainers have the right and responsibility to remove, edit, or | ||
reject comments, commits, code, wiki edits, issues, and other contributions | ||
that are not aligned to this Code of Conduct, or to ban temporarily or | ||
permanently any contributor for other behaviors that they deem inappropriate, | ||
threatening, offensive, or harmful. | ||
|
||
## Scope | ||
|
||
This Code of Conduct applies both within project spaces and in public spaces | ||
when an individual is representing the project or its community. Examples of | ||
representing a project or community include using an official project e-mail | ||
address, posting via an official social media account, or acting as an appointed | ||
representative at an online or offline event. Representation of a project may be | ||
further defined and clarified by project maintainers. | ||
|
||
## Enforcement | ||
|
||
Instances of abusive, harassing, or otherwise unacceptable behavior may be | ||
reported by contacting the project team at [email protected]. All | ||
complaints will be reviewed and investigated and will result in a response that | ||
is deemed necessary and appropriate to the circumstances. The project team is | ||
obligated to maintain confidentiality with regard to the reporter of an incident. | ||
Further details of specific enforcement policies may be posted separately. | ||
|
||
Project maintainers who do not follow or enforce the Code of Conduct in good | ||
faith may face temporary or permanent repercussions as determined by other | ||
members of the project's leadership. | ||
|
||
## Attribution | ||
|
||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, | ||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html | ||
|
||
[homepage]: https://www.contributor-covenant.org | ||
|
||
For answers to common questions about this code of conduct, see | ||
https://www.contributor-covenant.org/faq |
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 |
---|---|---|
|
@@ -5,13 +5,13 @@ | |
"keywords": ["yii2", "jwt", "jws", "token", "authentication"], | ||
"license": "Apache-2.0", | ||
"authors": [ | ||
{ | ||
"name": "Dmitriy Demin", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"name": "Pawel Bizley Brzozowski", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"name": "Dmitriy Demin", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"support": { | ||
|
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<?php declare(strict_types=1); | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace bizley\jwt; | ||
|
||
|
@@ -10,6 +12,7 @@ | |
use Lcobucci\JWT\Token; | ||
use Lcobucci\JWT\ValidationData; | ||
use Yii; | ||
use yii\base\Component; | ||
|
||
/** | ||
* JSON Web Token implementation based on lcobucci/jwt library. | ||
|
@@ -18,7 +21,7 @@ | |
* @author Dmitriy Demin <[email protected]> original package | ||
* @author Paweł Bizley Brzozowski <[email protected]> since 2.0 (fork) | ||
*/ | ||
class Jwt extends \yii\base\Component | ||
class Jwt extends Component | ||
{ | ||
/** | ||
* @var array Token signers | ||
|
@@ -61,7 +64,7 @@ public function getBuilder(?Encoder $encoder = null, ?Factory $claimFactory = nu | |
*/ | ||
public function getParser(?Decoder $decoder = null, ?Factory $claimFactory = null): Parser | ||
{ | ||
return new Parser($decoder, $claimFactory); | ||
return new Parser($decoder, $claimFactory); // $claimFactory not used anymore in lcobucci/jwt 3.4 | ||
} | ||
|
||
/** | ||
|
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,12 +1,18 @@ | ||
<?php declare(strict_types=1); | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace bizley\jwt; | ||
|
||
use Lcobucci\JWT\Token; | ||
use yii\base\InvalidConfigException; | ||
use yii\di\Instance; | ||
use yii\filters\auth\HttpBearerAuth; | ||
use yii\web\IdentityInterface; | ||
use yii\web\Request; | ||
use yii\web\Response; | ||
use yii\web\UnauthorizedHttpException; | ||
use yii\web\User; | ||
|
||
/** | ||
* JwtHttpBearerAuth is an action filter that supports the authentication method based on HTTP Bearer JSON Web Token. | ||
|
@@ -27,7 +33,7 @@ | |
* @author Dmitriy Demin <[email protected]> original package | ||
* @author Paweł Bizley Brzozowski <[email protected]> since 2.0 (fork) | ||
*/ | ||
class JwtHttpBearerAuth extends \yii\filters\auth\HttpBearerAuth | ||
class JwtHttpBearerAuth extends HttpBearerAuth | ||
{ | ||
/** | ||
* @var string|array|Jwt application component ID of the JWT handler, configuration array, or JWT handler object itself. | ||
|
@@ -55,7 +61,7 @@ public function init(): void | |
{ | ||
parent::init(); | ||
|
||
$this->jwt = \yii\di\Instance::ensure($this->jwt, Jwt::class); | ||
$this->jwt = Instance::ensure($this->jwt, Jwt::class); | ||
|
||
if (empty($this->pattern)) { | ||
throw new InvalidConfigException('You must provide pattern to use to extract the HTTP authentication value!'); | ||
|
@@ -64,8 +70,8 @@ public function init(): void | |
|
||
/** | ||
* Authenticates the current user. | ||
* @param \yii\web\User $user | ||
* @param \yii\web\Request $request | ||
* @param User $user | ||
* @param Request $request | ||
* @param Response $response | ||
* @return IdentityInterface the authenticated user identity. If authentication information is not provided, null will be returned. | ||
* @throws UnauthorizedHttpException if authentication information is provided but is invalid. | ||
|
Oops, something went wrong.