Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 4 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
Setup | |
0.00% |
0 / 4 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
onTestCanonicalRedirect | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isOAuthRequest | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\OAuth; |
4 | |
5 | use MediaWiki\Extension\OAuth\Backend\Utils; |
6 | use MediaWiki\Hook\TestCanonicalRedirectHook; |
7 | use MediaWiki\Output\OutputPage; |
8 | use MediaWiki\Request\WebRequest; |
9 | use MediaWiki\Title\Title; |
10 | |
11 | /** |
12 | * Class containing hooked functions for an OAuth environment |
13 | */ |
14 | class Setup implements TestCanonicalRedirectHook { |
15 | /** |
16 | * Prevent redirects to canonical titles, since that's not what the OAuth |
17 | * request signed. |
18 | * @param WebRequest $request |
19 | * @param Title $title |
20 | * @param OutputPage $output |
21 | * @return bool |
22 | */ |
23 | public function onTestCanonicalRedirect( $request, $title, $output ) { |
24 | return !self::isOAuthRequest( $request ); |
25 | } |
26 | |
27 | protected static function isOAuthRequest( $request ) { |
28 | if ( Utils::hasOAuthHeaders( $request ) ) { |
29 | return true; |
30 | } |
31 | return ResourceServer::isOAuth2Request( $request ); |
32 | } |
33 | } |