Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1427087
AuthCodeRepository.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
AuthCodeRepository.php
View Options
<?php
namespace
MediaWiki\Extension\OAuth\Repository
;
use
InvalidArgumentException
;
use
League\OAuth2\Server\Entities\AuthCodeEntityInterface
;
use
League\OAuth2\Server\Exception\UniqueTokenIdentifierConstraintViolationException
;
use
League\OAuth2\Server\Repositories\AuthCodeRepositoryInterface
;
use
MediaWiki\Extension\OAuth\Entity\AuthCodeEntity
;
class
AuthCodeRepository
extends
CacheRepository
implements
AuthCodeRepositoryInterface
{
/**
* Creates a new AuthCode
*
* @return AuthCodeEntityInterface
*/
public
function
getNewAuthCode
()
{
return
new
AuthCodeEntity
();
}
/**
* Persists a new auth code to permanent storage.
*
* @param AuthCodeEntityInterface $authCodeEntity
*
* @throws UniqueTokenIdentifierConstraintViolationException
*/
public
function
persistNewAuthCode
(
AuthCodeEntityInterface
$authCodeEntity
)
{
if
(
!
$authCodeEntity
instanceof
AuthCodeEntity
)
{
throw
new
InvalidArgumentException
(
'$authCodeEntity must be instance of '
.
AuthCodeEntity
::
class
.
', got '
.
get_class
(
$authCodeEntity
)
.
' instead'
);
}
if
(
$this
->
has
(
$authCodeEntity
->
getIdentifier
()
)
)
{
throw
UniqueTokenIdentifierConstraintViolationException
::
create
();
}
$this
->
set
(
$authCodeEntity
->
getIdentifier
(),
$authCodeEntity
->
jsonSerialize
(),
$authCodeEntity
->
getExpiryDateTime
()->
getTimestamp
()
);
}
/**
* Revoke an auth code.
*
* @param string $codeId
*/
public
function
revokeAuthCode
(
$codeId
)
{
$this
->
delete
(
$codeId
);
}
/**
* Check if the auth code has been revoked.
*
* @param string $codeId
*
* @return bool Return true if this code has been revoked
*/
public
function
isAuthCodeRevoked
(
$codeId
)
{
return
$this
->
has
(
$codeId
)
===
false
;
}
/**
* Get object type for session key
*
* @return string
*/
protected
function
getCacheKeyType
():
string
{
return
'AuthCode'
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 14:11 (1 d, 17 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
79/96/bf0a95e9da386108366ce2970f3f
Default Alt Text
AuthCodeRepository.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment