mirror of
https://github.com/webmasterskaya/joomla-oauth-server.git
synced 2024-11-23 22:34:50 +03:00
Немного изменений в редактировании клиента
This commit is contained in:
parent
8fe273aed2
commit
0aa1b5a961
@ -12,20 +12,29 @@
|
||||
readonly="true"
|
||||
class="readonly"
|
||||
/>
|
||||
<field
|
||||
name="active"
|
||||
type="list"
|
||||
label="JSTATUS"
|
||||
class="form-select-color-state"
|
||||
default="1"
|
||||
validate="options"
|
||||
>
|
||||
<option value="1">JON</option>
|
||||
<option value="0">JOFF</option>
|
||||
</field>
|
||||
<field name="name"
|
||||
type="text"
|
||||
label="COM_OAUTHSERVER_CLIENT_NAME_LABEL"
|
||||
required="1"
|
||||
/>
|
||||
<field name="public"
|
||||
type="radio"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
label="COM_OAUTHSERVER_CLIENT_PUBLIC_LABEL"
|
||||
description="COM_OAUTHSERVER_CLIENT_PUBLIC_DESCRIPTION"
|
||||
type="list"
|
||||
label="COM_OAUTHSERVER_CLIENT_TYPE_LABEL"
|
||||
filter="integer"
|
||||
default="0">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">COM_OAUTHSERVER_CLIENT_TYPE_PUBLIC</option>
|
||||
<option value="0">COM_OAUTHSERVER_CLIENT_TYPE_CONFIDENTIAL</option>
|
||||
</field>
|
||||
<field
|
||||
name="redirect_uris"
|
||||
@ -69,4 +78,21 @@
|
||||
readonly="1"
|
||||
label="COM_OAUTHSERVER_CLIENT_SECRET_LABEL"/>
|
||||
</fieldset>
|
||||
<fieldset name="endpoints">
|
||||
<field name="authorize_url"
|
||||
type="text"
|
||||
layout="components.oauthserver.field.copy.text"
|
||||
readonly="1"
|
||||
label="COM_OAUTHSERVER_CLIENT_AUTHORIZE_URL_LABEL"/>
|
||||
<field name="token_url"
|
||||
type="text"
|
||||
layout="components.oauthserver.field.copy.text"
|
||||
readonly="1"
|
||||
label="COM_OAUTHSERVER_CLIENT_TOKEN_URL_LABEL"/>
|
||||
<field name="profile_url"
|
||||
type="text"
|
||||
layout="components.oauthserver.field.copy.text"
|
||||
readonly="1"
|
||||
label="COM_OAUTHSERVER_CLIENT_PROFILE_URL_LABEL"/>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
@ -16,11 +16,14 @@ COM_OAUTHSERVER_CLIENT_EDIT = "Редактирование клиента"
|
||||
COM_OAUTHSERVER_CLIENT_DETAILS = "Основные параметры"
|
||||
|
||||
COM_OAUTHSERVER_CLIENT = "Клиент"
|
||||
COM_OAUTHSERVER_CLIENT_CONNECTIONS_TITLE = "Параметры подключения клиента"
|
||||
COM_OAUTHSERVER_SERVER_CONNECTIONS_TITLE = "Параметры подключения сервера"
|
||||
|
||||
COM_OAUTHSERVER_CLIENT_NAME_LABEL = "Имя клиента"
|
||||
COM_OAUTHSERVER_CLIENT_PUBLIC_LABEL = "Публичный клиент"
|
||||
COM_OAUTHSERVER_CLIENT_PUBLIC_DESCRIPTION = "Клиент, у которого нет секрета (Ключа клиента)"
|
||||
COM_OAUTHSERVER_CLIENT_REDIRECT_URI_LABEL = "Callback/Redirect URL"
|
||||
COM_OAUTHSERVER_CLIENT_TYPE_LABEL = "Тип клиента"
|
||||
COM_OAUTHSERVER_CLIENT_TYPE_PUBLIC = "Общедоступный"
|
||||
COM_OAUTHSERVER_CLIENT_TYPE_CONFIDENTIAL = "Конфиденциальный"
|
||||
COM_OAUTHSERVER_CLIENT_REDIRECT_URI_LABEL = "Допустимые значения Callback/Redirect URL"
|
||||
COM_OAUTHSERVER_CLIENT_REDIRECT_URI_DESCRIPTION = "Устанавливает URL, на который будет производиться перенаправление клиента, после аутентификации. Если задать этот параметр, то Redirect URI в запросе будет проигнорирован."
|
||||
COM_OAUTHSERVER_CLIENT_ALLOW_PLAIN_TEXT_PKCE_LABEL = "Разрешить «простой» метод запроса PKCE"
|
||||
COM_OAUTHSERVER_CLIENT_ALLOW_PLAIN_TEXT_PKCE_DESCRIPTION = "Разрешить клиенту создавать запрос PKCE на предоставление кода авторизации с помощью «простого» метода запроса кода."
|
||||
@ -32,6 +35,10 @@ COM_OAUTHSERVER_CLIENTS_HEADING_IDENTIFIER = "ID клиента"
|
||||
COM_OAUTHSERVER_CLIENTS_HEADING_SECRET = "Ключ"
|
||||
COM_OAUTHSERVER_CLIENTS_HEADING_PUBLIC = "Публичный"
|
||||
|
||||
COM_OAUTHSERVER_CLIENT_AUTHORIZE_URL_LABEL = "URL авторизации"
|
||||
COM_OAUTHSERVER_CLIENT_TOKEN_URL_LABEL = "URL токена"
|
||||
COM_OAUTHSERVER_CLIENT_PROFILE_URL_LABEL = "URL профиля"
|
||||
|
||||
COM_OAUTHSERVER_SAVE_AND_RESET = "Сохранить и сбросить"
|
||||
|
||||
COM_OAUTHSERVER_CLIENTS = "Клиенты"
|
||||
|
@ -13,6 +13,7 @@ use Joomla\CMS\Crypt\Crypt;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\MVC\Model\AdminModel;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
use Webmasterskaya\Component\OauthServer\Administrator\Table\ClientTable;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
@ -67,6 +68,13 @@ class ClientModel extends AdminModel
|
||||
$data = $this->getItem();
|
||||
}
|
||||
|
||||
$root = Uri::root();
|
||||
$uri = new Uri($root);
|
||||
|
||||
$data->def('authorize_url', (string) $uri->setPath('login/oauth/authorize'));
|
||||
$data->def('token_url', (string) $uri->setPath('login/oauth/token'));
|
||||
$data->def('profile_url', (string) $uri->setPath('login/oauth/profile'));
|
||||
|
||||
$this->preprocessData('com_oauthserver.client', $data);
|
||||
|
||||
return $data;
|
||||
@ -75,10 +83,16 @@ class ClientModel extends AdminModel
|
||||
public function validate($form, $data, $group = null): bool|array
|
||||
{
|
||||
unset($data['identifier'], $data['secret']);
|
||||
unset($data['authorize_url'], $data['token_url'], $data['profile_url']);
|
||||
|
||||
return parent::validate($form, $data, $group);
|
||||
}
|
||||
|
||||
public function save($data)
|
||||
{
|
||||
return parent::save($data); // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ClientTable $table
|
||||
*
|
||||
@ -92,10 +106,14 @@ class ClientModel extends AdminModel
|
||||
$input = $app->getInput();
|
||||
$task = strtolower($input->getCmd('task', ''));
|
||||
|
||||
if ($task === 'save2reset' || empty($table->id))
|
||||
if (empty($table->id))
|
||||
{
|
||||
$table->identifier = $this->generateNewIdentifier();
|
||||
$table->secret = !!$table->public ? '' : $this->generateNewSecret();
|
||||
}
|
||||
|
||||
if ($task === 'save2reset' || empty($table->id))
|
||||
{
|
||||
$table->secret = '';
|
||||
}
|
||||
|
||||
if (!!$table->public)
|
||||
@ -115,13 +133,26 @@ class ClientModel extends AdminModel
|
||||
parent::prepareTable($table);
|
||||
}
|
||||
|
||||
protected function generateNewHash($field, $algo = 'sha256', $length = 16)
|
||||
{
|
||||
$hash = hash($algo, Crypt::genRandomBytes($length));
|
||||
$table = $this->getTable();
|
||||
|
||||
if ($table->load([$field => $hash]))
|
||||
{
|
||||
return $this->generateNewHash($field, $algo, $length);
|
||||
}
|
||||
|
||||
return $hash;
|
||||
}
|
||||
|
||||
protected function generateNewIdentifier(): string
|
||||
{
|
||||
return hash('md5', Crypt::genRandomBytes(16));
|
||||
return $this->generateNewHash('identifier', 'md5');
|
||||
}
|
||||
|
||||
protected function generateNewSecret(): string
|
||||
{
|
||||
return hash('sha512', Crypt::genRandomBytes(32));
|
||||
return $this->generateNewHash('secret', 'sha512', 32);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
@ -28,24 +29,39 @@ $wa->useScript('keepalive')
|
||||
aria-label="<?php echo Text::_('COM_OAUTHSERVER_CLIENT_FORM_' . ((int) $this->item->id === 0 ? 'NEW' : 'EDIT'), true); ?>"
|
||||
class="form-validate">
|
||||
|
||||
<?php echo LayoutHelper::render('joomla.edit.title_alias', $this); ?>
|
||||
|
||||
<div class="main-card">
|
||||
<?php echo HTMLHelper::_('uitab.startTabSet', 'myTab', ['active' => 'details', 'recall' => true, 'breakpoint' => 768]); ?>
|
||||
|
||||
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'details', Text::_('COM_OAUTHSERVER_CLIENT_DETAILS')); ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<fieldset id="fieldset-publishingdata" class="options-form">
|
||||
<legend><?php echo Text::_('COM_OAUTHSERVER_CLIENT'); ?></legend>
|
||||
<div class="col-9">
|
||||
<fieldset id="fieldset-connections" class="options-form">
|
||||
<legend><?php echo Text::_('COM_OAUTHSERVER_CLIENT_CONNECTIONS_TITLE'); ?></legend>
|
||||
<div>
|
||||
<?php echo $this->form->renderField('name'); ?>
|
||||
<?php echo $this->form->renderField('public'); ?>
|
||||
<?php echo $this->form->renderField('redirect_uris'); ?>
|
||||
<?php echo $this->form->renderField('allow_plain_text_pkce'); ?>
|
||||
<?php echo $this->form->renderField('identifier'); ?>
|
||||
<?php echo $this->form->renderField('secret'); ?>
|
||||
<?php echo $this->form->renderField('redirect_uris'); ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset id="fieldset-endpoints" class="options-form">
|
||||
<legend><?php echo Text::_('COM_OAUTHSERVER_SERVER_CONNECTIONS_TITLE'); ?></legend>
|
||||
|
||||
<div>
|
||||
<?php echo $this->form->renderField('authorize_url'); ?>
|
||||
<?php echo $this->form->renderField('token_url'); ?>
|
||||
<?php echo $this->form->renderField('profile_url'); ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<fieldset class="form-vertical">
|
||||
<legend class="visually-hidden"><?php echo Text::_('JGLOBAL_FIELDSET_GLOBAL'); ?></legend>
|
||||
<?php echo $this->form->renderField('active'); ?>
|
||||
<?php echo $this->form->renderField('public'); ?>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user