Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
AuthorizationCodeAccessTokens | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
2.02 | |
0.00% |
0 / 1 |
getGrant | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
2.02 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\OAuth\AuthorizationProvider\Grant; |
4 | |
5 | use DateInterval; |
6 | use Exception; |
7 | use League\OAuth2\Server\Grant\AuthCodeGrant; |
8 | use League\OAuth2\Server\Grant\GrantTypeInterface; |
9 | use MediaWiki\Extension\OAuth\AuthorizationProvider\AccessToken; |
10 | |
11 | class AuthorizationCodeAccessTokens extends AccessToken { |
12 | |
13 | /** |
14 | * @return GrantTypeInterface |
15 | * @throws Exception |
16 | */ |
17 | protected function getGrant(): GrantTypeInterface { |
18 | $authCodeRepo = $this->getAuthCodeRepo(); |
19 | $refreshTokenRepo = $this->getRefreshTokenRepo(); |
20 | $grant = new AuthCodeGrant( $authCodeRepo, $refreshTokenRepo, new DateInterval( 'PT10M' ) ); |
21 | if ( !$this->config->get( 'OAuth2RequireCodeChallengeForPublicClients' ) ) { |
22 | $grant->disableRequireCodeChallengeForPublicClients(); |
23 | } |
24 | |
25 | return $grant; |
26 | } |
27 | } |