Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
83.33% covered (warning)
83.33%
5 / 6
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
AuthorizationCodeAccessTokens
83.33% covered (warning)
83.33%
5 / 6
0.00% covered (danger)
0.00%
0 / 1
2.02
0.00% covered (danger)
0.00%
0 / 1
 getGrant
83.33% covered (warning)
83.33%
5 / 6
0.00% covered (danger)
0.00%
0 / 1
2.02
1<?php
2
3namespace MediaWiki\Extension\OAuth\AuthorizationProvider\Grant;
4
5use DateInterval;
6use Exception;
7use League\OAuth2\Server\Grant\AuthCodeGrant;
8use League\OAuth2\Server\Grant\GrantTypeInterface;
9use MediaWiki\Extension\OAuth\AuthorizationProvider\AccessToken;
10
11class 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}