Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make possible to use encryption key object for better performance #21

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/Laravel/PassportServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function boot()
public function makeAuthorizationServer(): AuthorizationServer
{
$cryptKey = $this->makeCryptKey('private');
$encryptionKey = app(Encrypter::class)->getKey();
$encryptionKey = $this->getEncryptionKey(app(Encrypter::class)->getKey());

$customClaimSets = config('openid.custom_claim_sets');

Expand Down Expand Up @@ -74,7 +74,7 @@ public function makeAuthorizationServer(): AuthorizationServer
);
}

/**
/**
* Build the Auth Code grant instance.
*
* @return AuthCodeGrant
Expand All @@ -90,6 +90,22 @@ protected function buildAuthCodeGrant()
);
}

/**
* Get encryption key as string or a Key instance
*
* Based on https://github.com/laravel/passport/pull/820
*
* @param string $keyBytes Encryption key as string
*
* @return \Defuse\Crypto\Key|string
*/
protected function getEncryptionKey($keyBytes)
{
// For BC reasons we return string, but implementations can override this method to return an object.
// As mentioned in https://github.com/laravel/passport/pull/820 it gives better performance.
return $keyBytes;
}

public function registerClaimExtractor() {
$this->app->singleton(ClaimExtractor::class, function () {
$customClaimSets = config('openid.custom_claim_sets');
Expand Down
Loading