Skip to content

Commit

Permalink
Merge pull request #21 from alecpl/dev/get-encryption-key
Browse files Browse the repository at this point in the history
Make possible to use encryption key object for better performance
  • Loading branch information
jeremy379 authored Aug 1, 2024
2 parents 3b3580d + 0707eb2 commit 01e9b1e
Showing 1 changed file with 18 additions and 2 deletions.
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

0 comments on commit 01e9b1e

Please sign in to comment.