feat: harden the myep oauth2 client
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Security\OAuth2;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* MyE&P redirected back with an `error` instead of a code — the person cancelled, or the
|
||||
* authorization was refused.
|
||||
*
|
||||
* A subclass of AuthorizationRequestException so that a caller which does not care why the
|
||||
* callback carried no code still catches it, and one that does can tell this apart from a
|
||||
* malformed or replayed callback and say so.
|
||||
*/
|
||||
class AuthorizationDeniedException extends AuthorizationRequestException
|
||||
{
|
||||
public function __construct(
|
||||
private readonly string $error,
|
||||
private readonly ?string $errorDescription,
|
||||
Request $request,
|
||||
) {
|
||||
parent::__construct(sprintf('Authorization denied: %s', $error), 400, $request);
|
||||
}
|
||||
|
||||
public function getError(): string
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
public function getErrorDescription(): ?string
|
||||
{
|
||||
return $this->errorDescription;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user