Fixes ACCOUNTS-2. Catch decryption exception for OAuth2 flow

This commit is contained in:
ErickSkrauch
2020-08-23 00:23:36 +03:00
parent 503880615a
commit 2a4f29801d
3 changed files with 21 additions and 6 deletions

View File

@@ -107,6 +107,13 @@ class Component extends BaseComponent {
return $cipher;
}
/**
* @param string $encryptedValue
*
* @return string
* @throws \SodiumException
* @throws \RangeException
*/
public function decryptValue(string $encryptedValue): string {
$decoded = Base64UrlSafe::decode($encryptedValue);
Assert::true(mb_strlen($decoded, '8bit') >= (SODIUM_CRYPTO_SECRETBOX_NONCEBYTES + SODIUM_CRYPTO_SECRETBOX_MACBYTES));