1 | <?php |
||
16 | trait RequestValidatorTrait |
||
17 | { |
||
18 | /** |
||
19 | * Get the Emitter. |
||
20 | * |
||
21 | * @return EmitterInterface |
||
22 | */ |
||
23 | abstract public function getEmitter(); |
||
24 | |||
25 | /** |
||
26 | * @return ClientRepositoryInterface |
||
27 | */ |
||
28 | abstract public function getClientRepository(); |
||
29 | |||
30 | /** |
||
31 | * Return the grant identifier that can be used in matching up requests. |
||
32 | * |
||
33 | * @return string |
||
34 | */ |
||
35 | abstract public function getIdentifier(); |
||
36 | |||
37 | /** |
||
38 | * Validate the client. |
||
39 | * |
||
40 | * @param ServerRequestInterface $request |
||
41 | * |
||
42 | * @throws OAuthServerException |
||
43 | * |
||
44 | * @return ClientEntityInterface |
||
45 | */ |
||
46 | 54 | public function validateClient(ServerRequestInterface $request) |
|
78 | |||
79 | /** |
||
80 | * Validate redirectUri from the request. |
||
81 | * If a redirect URI is provided ensure it matches what is pre-registered |
||
82 | * |
||
83 | * @param string $redirectUri |
||
84 | * @param ClientEntityInterface $client |
||
85 | * @param ServerRequestInterface $request |
||
86 | * |
||
87 | * @throws OAuthServerException |
||
88 | */ |
||
89 | 34 | public function validateRedirectUri( |
|
106 | |||
107 | /** |
||
108 | * Retrieve request parameter. |
||
109 | * |
||
110 | * @param string $parameter |
||
111 | * @param ServerRequestInterface $request |
||
112 | * @param mixed $default |
||
113 | * |
||
114 | * @return null|string |
||
115 | */ |
||
116 | 54 | protected function getRequestParameter($parameter, ServerRequestInterface $request, $default = null) |
|
122 | |||
123 | /** |
||
124 | * Retrieve HTTP Basic Auth credentials with the Authorization header |
||
125 | * of a request. First index of the returned array is the username, |
||
126 | * second is the password (so list() will work). If the header does |
||
127 | * not exist, or is otherwise an invalid HTTP Basic header, return |
||
128 | * [null, null]. |
||
129 | * |
||
130 | * @param ServerRequestInterface $request |
||
131 | * |
||
132 | * @return string[]|null[] |
||
133 | */ |
||
134 | 59 | public function getBasicAuthCredentials(ServerRequestInterface $request) |
|
155 | |||
156 | /** |
||
157 | * Retrieve query string parameter. |
||
158 | * |
||
159 | * @param string $parameter |
||
160 | * @param ServerRequestInterface $request |
||
161 | * @param mixed $default |
||
162 | * |
||
163 | * @return null|string |
||
164 | */ |
||
165 | 21 | protected function getQueryStringParameter($parameter, ServerRequestInterface $request, $default = null) |
|
169 | |||
170 | /** |
||
171 | * Retrieve cookie parameter. |
||
172 | * |
||
173 | * @param string $parameter |
||
174 | * @param ServerRequestInterface $request |
||
175 | * @param mixed $default |
||
176 | * |
||
177 | * @return null|string |
||
178 | */ |
||
179 | 1 | protected function getCookieParameter($parameter, ServerRequestInterface $request, $default = null) |
|
183 | |||
184 | /** |
||
185 | * Retrieve server parameter. |
||
186 | * |
||
187 | * @param string $parameter |
||
188 | * @param ServerRequestInterface $request |
||
189 | * @param mixed $default |
||
190 | * |
||
191 | * @return null|string |
||
192 | */ |
||
193 | 20 | protected function getServerParameter($parameter, ServerRequestInterface $request, $default = null) |
|
197 | } |
||
198 |