Skip to content

Commit

Permalink
Some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
numelion committed Oct 21, 2022
1 parent 24516c4 commit 2e2e0f2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
14 changes: 8 additions & 6 deletions Jwt.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

namespace numelion\jwt;

use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Token\Builder;
use Lcobucci\JWT\Token\Parser;
use Lcobucci\JWT\Claim\Factory as ClaimFactory;
use Lcobucci\JWT\Parser;
use Lcobucci\JWT\Parsing\Decoder;
use Lcobucci\JWT\Parsing\Encoder;
use Lcobucci\JWT\Signer;
use Lcobucci\JWT\Signer\Key;
use Lcobucci\JWT\Signer\Key\InMemory as Key;
use Lcobucci\JWT\Token;
use Lcobucci\JWT\ValidationData;
use Yii;
use yii\base\Component;
use yii\base\InvalidArgumentException;
use Lcobucci\JWT\Encoding\JoseEncoder;
use Lcobucci\JWT\Encoding\UnixTimestampDates;

/**
* JSON Web Token implementation, based on this library:
Expand Down Expand Up @@ -59,7 +61,7 @@ class Jwt extends Component
*/
public function getBuilder(Encoder $encoder = null, ClaimFactory $claimFactory = null)
{
return new Builder($encoder, $claimFactory);
return new Builder($encoder ?? new JoseEncoder(), $claimFactory ?? new UnixTimestampDates());
}

/**
Expand Down Expand Up @@ -98,15 +100,15 @@ public function getSigner($alg)
* @param string|null $passphrase
* @return Key
*/
public function getKey($content = null, $passphrase = null)
public function getKey($content = '', $passphrase = '')
{
$content = $content ?: $this->key;

if ($content instanceof Key) {
return $content;
}

return new Key($content, $passphrase);
return Key::plainText($content, $passphrase);
}

/**
Expand Down
10 changes: 7 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"authors": [
{
"name": "numelion",
"email": "[email protected]",
"homepage": ""
"email": "[email protected]"
}
],
"license": "BSD-3-Clause",
Expand All @@ -34,5 +33,10 @@
"type": "composer",
"url": "https://asset-packagist.org"
}
]
],
"config": {
"allow-plugins": {
"yiisoft/yii2-composer": true
}
}
}

0 comments on commit 2e2e0f2

Please sign in to comment.