Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4159352
AuthorizationServerFactory.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
AuthorizationServerFactory.php
View Options
<?php
namespace
MediaWiki\Extension\OAuth
;
use
InvalidArgumentException
;
use
League\OAuth2\Server\AuthorizationServer
;
use
MediaWiki\Extension\OAuth\Repository\AccessTokenRepository
;
use
MediaWiki\Extension\OAuth\Repository\ClaimStore
;
use
MediaWiki\Extension\OAuth\Repository\ClientRepository
;
use
MediaWiki\Extension\OAuth\Repository\ScopeRepository
;
use
MediaWiki\MediaWikiServices
;
class
AuthorizationServerFactory
{
/** @var string */
protected
$privateKey
;
/** @var string */
protected
$encryptionKey
;
/** @var string */
private
$canonicalServer
;
/**
* @return static
*/
public
static
function
factory
()
{
$services
=
MediaWikiServices
::
getInstance
();
$extConfig
=
$services
->
getConfigFactory
()->
makeConfig
(
'mwoauth'
);
$mainConfig
=
$services
->
getMainConfig
();
$privateKey
=
$extConfig
->
get
(
'OAuth2PrivateKey'
);
$encryptionKey
=
$extConfig
->
get
(
'OAuthSecretKey'
)
??
$mainConfig
->
get
(
'SecretKey'
);
$canonicalServer
=
$mainConfig
->
get
(
'CanonicalServer'
);
return
new
static
(
$privateKey
,
$encryptionKey
,
$canonicalServer
);
}
/**
* @param string $privateKey
* @param string $encryptionKey
* @param string $canonicalServer
*/
public
function
__construct
(
string
$privateKey
,
string
$encryptionKey
,
string
$canonicalServer
)
{
$this
->
privateKey
=
$privateKey
;
$this
->
encryptionKey
=
trim
(
$encryptionKey
);
if
(
$this
->
encryptionKey
===
''
)
{
// Empty encryption key would not break the workflow, but would cause security issues
throw
new
InvalidArgumentException
(
'Encryption key must be set'
);
}
$this
->
canonicalServer
=
$canonicalServer
;
}
/**
* @return AuthorizationServer
*/
public
function
getAuthorizationServer
()
{
return
new
AuthorizationServer
(
new
ClientRepository
(),
new
AccessTokenRepository
(
$this
->
canonicalServer
),
new
ScopeRepository
(),
$this
->
privateKey
,
$this
->
encryptionKey
,
null
,
new
ClaimStore
()
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 19 2026, 23:51 (9 w, 1 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
c7/9a/9e724dfb68aa56594b55fa75624e
Default Alt Text
AuthorizationServerFactory.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment