Add API key manager
rodzic
2e4b8f85b1
commit
34ea14d34e
@ -1,5 +1,6 @@
|
||||
{
|
||||
"Edit": "Edit",
|
||||
"cancel": "Cancel",
|
||||
"Choose a user": "Choose a user"
|
||||
"Choose a user": "Choose a user",
|
||||
"Add Key": "Add Key"
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"Key": "Key",
|
||||
"Type": "Type",
|
||||
"Notes": "Notes",
|
||||
"Revoke": "Revoke",
|
||||
"Cannot revoke that API key, you would lose access to ManagePanel.": "Cannot revoke that API key, you would lose access to ManagePanel.",
|
||||
"API key revoked.": "API key revoked.",
|
||||
"That API key already exists.": "That API key already exists.",
|
||||
"API key added.": "API key added."
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
$key = hash("SHA1", random_bytes(100));
|
||||
|
||||
$form = new FormBuilder($Strings->get("Add Key", false), "fas fa-plus");
|
||||
|
||||
$form->addInput("key", $key, "text", true, "key", null, $Strings->get("Key", false), "fas fa-key", 12, 20);
|
||||
|
||||
$form->addInput("type", "", "select", true, "type", ["NONE" => "NONE", "AUTH" => "AUTH", "READ" => "READ", "FULL" => "FULL"], $Strings->get("Type", false), "fas fa-list", 6);
|
||||
|
||||
$form->addInput("notes", "", "textarea", false, "notes", null, $Strings->get("Notes", false), "fas fa-sticky-note", 6);
|
||||
|
||||
$form->addButton($Strings->get("Add Key", false), "fas fa-save", null, "submit", null, null, "", "btn btn-success");
|
||||
|
||||
$form->addHiddenInput("action", "addapikey");
|
||||
$form->addHiddenInput("source", "apikeys");
|
||||
|
||||
$form->generate();
|
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
require_once __DIR__ . '/../required.php';
|
||||
|
||||
redirectifnotloggedin();
|
||||
?>
|
||||
<div class="btn-group mgn-btm-10px">
|
||||
<a href="app.php?page=addapikey" class="btn btn-primary"><i class="fas fa-plus"></i> <?php $Strings->get("Add Key"); ?></a>
|
||||
</div>
|
||||
<table id="apikeytable" class="table table-bordered table-hover table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-priority="0"></th>
|
||||
<th data-priority="1"><?php $Strings->get('actions'); ?></th>
|
||||
<th data-priority="1"><i class="fas fa-fw fa-key d-none d-md-inline"></i> <?php $Strings->get('Key'); ?></th>
|
||||
<th data-priority="1"><i class="fas fa-fw fa-list d-none d-md-inline"></i> <?php $Strings->get('Type'); ?></th>
|
||||
<th data-priority="2"><i class="fas fa-fw fa-sticky-note d-none d-md-inline"></i> <?php $Strings->get('Notes'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$keys = $database->select("apikeys", ["key", "notes", "type"]);
|
||||
foreach ($keys as $key) {
|
||||
if ($SETTINGS['hide_api_key_in_use'] && $key['key'] == $SETTINGS['accounthub']['key']) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><form action="action.php" method="POST">
|
||||
<input type="hidden" name="action" value="revokeapikey" />
|
||||
<input type="hidden" name="source" value="apikeys" />
|
||||
<input type="hidden" name="key" value="<?php echo $key['key']; ?>" />
|
||||
<button type="submit" class="btn btn-danger btn-sm"><i class="fas fa-times"></i> <?php $Strings->get("Revoke"); ?></button>
|
||||
</form></td>
|
||||
<td><?php echo $key['key']; ?></td>
|
||||
<td><?php echo $key['type']; ?></td>
|
||||
<td><?php echo htmlentities($key['notes']); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th data-priority="0"></th>
|
||||
<th data-priority="1"><?php $Strings->get('actions'); ?></th>
|
||||
<th data-priority="1"><i class="fas fa-fw fa-key d-none d-md-inline"></i> <?php $Strings->get('Key'); ?></th>
|
||||
<th data-priority="1"><i class="fas fa-fw fa-list d-none d-md-inline"></i> <?php $Strings->get('Type'); ?></th>
|
||||
<th data-priority="2"><i class="fas fa-fw fa-sticky-note d-none d-md-inline"></i> <?php $Strings->get('Notes'); ?></th>
|
||||
</tfoot>
|
||||
</table>
|
@ -0,0 +1,30 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
$('#apikeytable').DataTable({
|
||||
responsive: {
|
||||
details: {
|
||||
display: $.fn.dataTable.Responsive.display.modal({
|
||||
header: function (row) {
|
||||
var data = row.data();
|
||||
return "<i class=\"fas fa-list fa-fw\"></i> " + data[1];
|
||||
}
|
||||
}),
|
||||
renderer: $.fn.dataTable.Responsive.renderer.tableAll({
|
||||
tableClass: 'table'
|
||||
}),
|
||||
type: "column"
|
||||
}
|
||||
},
|
||||
columnDefs: [
|
||||
{
|
||||
targets: 0,
|
||||
className: 'control',
|
||||
orderable: false
|
||||
}
|
||||
],
|
||||
order: [
|
||||
[1, 'desc']
|
||||
],
|
||||
});
|
Ładowanie…
Reference in New Issue