|
17 | 17 | use CodeIgniter\Shield\Authentication\Authenticators\AccessTokens; |
18 | 18 | use CodeIgniter\Shield\Authentication\Authenticators\HmacSha256; |
19 | 19 | use CodeIgniter\Shield\Authentication\Authenticators\Session; |
| 20 | +use CodeIgniter\Shield\Authentication\HMAC\HmacEncrypter; |
20 | 21 | use CodeIgniter\Shield\Authentication\Passwords; |
21 | | -use CodeIgniter\Shield\Config\AuthToken; |
22 | 22 | use CodeIgniter\Shield\Entities\AccessToken; |
23 | 23 | use CodeIgniter\Shield\Entities\User; |
24 | 24 | use CodeIgniter\Shield\Entities\UserIdentity; |
25 | 25 | use CodeIgniter\Shield\Exceptions\LogicException; |
26 | 26 | use CodeIgniter\Shield\Exceptions\ValidationException; |
27 | | -use Config\Encryption; |
28 | | -use Config\Services; |
29 | 27 | use Exception; |
30 | 28 | use Faker\Generator; |
31 | 29 | use ReflectionException; |
@@ -254,18 +252,9 @@ public function generateHmacToken(User $user, string $name, array $scopes = ['*' |
254 | 252 | { |
255 | 253 | $this->checkUserId($user); |
256 | 254 |
|
257 | | - /** @var AuthToken $authConfig */ |
258 | | - $authConfig = config('AuthToken'); |
259 | | - $config = new Encryption(); |
260 | | - |
261 | | - $config->key = $authConfig->hmacEncryptionKey; |
262 | | - $config->driver = $authConfig->hmacEncryptionDriver; |
263 | | - $config->digest = $authConfig->hmacEncryptionDigest; |
264 | | - |
265 | | - // Generate and encrypt secret key |
266 | | - $encrypter = Services::encrypter($config); |
267 | | - $rawSecretKey = bin2hex(random_bytes(config('AuthToken')->hmacSecretKeyByteSize)); |
268 | | - $secretKey = bin2hex($encrypter->encrypt($rawSecretKey)); |
| 255 | + $encrypter = new HmacEncrypter(); |
| 256 | + $rawSecretKey = $encrypter->generateSecretKey(); |
| 257 | + $secretKey = $encrypter->encrypt($rawSecretKey); |
269 | 258 |
|
270 | 259 | $return = $this->insert([ |
271 | 260 | 'type' => HmacSha256::ID_TYPE_HMAC_TOKEN, |
|
0 commit comments