2018-01-02 22:52:56 +05:30
|
|
|
<?php
|
2019-12-04 23:40:15 +05:30
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-01-02 22:52:56 +05:30
|
|
|
namespace api\modules\authserver\validators;
|
|
|
|
|
|
|
|
use api\modules\authserver\exceptions\IllegalArgumentException;
|
2019-12-04 23:40:15 +05:30
|
|
|
use yii\validators\Validator;
|
2018-01-02 22:52:56 +05:30
|
|
|
|
|
|
|
/**
|
2019-07-15 04:29:56 +05:30
|
|
|
* The maximum length of clientToken for our database is 255.
|
|
|
|
* If the token is longer, we do not accept the passed token at all.
|
2018-01-02 22:52:56 +05:30
|
|
|
*/
|
2019-12-04 23:40:15 +05:30
|
|
|
class ClientTokenValidator extends Validator {
|
2018-01-02 22:52:56 +05:30
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $value
|
|
|
|
* @return null
|
|
|
|
* @throws \api\modules\authserver\exceptions\AuthserverException
|
|
|
|
*/
|
2019-12-04 23:40:15 +05:30
|
|
|
protected function validateValue($value): ?array {
|
2023-05-26 22:18:15 +05:30
|
|
|
if (mb_strlen((string)$value) > 255) {
|
2018-01-02 22:52:56 +05:30
|
|
|
throw new IllegalArgumentException('clientToken is too long.');
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|