forked from alterminal/alterminal
115 lines
7.3 KiB
HTML
115 lines
7.3 KiB
HTML
{{/* 應用程式管理頁(僅 admin)。以 layout.html(側邊導覽欄版面)為根模板
|
|
組合渲染:本檔僅定義區塊,不應單獨解析執行;並引用 secretpanel.html
|
|
的一次性成果面板。導覽覆寫為「帳號資訊+金鑰管理+應用程式管理」
|
|
(後者標記 aria-current),側欄頁尾沿用版面預設。每列提供編輯(連往
|
|
/admin/applications/{id})、輪替 secret 與刪除操作;註冊表單獨立於
|
|
/admin/applications/new(本頁按鈕進入);輪替成功時於 POST 回應直接
|
|
顯示明文 client secret(僅此一次,故不採 PRG)。 */}}
|
|
{{define "title"}}應用程式管理 - alterminal{{end}}
|
|
|
|
{{define "navitems"}}
|
|
<li>
|
|
<a href="/login"
|
|
class="flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium text-neutral-600 hover:bg-neutral-100 dark:text-neutral-300 dark:hover:bg-neutral-700/60">
|
|
<svg class="size-5 shrink-0" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
|
|
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z"/>
|
|
</svg>
|
|
帳號資訊
|
|
</a>
|
|
</li>
|
|
<li>
|
|
<a href="/admin/keys"
|
|
class="flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium text-neutral-600 hover:bg-neutral-100 dark:text-neutral-300 dark:hover:bg-neutral-700/60">
|
|
<svg class="size-5 shrink-0" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
|
|
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z"/>
|
|
</svg>
|
|
金鑰管理
|
|
</a>
|
|
</li>
|
|
<li>
|
|
<a href="/admin/applications" aria-current="page"
|
|
class="flex items-center gap-3 rounded-lg bg-brand/10 px-3 py-2 text-sm font-medium text-brand dark:bg-brand/25 dark:text-blue-200">
|
|
<svg class="size-5 shrink-0" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
|
|
<path stroke-linecap="round" stroke-linejoin="round" d="M21 7.5l-9-5.25L3 7.5m18 0l-9 5.25m9-5.25v9l-9 5.25M3 7.5l9 5.25M3 7.5v9l9 5.25m0-9v9"/>
|
|
</svg>
|
|
應用程式管理
|
|
</a>
|
|
</li>
|
|
{{end}}
|
|
|
|
{{define "content"}}
|
|
<section class="rounded-xl bg-white p-8 shadow-lg dark:bg-neutral-800 dark:shadow-black/40">
|
|
<div class="mb-6 flex flex-wrap items-center justify-between gap-3">
|
|
<div>
|
|
<h1 class="mb-1 text-xl font-semibold">應用程式管理</h1>
|
|
<p class="text-sm text-neutral-500 dark:text-neutral-400">接入 OIDC 的應用程式(Relying Party)註冊</p>
|
|
</div>
|
|
<a href="/admin/applications/new"
|
|
class="flex items-center gap-2 rounded-lg bg-brand px-4 py-2.5 text-sm font-semibold text-white hover:bg-brand-strong">
|
|
<svg class="size-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
|
|
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15"/>
|
|
</svg>
|
|
註冊新應用程式
|
|
</a>
|
|
</div>
|
|
{{if .Error}}<p class="mb-4 rounded-lg bg-red-500/10 px-3 py-2.5 text-sm text-red-600 dark:text-red-400" role="alert">{{.Error}}</p>{{end}}
|
|
{{if .Secret}}{{template "secretpanel" .Secret}}{{end}}
|
|
|
|
{{if .Apps}}
|
|
<div class="overflow-x-auto">
|
|
<table class="w-full text-left text-sm">
|
|
<thead>
|
|
<tr class="border-b border-neutral-200 dark:border-neutral-700">
|
|
<th scope="col" class="px-3 py-2 text-xs font-medium tracking-wide text-neutral-500 uppercase dark:text-neutral-400">名稱</th>
|
|
<th scope="col" class="px-3 py-2 text-xs font-medium tracking-wide text-neutral-500 uppercase dark:text-neutral-400">client_id</th>
|
|
<th scope="col" class="px-3 py-2 text-xs font-medium tracking-wide text-neutral-500 uppercase dark:text-neutral-400">類型</th>
|
|
<th scope="col" class="px-3 py-2 text-xs font-medium tracking-wide text-neutral-500 uppercase dark:text-neutral-400">redirect URI</th>
|
|
<th scope="col" class="px-3 py-2 text-xs font-medium tracking-wide text-neutral-500 uppercase dark:text-neutral-400">grant type</th>
|
|
<th scope="col" class="px-3 py-2 text-xs font-medium tracking-wide text-neutral-500 uppercase dark:text-neutral-400">scope</th>
|
|
<th scope="col" class="px-3 py-2 text-xs font-medium tracking-wide text-neutral-500 uppercase dark:text-neutral-400">建立時間</th>
|
|
<th scope="col" class="px-3 py-2"><span class="sr-only">操作</span></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-neutral-100 dark:divide-neutral-700/60">
|
|
{{range .Apps}}
|
|
<tr>
|
|
<td class="px-3 py-3 font-medium">{{.Name}}</td>
|
|
<td class="px-3 py-3 font-mono text-xs break-all">{{.ClientID}}</td>
|
|
<td class="px-3 py-3 whitespace-nowrap">
|
|
{{if .Confidential}}
|
|
<span class="rounded-full bg-blue-500/10 px-2.5 py-0.5 text-xs font-medium text-blue-700 dark:text-blue-400">機密式</span>
|
|
{{else}}
|
|
<span class="rounded-full bg-violet-500/10 px-2.5 py-0.5 text-xs font-medium text-violet-700 dark:text-violet-400">公開式</span>
|
|
{{end}}
|
|
</td>
|
|
<td class="px-3 py-3 font-mono text-xs break-all whitespace-pre-line">{{.RedirectURIs}}</td>
|
|
<td class="px-3 py-3 text-xs">{{.GrantTypes}}</td>
|
|
<td class="px-3 py-3 font-mono text-xs break-all">{{.Scope}}</td>
|
|
<td class="px-3 py-3 whitespace-nowrap text-neutral-500 dark:text-neutral-400">{{.CreatedAt}}</td>
|
|
<td class="px-3 py-3">
|
|
<a href="/admin/applications/{{.ID}}" title="編輯註冊內容"
|
|
class="mb-1 block rounded-lg border border-neutral-300 px-3 py-1.5 text-center text-xs font-semibold hover:bg-neutral-100 dark:border-neutral-600 dark:hover:bg-neutral-700">編輯</a>
|
|
{{if .Confidential}}
|
|
<form method="post" action="/admin/applications/{{.ID}}/secret" class="mb-1">
|
|
<input type="hidden" name="csrf_token" value="{{$.CSRF}}">
|
|
<button type="submit" title="產生新 client secret(舊的立即失效)"
|
|
class="rounded-lg border border-neutral-300 px-3 py-1.5 text-xs font-semibold hover:bg-neutral-100 dark:border-neutral-600 dark:hover:bg-neutral-700">輪替 secret</button>
|
|
</form>
|
|
{{end}}
|
|
<form method="post" action="/admin/applications/{{.ID}}/delete">
|
|
<input type="hidden" name="csrf_token" value="{{$.CSRF}}">
|
|
<button type="submit" title="刪除後此應用程式無法再登入"
|
|
class="rounded-lg border border-red-300 px-3 py-1.5 text-xs font-semibold text-red-600 hover:bg-red-50 dark:border-red-500/60 dark:text-red-400 dark:hover:bg-red-500/10">刪除</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
{{end}}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{{else}}
|
|
<p class="py-6 text-sm text-neutral-500 dark:text-neutral-400">尚無應用程式,點選上方「註冊新應用程式」建立第一個。</p>
|
|
{{end}}
|
|
</section>
|
|
{{end}}
|