Page MenuHomeWickedGov Phorge

ClientRepository.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

ClientRepository.php

<?php
namespace MediaWiki\Extension\OAuth\Repository;
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
use MediaWiki\Extension\OAuth\Backend\Utils;
use MediaWiki\Extension\OAuth\Entity\ClientEntity;
use Wikimedia\NormalizedException\NormalizedException;
class ClientRepository implements ClientRepositoryInterface {
/**
* Get a client.
*
* @param string $clientIdentifier The client's identifier
*
* @return ClientEntity|bool
*/
public function getClientEntity( $clientIdentifier ) {
$client = ClientEntity::newFromKey(
Utils::getCentralDB( DB_REPLICA ),
$clientIdentifier
);
if ( !$client instanceof ClientEntity ) {
return false;
}
return $client;
}
/**
* @param int $clientId
* @return ClientEntity|bool
*/
public function getClientEntityByDBId( $clientId ) {
$client = ClientEntity::newFromId( Utils::getCentralDB( DB_REPLICA ), $clientId );
if ( !$client instanceof ClientEntity ) {
return false;
}
return $client;
}
/**
* Validate a client's secret.
*
* @param string $clientIdentifier The client's identifier
* @param null|string $clientSecret The client's secret (if sent)
* @param null|string $grantType The type of grant the client is using (if sent)
*
* @return bool
* @throws NormalizedException
*/
public function validateClient( $clientIdentifier, $clientSecret, $grantType ) {
$client = $this->getClientEntity( $clientIdentifier );
if ( !$client || !$client instanceof ClientEntity ) {
throw new NormalizedException(
"Client with identifier '{clientIdentifier}' does not exist!",
[
'clientIdentifier' => $clientIdentifier,
]
);
}
return $client->validate( $clientSecret, $grantType );
}
}

File Metadata

Mime Type
text/x-php
Expires
Oct 4 2026, 21:09 (5 w, 6 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
98/9c/314a9cd79406cd845c44f74f9daa
Default Alt Text
ClientRepository.php (1 KB)

Event Timeline