mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Implemented Rs256 jwt encryption algorithm
This commit is contained in:
@@ -189,6 +189,8 @@ class ComponentTest extends TestCase {
|
||||
'enableSession' => false,
|
||||
'loginUrl' => null,
|
||||
'secret' => 'secret',
|
||||
'publicKey' => 'data/certs/public.crt',
|
||||
'privateKey' => 'data/certs/private.key',
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -8,6 +8,7 @@ use common\tests\_support\ProtectedCaller;
|
||||
use common\tests\fixtures\AccountFixture;
|
||||
use Emarref\Jwt\Claim;
|
||||
use Emarref\Jwt\Encryption\Factory as EncryptionFactory;
|
||||
use Emarref\Jwt\HeaderParameter\Custom;
|
||||
use Emarref\Jwt\Token;
|
||||
use Yii;
|
||||
|
||||
@@ -33,10 +34,11 @@ class JwtIdentityTest extends TestCase {
|
||||
*/
|
||||
public function testFindIdentityByAccessTokenWithExpiredToken() {
|
||||
$token = new Token();
|
||||
$token->addHeader(new Custom('v', 1));
|
||||
$token->addClaim(new Claim\IssuedAt(1464593193));
|
||||
$token->addClaim(new Claim\Expiration(1464596793));
|
||||
$token->addClaim(new Claim\Subject('ely|' . $this->tester->grabFixture('accounts', 'admin')['id']));
|
||||
$expiredToken = (new Jwt())->serialize($token, EncryptionFactory::create(Yii::$app->user->getAlgorithm()));
|
||||
$expiredToken = (new Jwt())->serialize($token, EncryptionFactory::create(Yii::$app->user->getAlgorithm())->setPrivateKey(Yii::$app->user->privateKey));
|
||||
|
||||
JwtIdentity::findIdentityByAccessToken($expiredToken);
|
||||
}
|
||||
|
@@ -63,6 +63,8 @@ class LogoutFormTest extends TestCase {
|
||||
'enableSession' => false,
|
||||
'loginUrl' => null,
|
||||
'secret' => 'secret',
|
||||
'publicKey' => 'data/certs/public.crt',
|
||||
'privateKey' => 'data/certs/private.key',
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -61,6 +61,8 @@ class ChangePasswordFormTest extends TestCase {
|
||||
'enableSession' => false,
|
||||
'loginUrl' => null,
|
||||
'secret' => 'secret',
|
||||
'publicKey' => 'data/certs/public.crt',
|
||||
'privateKey' => 'data/certs/private.key',
|
||||
]]);
|
||||
$component->shouldNotReceive('terminateSessions');
|
||||
|
||||
@@ -121,6 +123,8 @@ class ChangePasswordFormTest extends TestCase {
|
||||
'enableSession' => false,
|
||||
'loginUrl' => null,
|
||||
'secret' => 'secret',
|
||||
'publicKey' => 'data/certs/public.crt',
|
||||
'privateKey' => 'data/certs/private.key',
|
||||
]]);
|
||||
$component->shouldReceive('terminateSessions')->once()->withArgs([$account, Component::KEEP_CURRENT_SESSION]);
|
||||
|
||||
|
@@ -24,6 +24,8 @@ class EnableTwoFactorAuthFormTest extends TestCase {
|
||||
'enableSession' => false,
|
||||
'loginUrl' => null,
|
||||
'secret' => 'secret',
|
||||
'publicKey' => 'data/certs/public.crt',
|
||||
'privateKey' => 'data/certs/private.key',
|
||||
]]);
|
||||
$component->shouldReceive('terminateSessions')->withArgs([$account, Component::KEEP_CURRENT_SESSION]);
|
||||
|
||||
|
Reference in New Issue
Block a user