Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 10 |
CRAP | |
0.00% |
0 / 1 |
| ConsumerAcceptanceAccessControl | |
0.00% |
0 / 12 |
|
0.00% |
0 / 10 |
110 | |
0.00% |
0 / 1 |
| getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getWiki | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getUserId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getConsumerId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getAccessToken | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getAccessSecret | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getGrants | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getAccepted | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getWikiName | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| getDAO | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Extension\OAuth\Control; |
| 4 | |
| 5 | use MediaWiki\Extension\OAuth\Backend\ConsumerAcceptance; |
| 6 | use MediaWiki\Extension\OAuth\Backend\Utils; |
| 7 | use MediaWiki\Message\Message; |
| 8 | |
| 9 | class ConsumerAcceptanceAccessControl extends DAOAccessControl { |
| 10 | // accessor fields copied from ConsumerAcceptance, except they can return a Message |
| 11 | // on access error |
| 12 | |
| 13 | /** |
| 14 | * Database ID. |
| 15 | * Returns a Message when the user does not have permission to see this field. |
| 16 | * @return int|Message |
| 17 | */ |
| 18 | public function getId() { |
| 19 | return $this->get( 'id' ); |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Wiki on which the user has authorized the consumer to access their account. Wiki ID or '*' |
| 24 | * for all. |
| 25 | * Returns a Message when the user does not have permission to see this field. |
| 26 | * @return string|Message |
| 27 | */ |
| 28 | public function getWiki() { |
| 29 | return $this->get( 'wiki' ); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Central user ID of the authorizing user. |
| 34 | * Returns a Message when the user does not have permission to see this field. |
| 35 | * @return int|Message |
| 36 | */ |
| 37 | public function getUserId() { |
| 38 | return $this->get( 'userId' ); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Database ID of the consumer. |
| 43 | * Returns a Message when the user does not have permission to see this field. |
| 44 | * @return int|Message |
| 45 | */ |
| 46 | public function getConsumerId() { |
| 47 | return $this->get( 'consumerId' ); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * The access token for the OAuth protocol |
| 52 | * Returns a Message when the user does not have permission to see this field. |
| 53 | * @return string|Message |
| 54 | */ |
| 55 | public function getAccessToken() { |
| 56 | return $this->get( 'accessToken' ); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Secret key used to derive the access secret for the OAuth protocol. |
| 61 | * The actual access secret will be calculated via Utils::hmacDBSecret() to mitigate |
| 62 | * DB leaks. |
| 63 | * Returns a Message when the user does not have permission to see this field. |
| 64 | * @return string|Message |
| 65 | */ |
| 66 | public function getAccessSecret() { |
| 67 | return $this->get( 'accessSecret' ); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * The list of grants which have been granted. |
| 72 | * Returns a Message when the user does not have permission to see this field. |
| 73 | * @return string[]|Message |
| 74 | */ |
| 75 | public function getGrants() { |
| 76 | return $this->get( 'grants' ); |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Date of the authorization, in TS_MW format. |
| 81 | * Returns a Message when the user does not have permission to see this field. |
| 82 | * @return string|Message |
| 83 | */ |
| 84 | public function getAccepted() { |
| 85 | return $this->get( 'accepted' ); |
| 86 | } |
| 87 | |
| 88 | // accessors for common formatting |
| 89 | |
| 90 | /** |
| 91 | * Pretty wiki name. |
| 92 | * @return string|Message |
| 93 | */ |
| 94 | public function getWikiName() { |
| 95 | return $this->get( 'wiki', static function ( $wikiId ) { |
| 96 | return Utils::getWikiIdName( $wikiId ); |
| 97 | } ); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * @return ConsumerAcceptance |
| 102 | */ |
| 103 | public function getDAO() { |
| 104 | // @phan-suppress-next-line PhanTypeMismatchReturnSuperType |
| 105 | return $this->dao; |
| 106 | } |
| 107 | } |