From 2cf9fbbddf5e2a690d28d00c4a877e01d962f9e3 Mon Sep 17 00:00:00 2001 From: Andrew Millington Date: Thu, 21 Mar 2024 15:00:01 +0000 Subject: [PATCH] Add new methods to GrantTypeInterface --- src/Grant/AbstractGrant.php | 25 +++++++++++++++++++++++++ src/Grant/DeviceCodeGrant.php | 1 - src/Grant/GrantTypeInterface.php | 19 +++++++++++++++++++ tests/Stubs/GrantType.php | 13 +++++++++++++ 4 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/Grant/AbstractGrant.php b/src/Grant/AbstractGrant.php index c11be4d77..2949327ce 100644 --- a/src/Grant/AbstractGrant.php +++ b/src/Grant/AbstractGrant.php @@ -555,4 +555,29 @@ public function completeDeviceAuthorizationRequest(string $deviceCode, string $u { throw new LogicException('This grant cannot complete a device authorization request'); } + + /** + * {@inheritdoc} + */ + public function setIntervalVisibility(bool $intervalVisibility): void + { + throw new LogicException('This grant does not support the interval parameter'); + } + + /** + * {@inheritdoc} + */ + public function getIntervalVisibility(): bool + { + return false; + } + + /** + * {@inheritdoc} + */ + public function setIncludeVerificationUriComplete(bool $includeVerificationUriComplete): void + { + throw new LogicException('This grant does not support the verification_uri_complete parameter'); + } + } diff --git a/src/Grant/DeviceCodeGrant.php b/src/Grant/DeviceCodeGrant.php index bfd326f88..eb88fe9c7 100644 --- a/src/Grant/DeviceCodeGrant.php +++ b/src/Grant/DeviceCodeGrant.php @@ -316,7 +316,6 @@ protected function generateUserCode(int $length = 8): string // @codeCoverageIgnoreEnd } - // TODO: Check interface public function setIntervalVisibility(bool $intervalVisibility): void { $this->intervalVisibility = $intervalVisibility; diff --git a/src/Grant/GrantTypeInterface.php b/src/Grant/GrantTypeInterface.php index 461416773..039982cf1 100644 --- a/src/Grant/GrantTypeInterface.php +++ b/src/Grant/GrantTypeInterface.php @@ -133,4 +133,23 @@ public function setEncryptionKey(Key|string|null $key = null): void; * Enable or prevent the revocation of refresh tokens upon usage. */ public function revokeRefreshTokens(bool $willRevoke): void; + + /** + * If set, the minimum interval between device code polling will be + * returned by the server. + */ + public function setIntervalVisibility(bool $intervalVisibility): void; + + /** + * Checks if the minimum interval between device code polling should be + * returned by the server. + */ + public function getIntervalVisibility(): bool; + + /** + * If set, the server will return a full verification URI to the client. + * This is useful when your device authorization endpoint might not be able + * to enter the user code easily. + */ + public function setIncludeVerificationUriComplete(bool $includeVerificationUriComplete): void; } diff --git a/tests/Stubs/GrantType.php b/tests/Stubs/GrantType.php index 6c6ecdcca..16eab4795 100644 --- a/tests/Stubs/GrantType.php +++ b/tests/Stubs/GrantType.php @@ -116,4 +116,17 @@ public function respondToDeviceAuthorizationRequest(ServerRequestInterface $requ { return new DeviceCodeResponse(); } + + public function setIntervalVisibility(bool $intervalVisibility): void + { + } + + public function getIntervalVisibility(): bool + { + return false; + } + + public function setIncludeVerificationUriComplete(bool $includeVerificationUriComplete): void + { + } }