1 | <?php |
||
27 | abstract class AuthorizationEndpoint implements MiddlewareInterface |
||
28 | { |
||
29 | /** |
||
30 | * @var UserAccountDiscovery |
||
31 | */ |
||
32 | private $userAccountDiscovery; |
||
33 | |||
34 | /** |
||
35 | * @var UserAccountCheckerManager |
||
36 | */ |
||
37 | private $userAccountCheckerManager; |
||
38 | |||
39 | /** |
||
40 | * @var ExtensionManager |
||
41 | */ |
||
42 | private $consentScreenExtensionManager; |
||
43 | |||
44 | /** |
||
45 | * @var AuthorizationRequestLoader |
||
46 | */ |
||
47 | private $authorizationRequestLoader; |
||
48 | |||
49 | /** |
||
50 | * @var ParameterCheckerManager |
||
51 | */ |
||
52 | private $parameterCheckerManager; |
||
53 | |||
54 | /** |
||
55 | * AuthorizationEndpoint constructor. |
||
56 | * |
||
57 | * @param AuthorizationRequestLoader $authorizationRequestLoader |
||
58 | * @param ParameterCheckerManager $parameterCheckerManager |
||
59 | * @param UserAccountDiscovery $userAccountDiscovery |
||
60 | * @param UserAccountCheckerManager $userAccountCheckerManager |
||
61 | * @param ExtensionManager $consentScreenExtensionManager |
||
62 | */ |
||
63 | public function __construct(AuthorizationRequestLoader $authorizationRequestLoader, ParameterCheckerManager $parameterCheckerManager, UserAccountDiscovery $userAccountDiscovery, UserAccountCheckerManager $userAccountCheckerManager, ExtensionManager $consentScreenExtensionManager) |
||
71 | |||
72 | /** |
||
73 | * @param ServerRequestInterface $request |
||
74 | * @param Authorization $authorization |
||
75 | * |
||
76 | * @return ResponseInterface |
||
77 | */ |
||
78 | abstract protected function redirectToLoginPage(ServerRequestInterface $request, Authorization $authorization): ResponseInterface; |
||
79 | |||
80 | /** |
||
81 | * @param ServerRequestInterface $request |
||
82 | * @param Authorization $authorization |
||
83 | * |
||
84 | * @return ResponseInterface |
||
85 | */ |
||
86 | abstract protected function processConsentScreen(ServerRequestInterface $request, Authorization $authorization): ResponseInterface; |
||
87 | |||
88 | /** |
||
89 | * {@inheritdoc} |
||
90 | */ |
||
91 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
||
143 | |||
144 | /** |
||
145 | * @param Authorization $authorization |
||
146 | * |
||
147 | * @throws OAuth2Exception |
||
148 | * |
||
149 | * @return ResponseInterface |
||
150 | */ |
||
151 | private function buildResponse(Authorization $authorization): ResponseInterface |
||
167 | |||
168 | /** |
||
169 | * @param Authorization $authorization |
||
170 | * @param string $error |
||
171 | * @param string $error_description |
||
172 | * |
||
173 | * @throws OAuth2Exception |
||
174 | */ |
||
175 | private function throwRedirectionException(Authorization $authorization, string $error, string $error_description) |
||
188 | |||
189 | |||
190 | /** |
||
191 | * @param ServerRequestInterface $request |
||
192 | * |
||
193 | * @return Authorization |
||
194 | * |
||
195 | * @throws \Http\Client\Exception |
||
196 | * @throws \OAuth2Framework\Component\Core\Exception\OAuth2Exception |
||
197 | */ |
||
198 | public function createAuthorizationFromRequest(ServerRequestInterface $request): Authorization |
||
205 | } |
||
206 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: