Skip to content

Commit

Permalink
Add new methods to GrantTypeInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
Sephster committed Mar 21, 2024
1 parent 4345dae commit 2cf9fbb
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/Grant/AbstractGrant.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

}
1 change: 0 additions & 1 deletion src/Grant/DeviceCodeGrant.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ protected function generateUserCode(int $length = 8): string
// @codeCoverageIgnoreEnd
}

// TODO: Check interface
public function setIntervalVisibility(bool $intervalVisibility): void
{
$this->intervalVisibility = $intervalVisibility;
Expand Down
19 changes: 19 additions & 0 deletions src/Grant/GrantTypeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
13 changes: 13 additions & 0 deletions tests/Stubs/GrantType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
}
}

0 comments on commit 2cf9fbb

Please sign in to comment.