Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 07c9da8a80 | |||
| 4bdd4c1d8a | |||
| 336334c7f5 | |||
| a502ae2687 | |||
| 782d8446d9 | |||
| 5b79f5fb4b | |||
| a0f84ec78e |
@@ -1743,13 +1743,12 @@ def update_api_key(kid: int):
|
||||
|
||||
@app.route("/api/api-keys/<int:kid>", methods=["DELETE"])
|
||||
@require_login
|
||||
def revoke_api_key(kid: int):
|
||||
def delete_api_key(kid: int):
|
||||
with db_cursor() as (_, cur):
|
||||
cur.execute(
|
||||
"""
|
||||
UPDATE api_keys
|
||||
SET revoked_at = CURRENT_TIMESTAMP
|
||||
WHERE id = %s AND revoked_at IS NULL
|
||||
DELETE FROM api_keys
|
||||
WHERE id = %s
|
||||
""",
|
||||
(kid,),
|
||||
)
|
||||
|
||||
+13
-12
@@ -366,14 +366,14 @@ async function submitApiKey() {
|
||||
}
|
||||
}
|
||||
|
||||
async function revokeApiKey(id: number, label: string) {
|
||||
if (!confirm(`Revoke API key "${label}"? This cannot be undone.`)) return;
|
||||
async function deleteApiKey(id: number, label: string) {
|
||||
if (!confirm(`Delete API key "${label}"? This cannot be undone.`)) return;
|
||||
apiKeysErr.value = "";
|
||||
try {
|
||||
await api.revokeApiKey(id);
|
||||
await api.deleteApiKey(id);
|
||||
await refreshApiKeys();
|
||||
} catch (e) {
|
||||
apiKeysErr.value = e instanceof Error ? e.message : "Failed to revoke API key";
|
||||
apiKeysErr.value = e instanceof Error ? e.message : "Failed to delete API key";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -692,27 +692,29 @@ async function deleteIdentityRow(id: number) {
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<div class="flex items-center gap-2 truncate">
|
||||
<span class="truncate text-sm font-semibold text-white">JDB-NET SSH</span>
|
||||
<a
|
||||
href="https://git.jdbnet.co.uk/jamie/ssh"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="flex items-center gap-2 truncate"
|
||||
class="truncate text-xs text-slate-400 hover:text-slate-300"
|
||||
>
|
||||
<span class="truncate text-sm font-semibold text-white">JDB-NET SSH</span>
|
||||
<span class="truncate text-xs text-slate-400 hover:text-slate-300">{{ appVersion }}</span>
|
||||
{{ appVersion }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg px-3 py-1.5 text-xs text-slate-400 hover:bg-slate-800 hover:text-white"
|
||||
class="hidden rounded-lg px-3 py-1.5 text-xs text-slate-400 hover:bg-slate-800 hover:text-white md:inline-flex"
|
||||
@click="openApiKeys"
|
||||
>
|
||||
API keys
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg px-3 py-1.5 text-xs text-slate-400 hover:bg-slate-800 hover:text-white"
|
||||
class="hidden rounded-lg px-3 py-1.5 text-xs text-slate-400 hover:bg-slate-800 hover:text-white md:inline-flex"
|
||||
@click="openAuditLog"
|
||||
>
|
||||
Connection audit
|
||||
@@ -1139,12 +1141,11 @@ async function deleteIdentityRow(id: number) {
|
||||
<td class="px-2 py-2">{{ apiKeyStatus(row) }}</td>
|
||||
<td class="px-2 py-2 text-right">
|
||||
<button
|
||||
v-if="row.active"
|
||||
type="button"
|
||||
class="rounded px-2 py-1 text-red-400 hover:bg-slate-800"
|
||||
@click="revokeApiKey(row.id, row.label)"
|
||||
@click="deleteApiKey(row.id, row.label)"
|
||||
>
|
||||
Revoke
|
||||
Delete
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
+1
-1
@@ -226,7 +226,7 @@ export const api = {
|
||||
return handle(res);
|
||||
},
|
||||
|
||||
async revokeApiKey(id: number): Promise<void> {
|
||||
async deleteApiKey(id: number): Promise<void> {
|
||||
const res = await fetch(`/api/api-keys/${id}`, {
|
||||
method: "DELETE",
|
||||
credentials: "include",
|
||||
|
||||
Generated
-6
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"name": "ssh",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {}
|
||||
}
|
||||
Reference in New Issue
Block a user