Объединены сущности для авторизации посредством JWT токенов и токенов, выданных через oAuth2.

Все действия, связанные с аккаунтами, теперь вызываются через url `/api/v1/accounts/<id>/<action>`.
Добавлена вменяемая система разграничения прав на основе RBAC.
Теперь oAuth2 токены генерируются как случайная строка в 40 символов длинной, а не UUID.
Исправлен баг с неправильным временем жизни токена в ответе успешного запроса аутентификации.
Теперь все unit тесты можно успешно прогнать без наличия интернета.
This commit is contained in:
ErickSkrauch
2017-09-19 20:06:16 +03:00
parent 928b3aa7fc
commit dd2c4bc413
173 changed files with 2719 additions and 2748 deletions

View File

@ -1,7 +1,7 @@
<?php
namespace codeception\api\unit\models\authentication;
use api\components\User\RenewResult;
use api\components\User\AuthenticationResult;
use api\models\authentication\RefreshTokenForm;
use Codeception\Specify;
use common\models\AccountSession;
@ -26,7 +26,7 @@ class RefreshTokenFormTest extends TestCase {
}
};
$model->validateRefreshToken();
expect($model->getErrors('refresh_token'))->equals(['error.refresh_token_not_exist']);
$this->assertEquals(['error.refresh_token_not_exist'], $model->getErrors('refresh_token'));
});
$this->specify('no errors if token exists', function() {
@ -37,14 +37,14 @@ class RefreshTokenFormTest extends TestCase {
}
};
$model->validateRefreshToken();
expect($model->getErrors('refresh_token'))->isEmpty();
$this->assertEmpty($model->getErrors('refresh_token'));
});
}
public function testRenew() {
$model = new RefreshTokenForm();
$model->refresh_token = $this->tester->grabFixture('sessions', 'admin')['refresh_token'];
$this->assertInstanceOf(RenewResult::class, $model->renew());
$this->assertInstanceOf(AuthenticationResult::class, $model->renew());
}
}