Move require options and resource limits to twig
Moves require options and resource limits from Server\Privileges to the Twig templates. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
79298d1a15
commit
f5eb16066a
@ -737,130 +737,6 @@ class Privileges
|
||||
. '</fieldset>' . "\n";
|
||||
}
|
||||
return $html_output;
|
||||
} // end of the 'PMA_displayPrivTable()' function
|
||||
|
||||
/**
|
||||
* Get require options
|
||||
*
|
||||
* @param array $row privilege array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getRequireOptions(array $row): array
|
||||
{
|
||||
$specified = isset($row['ssl_type']) && $row['ssl_type'] === 'SPECIFIED';
|
||||
return [
|
||||
[
|
||||
'name' => 'ssl_type',
|
||||
'value' => 'NONE',
|
||||
'description' => __('Does not require SSL-encrypted connections.'),
|
||||
'label' => 'REQUIRE NONE',
|
||||
'is_checked' => isset($row['ssl_type']) && ($row['ssl_type'] === 'NONE' || $row['ssl_type'] === ''),
|
||||
'is_disabled' => false,
|
||||
'is_radio' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'ssl_type',
|
||||
'value' => 'ANY',
|
||||
'description' => __('Requires SSL-encrypted connections.'),
|
||||
'label' => 'REQUIRE SSL',
|
||||
'is_checked' => isset($row['ssl_type']) && $row['ssl_type'] === 'ANY',
|
||||
'is_disabled' => false,
|
||||
'is_radio' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'ssl_type',
|
||||
'value' => 'X509',
|
||||
'description' => __('Requires a valid X509 certificate.'),
|
||||
'label' => 'REQUIRE X509',
|
||||
'is_checked' => isset($row['ssl_type']) && $row['ssl_type'] === 'X509',
|
||||
'is_disabled' => false,
|
||||
'is_radio' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'ssl_type',
|
||||
'value' => 'SPECIFIED',
|
||||
'description' => '',
|
||||
'label' => 'SPECIFIED',
|
||||
'is_checked' => $specified,
|
||||
'is_disabled' => false,
|
||||
'is_radio' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'ssl_cipher',
|
||||
'value' => $row['ssl_cipher'] ?? '',
|
||||
'description' => __('Requires that a specific cipher method be used for a connection.'),
|
||||
'label' => 'REQUIRE CIPHER',
|
||||
'is_checked' => false,
|
||||
'is_disabled' => ! $specified,
|
||||
'is_radio' => false,
|
||||
],
|
||||
[
|
||||
'name' => 'x509_issuer',
|
||||
'value' => $row['x509_issuer'] ?? '',
|
||||
'description' => __('Requires that a valid X509 certificate issued by this CA be presented.'),
|
||||
'label' => 'REQUIRE ISSUER',
|
||||
'is_checked' => false,
|
||||
'is_disabled' => ! $specified,
|
||||
'is_radio' => false,
|
||||
],
|
||||
[
|
||||
'name' => 'x509_subject',
|
||||
'value' => $row['x509_subject'] ?? '',
|
||||
'description' => __('Requires that a valid X509 certificate with this subject be presented.'),
|
||||
'label' => 'REQUIRE SUBJECT',
|
||||
'is_checked' => false,
|
||||
'is_disabled' => ! $specified,
|
||||
'is_radio' => false,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource limits
|
||||
*
|
||||
* @param array $row first row from result or boolean false
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getResourceLimits(array $row): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'input_name' => 'max_questions',
|
||||
'name_main' => 'MAX QUERIES PER HOUR',
|
||||
'value' => $row['max_questions'] ?? '0',
|
||||
'description' => __(
|
||||
'Limits the number of queries the user may send to the server per hour.'
|
||||
),
|
||||
],
|
||||
[
|
||||
'input_name' => 'max_updates',
|
||||
'name_main' => 'MAX UPDATES PER HOUR',
|
||||
'value' => $row['max_updates'] ?? '0',
|
||||
'description' => __(
|
||||
'Limits the number of commands that change any table '
|
||||
. 'or database the user may execute per hour.'
|
||||
),
|
||||
],
|
||||
[
|
||||
'input_name' => 'max_connections',
|
||||
'name_main' => 'MAX CONNECTIONS PER HOUR',
|
||||
'value' => $row['max_connections'] ?? '0',
|
||||
'description' => __(
|
||||
'Limits the number of new connections the user may open per hour.'
|
||||
),
|
||||
],
|
||||
[
|
||||
'input_name' => 'max_user_connections',
|
||||
'name_main' => 'MAX USER_CONNECTIONS',
|
||||
'value' => $row['max_user_connections'] ?? '0',
|
||||
'description' => __(
|
||||
'Limits the number of simultaneous connections '
|
||||
. 'the user may have.'
|
||||
),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1091,21 +967,13 @@ class Privileges
|
||||
$row
|
||||
);
|
||||
|
||||
$resourceLimits = [];
|
||||
$requireOptions = [];
|
||||
if ($db === '*') {
|
||||
$resourceLimits = $this->getResourceLimits($row);
|
||||
$requireOptions = $this->getRequireOptions($row);
|
||||
}
|
||||
|
||||
return $this->template->render('server/privileges/global_db_specific_privileges', [
|
||||
'grant_count' => $grantCount,
|
||||
'menu_label' => $menuLabel,
|
||||
'legend' => $legend,
|
||||
'global_priv_table' => $globalPrivTable,
|
||||
'is_global' => $db === '*',
|
||||
'resource_limits' => $resourceLimits,
|
||||
'require_options' => $requireOptions,
|
||||
'row' => $row,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -17,45 +17,126 @@
|
||||
<p>
|
||||
<small><em>{% trans 'Note: Setting these options to 0 (zero) removes the limit.' %}</em></small>
|
||||
</p>
|
||||
{% for limit in resource_limits %}
|
||||
<div class="item">
|
||||
<label for="text_{{ limit.input_name }}">
|
||||
<code><dfn title="{{ limit.description }}">{{ limit.name_main }}</dfn></code>
|
||||
</label>
|
||||
<input type="number" name="{{ limit.input_name }}" id="text_{{ limit.input_name }}" value="
|
||||
{{- limit.value }}" title="{{ limit.description }}">
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<div class="item">
|
||||
<label for="text_max_questions">
|
||||
<code>
|
||||
<dfn title="{% trans 'Limits the number of queries the user may send to the server per hour.' %}">
|
||||
MAX QUERIES PER HOUR
|
||||
</dfn>
|
||||
</code>
|
||||
</label>
|
||||
<input type="number" name="max_questions" id="text_max_questions" value="
|
||||
{{- row.max_questions ?? '0' }}" title="
|
||||
{%- trans 'Limits the number of queries the user may send to the server per hour.' %}">
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
<label for="text_max_updates">
|
||||
<code>
|
||||
<dfn title="{% trans 'Limits the number of commands that change any table or database the user may execute per hour.' %}">
|
||||
MAX UPDATES PER HOUR
|
||||
</dfn>
|
||||
</code>
|
||||
</label>
|
||||
<input type="number" name="max_updates" id="text_max_updates" value="
|
||||
{{- row.max_updates ?? '0' }}" title="
|
||||
{%- trans 'Limits the number of commands that change any table or database the user may execute per hour.' %}">
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
<label for="text_max_connections">
|
||||
<code>
|
||||
<dfn title="{% trans 'Limits the number of new connections the user may open per hour.' %}">
|
||||
MAX CONNECTIONS PER HOUR
|
||||
</dfn>
|
||||
</code>
|
||||
</label>
|
||||
<input type="number" name="max_connections" id="text_max_connections" value="
|
||||
{{- row.max_connections ?? '0' }}" title="
|
||||
{%- trans 'Limits the number of new connections the user may open per hour.' %}">
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
<label for="text_max_user_connections">
|
||||
<code>
|
||||
<dfn title="{% trans 'Limits the number of simultaneous connections the user may have.' %}">
|
||||
MAX USER_CONNECTIONS
|
||||
</dfn>
|
||||
</code>
|
||||
</label>
|
||||
<input type="number" name="max_user_connections" id="text_max_user_connections" value="
|
||||
{{- row.max_user_connections ?? '0' }}" title="
|
||||
{%- trans 'Limits the number of simultaneous connections the user may have.' %}">
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>SSL</legend>
|
||||
<div id="require_ssl_div">
|
||||
{% for option in require_options %}
|
||||
{% if option.name == 'ssl_cipher' %}
|
||||
<div id="specified_div" style="padding-left:20px;">
|
||||
{% endif %}
|
||||
<div class="item">
|
||||
<input type="radio" name="ssl_type" id="ssl_type_NONE" title="
|
||||
{%- trans 'Does not require SSL-encrypted connections.' %}" value="NONE"
|
||||
{{- row.ssl_type == 'NONE' or row.ssl_type == '' ? ' checked' }}>
|
||||
<label for="ssl_type_NONE">
|
||||
<code>REQUIRE NONE</code>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
<input type="radio" name="ssl_type" id="ssl_type_ANY" title="
|
||||
{%- trans 'Requires SSL-encrypted connections.' %}" value="ANY"
|
||||
{{- row.ssl_type == 'ANY' ? ' checked' }}>
|
||||
<label for="ssl_type_ANY">
|
||||
<code>REQUIRE SSL</code>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
<input type="radio" name="ssl_type" id="ssl_type_X509" title="
|
||||
{%- trans 'Requires a valid X509 certificate.' %}" value="X509"
|
||||
{{- row.ssl_type == 'X509' ? ' checked' }}>
|
||||
<label for="ssl_type_X509">
|
||||
<code>REQUIRE X509</code>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
<input type="radio" name="ssl_type" id="ssl_type_SPECIFIED" value="SPECIFIED"
|
||||
{{- row.ssl_type == 'SPECIFIED' ? ' checked' }}>
|
||||
<label for="ssl_type_SPECIFIED">
|
||||
<code>SPECIFIED</code>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div id="specified_div" style="padding-left:20px;">
|
||||
<div class="item">
|
||||
{% if option.is_radio %}
|
||||
<input type="radio" name="ssl_type" id="{{ option.name }}_{{ option.value }}" title="
|
||||
{{- option.description }}" value="{{ option.value }}"{{ option.is_checked ? ' checked' }}>
|
||||
<label for="{{ option.name }}_{{ option.value }}">
|
||||
<code>{{ option.label }}</code>
|
||||
</label>
|
||||
{% else %}
|
||||
<label for="text_{{ option.name }}">
|
||||
<code>{{ option.label }}</code>
|
||||
</label>
|
||||
<input type="text" name="{{ option.name }}" id="text_{{ option.name }}" value="
|
||||
{{- option.value }}" size="80" title="{{ option.description }}"{{ option.is_disabled ? ' disabled' }}>
|
||||
{% endif %}
|
||||
<label for="text_ssl_cipher">
|
||||
<code>REQUIRE CIPHER</code>
|
||||
</label>
|
||||
<input type="text" name="ssl_cipher" id="text_ssl_cipher" value="{{ row.ssl_cipher }}" size="80" title="
|
||||
{%- trans 'Requires that a specific cipher method be used for a connection.' %}"
|
||||
{{- row.ssl_type != 'SPECIFIED' ? ' disabled' }}>
|
||||
</div>
|
||||
|
||||
{% if option.name == 'ssl_cipher' %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<div class="item">
|
||||
<label for="text_x509_issuer">
|
||||
<code>REQUIRE ISSUER</code>
|
||||
</label>
|
||||
<input type="text" name="x509_issuer" id="text_x509_issuer" value="{{ row.x509_issuer }}" size="80" title="
|
||||
{%- trans 'Requires that a valid X509 certificate issued by this CA be presented.' %}"
|
||||
{{- row.ssl_type != 'SPECIFIED' ? ' disabled' }}>
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
<label for="text_x509_subject">
|
||||
<code>REQUIRE SUBJECT</code>
|
||||
</label>
|
||||
<input type="text" name="x509_subject" id="text_x509_subject" value="{{ row.x509_subject }}" size="80" title="
|
||||
{%- trans 'Requires that a valid X509 certificate with this subject be presented.' %}"
|
||||
{{- row.ssl_type != 'SPECIFIED' ? ' disabled' }}>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
{% endif %}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user