Closed alecpl closed 1 month ago
Seems legit, thanks.
FYI, this is what I'm using in my provider.
/**
* Create a Key instance for encrypting the refresh token
*
* Based on https://github.com/laravel/passport/pull/820
*
* @param string $keyBytes
* @return \Defuse\Crypto\Key|string
*/
protected function getEncryptionKey($keyBytes)
{
// First, we will encode Laravel's encryption key into a format that the Defuse\Crypto\Key class can use,
// so we can instantiate a new Key object. We need to do this as the Key class has a private constructor method
// which means we cannot directly instantiate the class based on our Laravel encryption key.
$encryptionKeyAscii = EncryptionEncoding::saveBytesToChecksummedAsciiSafeString(
EncryptionKey::KEY_CURRENT_VERSION,
$keyBytes
);
// Instantiate a Key object so we can take advantage of significantly faster encryption/decryption
// from https://github.com/thephpleague/oauth2-server/pull/814. The improvement is 200x-300x faster.
return EncryptionKey::loadFromAsciiSafeString($encryptionKeyAscii);
}
If you'd be interested we could include that in your package, but make it optional. This way there would be less code needed on the application side.
As mentioned in https://github.com/laravel/passport/pull/820 it gives better performance.
Implementations can override the internal method to return an object without a need to override the whole
makeAuthorizationServer()
method.