Skip to content

Commit

Permalink
include interval on authorization_pending and slow_down error responses
Browse files Browse the repository at this point in the history
  • Loading branch information
hafezdivandari committed Oct 28, 2024
1 parent bc6b12f commit 7c2c8d0
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/Exception/OAuthServerException.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ public static function expiredToken(?string $hint = null, ?Throwable $previous =
return new static($errorMessage, 11, 'expired_token', 400, $hint, null, $previous);
}

public static function authorizationPending(string $hint = '', ?Throwable $previous = null): static
public static function authorizationPending(?int $interval = null, string $hint = '', ?Throwable $previous = null): static
{
return new static(
$exception = new static(
'The authorization request is still pending as the end user ' .
'hasn\'t yet completed the user interaction steps. The client ' .
'SHOULD repeat the Access Token Request to the token endpoint',
Expand All @@ -228,6 +228,15 @@ public static function authorizationPending(string $hint = '', ?Throwable $previ
null,
$previous
);

if (!is_null($interval)) {
$exception->setPayload([

Check failure on line 233 in src/Exception/OAuthServerException.php

View workflow job for this annotation

GitHub Actions / Static Analysis (8.1, prefer-lowest, ubuntu-latest)

Parameter #1 $payload of method League\OAuth2\Server\Exception\OAuthServerException::setPayload() expects array<string, string>, array<string, int|string> given.

Check failure on line 233 in src/Exception/OAuthServerException.php

View workflow job for this annotation

GitHub Actions / Static Analysis (8.2, prefer-lowest, ubuntu-latest)

Parameter #1 $payload of method League\OAuth2\Server\Exception\OAuthServerException::setPayload() expects array<string, string>, array<string, int|string> given.

Check failure on line 233 in src/Exception/OAuthServerException.php

View workflow job for this annotation

GitHub Actions / Static Analysis (8.2, prefer-stable, ubuntu-latest)

Parameter #1 $payload of method League\OAuth2\Server\Exception\OAuthServerException::setPayload() expects array<string, string>, array<string, int|string> given.

Check failure on line 233 in src/Exception/OAuthServerException.php

View workflow job for this annotation

GitHub Actions / Static Analysis (8.3, prefer-lowest, ubuntu-latest)

Parameter #1 $payload of method League\OAuth2\Server\Exception\OAuthServerException::setPayload() expects array<string, string>, array<string, int|string> given.

Check failure on line 233 in src/Exception/OAuthServerException.php

View workflow job for this annotation

GitHub Actions / Static Analysis (8.3, prefer-stable, ubuntu-latest)

Parameter #1 $payload of method League\OAuth2\Server\Exception\OAuthServerException::setPayload() expects array<string, string>, array<string, int|string> given.

Check failure on line 233 in src/Exception/OAuthServerException.php

View workflow job for this annotation

GitHub Actions / Static Analysis (8.4, prefer-lowest, ubuntu-latest)

Parameter #1 $payload of method League\OAuth2\Server\Exception\OAuthServerException::setPayload() expects array<string, string>, array<string, int|string> given.

Check failure on line 233 in src/Exception/OAuthServerException.php

View workflow job for this annotation

GitHub Actions / Static Analysis (8.4, prefer-stable, ubuntu-latest)

Parameter #1 $payload of method League\OAuth2\Server\Exception\OAuthServerException::setPayload() expects array<string, string>, array<string, int|string> given.
...$exception->getPayload(),
'interval' => $interval,
]);
}

return $exception;
}

/**
Expand All @@ -236,9 +245,9 @@ public static function authorizationPending(string $hint = '', ?Throwable $previ
*
* @return static
*/
public static function slowDown(string $hint = '', ?Throwable $previous = null): static
public static function slowDown(?int $interval = null, string $hint = '', ?Throwable $previous = null): static
{
return new static(
$exception = new static(
'The authorization request is still pending and polling should ' .
'continue, but the interval MUST be increased ' .
'by 5 seconds for this and all subsequent requests.',
Expand All @@ -249,6 +258,15 @@ public static function slowDown(string $hint = '', ?Throwable $previous = null):
null,
$previous
);

if (!is_null($interval)) {
$exception->setPayload([

Check failure on line 263 in src/Exception/OAuthServerException.php

View workflow job for this annotation

GitHub Actions / Static Analysis (8.1, prefer-lowest, ubuntu-latest)

Parameter #1 $payload of method League\OAuth2\Server\Exception\OAuthServerException::setPayload() expects array<string, string>, array<string, int|string> given.

Check failure on line 263 in src/Exception/OAuthServerException.php

View workflow job for this annotation

GitHub Actions / Static Analysis (8.2, prefer-lowest, ubuntu-latest)

Parameter #1 $payload of method League\OAuth2\Server\Exception\OAuthServerException::setPayload() expects array<string, string>, array<string, int|string> given.

Check failure on line 263 in src/Exception/OAuthServerException.php

View workflow job for this annotation

GitHub Actions / Static Analysis (8.2, prefer-stable, ubuntu-latest)

Parameter #1 $payload of method League\OAuth2\Server\Exception\OAuthServerException::setPayload() expects array<string, string>, array<string, int|string> given.

Check failure on line 263 in src/Exception/OAuthServerException.php

View workflow job for this annotation

GitHub Actions / Static Analysis (8.3, prefer-lowest, ubuntu-latest)

Parameter #1 $payload of method League\OAuth2\Server\Exception\OAuthServerException::setPayload() expects array<string, string>, array<string, int|string> given.

Check failure on line 263 in src/Exception/OAuthServerException.php

View workflow job for this annotation

GitHub Actions / Static Analysis (8.3, prefer-stable, ubuntu-latest)

Parameter #1 $payload of method League\OAuth2\Server\Exception\OAuthServerException::setPayload() expects array<string, string>, array<string, int|string> given.

Check failure on line 263 in src/Exception/OAuthServerException.php

View workflow job for this annotation

GitHub Actions / Static Analysis (8.4, prefer-lowest, ubuntu-latest)

Parameter #1 $payload of method League\OAuth2\Server\Exception\OAuthServerException::setPayload() expects array<string, string>, array<string, int|string> given.

Check failure on line 263 in src/Exception/OAuthServerException.php

View workflow job for this annotation

GitHub Actions / Static Analysis (8.4, prefer-stable, ubuntu-latest)

Parameter #1 $payload of method League\OAuth2\Server\Exception\OAuthServerException::setPayload() expects array<string, string>, array<string, int|string> given.
...$exception->getPayload(),
'interval' => $interval,
]);
}

return $exception;
}

/**
Expand Down

0 comments on commit 7c2c8d0

Please sign in to comment.