mirror of
https://github.com/webmasterskaya/joomla-oauth-server.git
synced 2024-11-23 22:34:50 +03:00
_JEXEC & copyright
This commit is contained in:
parent
f821c9becb
commit
ce0b9a6bc9
@ -1,18 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_oauthserver
|
||||
*
|
||||
* @copyright (c) 2024. Webmasterskaya. <https://webmasterskaya.xyz>
|
||||
* @license MIT; see LICENSE.txt
|
||||
**/
|
||||
|
||||
namespace Webmasterskaya\Component\OauthServer\Administrator\Table;
|
||||
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $identifier
|
||||
* @property int $id
|
||||
* @property string $identifier
|
||||
* @property \DateTimeImmutable|\DateTime|string $expiry
|
||||
* @property ?int $user_id
|
||||
* @property string|array|null $scopes
|
||||
* @property int $client_id
|
||||
* @property int $revoked
|
||||
* @property ?int $user_id
|
||||
* @property string|array|null $scopes
|
||||
* @property int $client_id
|
||||
* @property int $revoked
|
||||
*
|
||||
* @since version
|
||||
*/
|
||||
@ -40,4 +49,4 @@ class AccessTokenTable extends Table implements RevokedTableInterface
|
||||
{
|
||||
parent::__construct('#__webmasterskaya_oauthserver_access_tokens', 'id', $db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_oauthserver
|
||||
*
|
||||
* @copyright (c) 2024. Webmasterskaya. <https://webmasterskaya.xyz>
|
||||
* @license MIT; see LICENSE.txt
|
||||
**/
|
||||
|
||||
namespace Webmasterskaya\Component\OauthServer\Administrator\Table;
|
||||
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $identifier
|
||||
* @property int $id
|
||||
* @property string $identifier
|
||||
* @property \DateTimeImmutable|\DateTime|string $expiry
|
||||
* @property int|null $user_id
|
||||
* @property string|array|null $scopes
|
||||
* @property int $revoked
|
||||
* @property int $client_id
|
||||
* @property int|null $user_id
|
||||
* @property string|array|null $scopes
|
||||
* @property int $revoked
|
||||
* @property int $client_id
|
||||
*
|
||||
* @since version
|
||||
*/
|
||||
@ -40,4 +49,4 @@ class AuthCodeTable extends Table implements RevokedTableInterface
|
||||
{
|
||||
parent::__construct('#__webmasterskaya_oauthserver_authorization_codes', 'id', $db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_oauthserver
|
||||
*
|
||||
* @copyright (c) 2024. Webmasterskaya. <https://webmasterskaya.xyz>
|
||||
* @license MIT; see LICENSE.txt
|
||||
**/
|
||||
|
||||
namespace Webmasterskaya\Component\OauthServer\Administrator\Table;
|
||||
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
use League\OAuth2\Server\Entities\ClientEntityInterface;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* @property int $id;
|
||||
* @property string $identifier;
|
||||
* @property string $name;
|
||||
* @property ?string $secret;
|
||||
* @property string|array|null $redirect_uris;
|
||||
* @property string|array|null $grants;
|
||||
* @property string|array|null $scopes;
|
||||
* @property int $active;
|
||||
* @property int $public;
|
||||
* @property int $allow_plain_text_pkce;
|
||||
* @property int $id ;
|
||||
* @property string $identifier ;
|
||||
* @property string $name ;
|
||||
* @property ?string $secret ;
|
||||
* @property string|array|null $redirect_uris ;
|
||||
* @property string|array|null $grants ;
|
||||
* @property string|array|null $scopes ;
|
||||
* @property int $active ;
|
||||
* @property int $public ;
|
||||
* @property int $allow_plain_text_pkce;
|
||||
*
|
||||
* @since version
|
||||
*/
|
||||
@ -41,7 +49,7 @@ class ClientTable extends Table
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param DatabaseDriver $db Database connector object
|
||||
* @param DatabaseDriver $db Database connector object
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@ -49,4 +57,4 @@ class ClientTable extends Table
|
||||
{
|
||||
parent::__construct('#__webmasterskaya_oauthserver_clients', 'id', $db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_oauthserver
|
||||
*
|
||||
* @copyright (c) 2024. Webmasterskaya. <https://webmasterskaya.xyz>
|
||||
* @license MIT; see LICENSE.txt
|
||||
**/
|
||||
|
||||
namespace Webmasterskaya\Component\OauthServer\Administrator\Table;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
|
||||
use League\OAuth2\Server\Entities\RefreshTokenEntityInterface;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $identifier
|
||||
* @property int $id
|
||||
* @property string $identifier
|
||||
* @property \DateTimeImmutable|\DateTime|string $expiry
|
||||
* @property int $revoked
|
||||
* @property int|null $access_token_id
|
||||
* @property int $revoked
|
||||
* @property int|null $access_token_id
|
||||
*
|
||||
* @since version
|
||||
*/
|
||||
@ -33,4 +39,4 @@ class RefreshTokenTable extends Table implements RevokedTableInterface
|
||||
{
|
||||
parent::__construct('#__webmasterskaya_oauthserver_refresh_tokens', 'id', $db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_oauthserver
|
||||
*
|
||||
* @copyright (c) 2024. Webmasterskaya. <https://webmasterskaya.xyz>
|
||||
* @license MIT; see LICENSE.txt
|
||||
**/
|
||||
|
||||
namespace Webmasterskaya\Component\OauthServer\Administrator\Table;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
interface RevokedTableInterface
|
||||
{
|
||||
public function revoke($pks = null): bool;
|
||||
}
|
||||
}
|
||||
|
@ -1,50 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_oauthserver
|
||||
*
|
||||
* @copyright (c) 2024. Webmasterskaya. <https://webmasterskaya.xyz>
|
||||
* @license MIT; see LICENSE.txt
|
||||
**/
|
||||
|
||||
namespace Webmasterskaya\Component\OauthServer\Administrator\Table;
|
||||
|
||||
use Joomla\CMS\Event\AbstractEvent;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
trait RevokedTableTrait
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
* @since version
|
||||
* @since version
|
||||
* @noinspection PhpMissingFieldTypeInspection
|
||||
*/
|
||||
protected $_tbl = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @since version
|
||||
* @since version
|
||||
* @noinspection PhpMissingFieldTypeInspection
|
||||
*/
|
||||
protected $_tbl_key = '';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @since version
|
||||
* @since version
|
||||
* @noinspection PhpMissingFieldTypeInspection
|
||||
*/
|
||||
protected $_tbl_keys = [];
|
||||
|
||||
/**
|
||||
* @var \Joomla\Database\DatabaseDriver
|
||||
* @since version
|
||||
* @var DatabaseDriver
|
||||
* @since version
|
||||
* @noinspection PhpMissingFieldTypeInspection
|
||||
*/
|
||||
protected $_db;
|
||||
|
||||
abstract public function getDispatcher();
|
||||
|
||||
abstract public function setError($error);
|
||||
|
||||
abstract public function getColumnAlias($column);
|
||||
|
||||
abstract public function getDbo();
|
||||
|
||||
abstract public function appendPrimaryKeys($query, $pk = null);
|
||||
|
||||
public function revoke($pks = null): bool
|
||||
{
|
||||
// Pre-processing by observers
|
||||
@ -52,31 +54,40 @@ trait RevokedTableTrait
|
||||
'onTableBeforeRevoke',
|
||||
[
|
||||
'subject' => $this,
|
||||
'pks' => $pks,
|
||||
'pks' => $pks,
|
||||
]
|
||||
);
|
||||
$this->getDispatcher()->dispatch('onTableBeforeRevoke', $event);
|
||||
|
||||
if (!\is_null($pks)) {
|
||||
if (!\is_array($pks)) {
|
||||
if (!\is_null($pks))
|
||||
{
|
||||
if (!\is_array($pks))
|
||||
{
|
||||
$pks = [$pks];
|
||||
}
|
||||
|
||||
foreach ($pks as $key => $pk) {
|
||||
if (!\is_array($pk)) {
|
||||
foreach ($pks as $key => $pk)
|
||||
{
|
||||
if (!\is_array($pk))
|
||||
{
|
||||
$pks[$key] = [$this->_tbl_key => $pk];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If there are no primary keys set check to see if the instance key is set.
|
||||
if (empty($pks)) {
|
||||
if (empty($pks))
|
||||
{
|
||||
$pk = [];
|
||||
|
||||
foreach ($this->_tbl_keys as $key) {
|
||||
if ($this->$key) {
|
||||
foreach ($this->_tbl_keys as $key)
|
||||
{
|
||||
if ($this->$key)
|
||||
{
|
||||
$pk[$key] = $this->$key;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a full primary key - return false
|
||||
$this->setError(Text::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
|
||||
|
||||
@ -89,7 +100,8 @@ trait RevokedTableTrait
|
||||
|
||||
$revokedField = $this->getColumnAlias('revoked');
|
||||
|
||||
foreach ($pks as $pk) {
|
||||
foreach ($pks as $pk)
|
||||
{
|
||||
$query = $this->_db->getQuery(true)
|
||||
->update($this->_db->quoteName($this->_tbl))
|
||||
->set($this->_db->quoteName($revokedField) . ' = 0');
|
||||
@ -99,9 +111,12 @@ trait RevokedTableTrait
|
||||
|
||||
$this->_db->setQuery($query);
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
$this->_db->execute();
|
||||
} catch (\RuntimeException $e) {
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
$this->setError($e->getMessage());
|
||||
|
||||
return false;
|
||||
@ -110,13 +125,16 @@ trait RevokedTableTrait
|
||||
// If the Table instance value is in the list of primary keys that were set, set the instance.
|
||||
$ours = true;
|
||||
|
||||
foreach ($this->_tbl_keys as $key) {
|
||||
if ($this->$key != $pk[$key]) {
|
||||
foreach ($this->_tbl_keys as $key)
|
||||
{
|
||||
if ($this->$key != $pk[$key])
|
||||
{
|
||||
$ours = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ours) {
|
||||
if ($ours)
|
||||
{
|
||||
$this->$revokedField = 0;
|
||||
}
|
||||
}
|
||||
@ -128,11 +146,19 @@ trait RevokedTableTrait
|
||||
'onTableAfterRevoke',
|
||||
[
|
||||
'subject' => $this,
|
||||
'pks' => $pks
|
||||
'pks' => $pks
|
||||
]
|
||||
);
|
||||
$this->getDispatcher()->dispatch('onTableAfterRevoke', $event);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
abstract public function getDispatcher();
|
||||
|
||||
abstract public function setError($error);
|
||||
|
||||
abstract public function getColumnAlias($column);
|
||||
|
||||
abstract public function appendPrimaryKeys($query, $pk = null);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user