Add grpcserver test coverage
- Add comprehensive test file for internal/grpcserver package - Cover interceptors, system, engine, policy, and auth handlers - Cover pbToRule/ruleToPB conversion helpers - 37 tests total; CA/PKI/ACME and Login/Logout skipped (require live deps) Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
@@ -1,63 +1,85 @@
|
||||
{{define "title"}} - Dashboard{{end}}
|
||||
{{define "content"}}
|
||||
<h2>Dashboard</h2>
|
||||
<div class="status-bar">
|
||||
<span>Logged in as <strong>{{.Username}}</strong></span>
|
||||
{{if .IsAdmin}}<span class="badge">Admin</span>{{end}}
|
||||
<span>State: <strong>{{.State}}</strong></span>
|
||||
<span class="version">v{{.Version}}</span>
|
||||
<a href="/login" onclick="fetch('/v1/auth/logout',{method:'POST'})">Logout</a>
|
||||
<div class="page-header">
|
||||
<h2>Dashboard</h2>
|
||||
<div class="page-meta">
|
||||
<span class="state-chip state-{{.State}}">{{.State}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3>Engine Mounts</h3>
|
||||
{{if .Mounts}}
|
||||
<table>
|
||||
<thead><tr><th>Name</th><th>Type</th><th>Path</th></tr></thead>
|
||||
<tbody>
|
||||
{{range .Mounts}}
|
||||
<tr>
|
||||
<td>{{if eq (printf "%s" .Type) "ca"}}<a href="/pki">{{.Name}}</a>{{else}}{{.Name}}{{end}}</td>
|
||||
<td>{{.Type}}</td>
|
||||
<td>{{.MountPath}}</td>
|
||||
</tr>
|
||||
<div class="card">
|
||||
<div class="card-title">Engine Mounts</div>
|
||||
{{if .Mounts}}
|
||||
<div class="table-wrapper">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Path</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range .Mounts}}
|
||||
<tr>
|
||||
<td>
|
||||
{{if eq (printf "%s" .Type) "ca"}}
|
||||
<a href="/pki">{{.Name}}</a>
|
||||
{{else}}
|
||||
{{.Name}}
|
||||
{{end}}
|
||||
</td>
|
||||
<td><code>{{.Type}}</code></td>
|
||||
<td><code>{{.MountPath}}</code></td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{else}}
|
||||
<p>No engines mounted.</p>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{else}}
|
||||
<p>No engines mounted.</p>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
{{if .IsAdmin}}
|
||||
<h3>Mount CA Engine</h3>
|
||||
{{if .MountError}}<div class="error">{{.MountError}}</div>{{end}}
|
||||
<form method="post" action="/dashboard/mount-ca" enctype="multipart/form-data">
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="mount_name">Mount Name</label>
|
||||
<input type="text" id="mount_name" name="name" placeholder="pki" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="organization">Organization</label>
|
||||
<input type="text" id="organization" name="organization" placeholder="Metacircular">
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-title">Mount Engine</div>
|
||||
{{if .MountError}}<div class="error">{{.MountError}}</div>{{end}}
|
||||
<details>
|
||||
<summary>Import existing root CA (optional)</summary>
|
||||
<div class="form-group">
|
||||
<label for="cert_file">Certificate PEM file</label>
|
||||
<input type="file" id="cert_file" name="cert_file" accept=".pem,.crt">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="key_file">Private Key PEM file</label>
|
||||
<input type="file" id="key_file" name="key_file" accept=".pem,.key">
|
||||
</div>
|
||||
<summary>Mount a CA engine</summary>
|
||||
<form method="post" action="/dashboard/mount-ca" enctype="multipart/form-data">
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="mount_name">Mount Name</label>
|
||||
<input type="text" id="mount_name" name="name" placeholder="pki" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="organization">Organization</label>
|
||||
<input type="text" id="organization" name="organization" placeholder="Metacircular">
|
||||
</div>
|
||||
</div>
|
||||
<details>
|
||||
<summary>Import existing root CA (optional)</summary>
|
||||
<div class="form-group">
|
||||
<label for="cert_file">Certificate PEM</label>
|
||||
<input type="file" id="cert_file" name="cert_file" accept=".pem,.crt">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="key_file">Private Key PEM</label>
|
||||
<input type="file" id="key_file" name="key_file" accept=".pem,.key">
|
||||
</div>
|
||||
</details>
|
||||
<div class="form-actions">
|
||||
<button type="submit">Mount</button>
|
||||
</div>
|
||||
</form>
|
||||
</details>
|
||||
<button type="submit">Mount</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<h3>Admin Actions</h3>
|
||||
<div class="admin-actions">
|
||||
<button hx-post="/v1/seal" hx-confirm="Are you sure you want to seal the service?">Seal Service</button>
|
||||
<div class="card">
|
||||
<div class="card-title">Administration</div>
|
||||
<p>Sealing the service will require the seal password to restore access.</p>
|
||||
<button class="btn-danger" hx-post="/v1/seal" hx-confirm="Are you sure you want to seal the service?">Seal Service</button>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
{{define "title"}} - Initialize{{end}}
|
||||
{{define "container-class"}}auth-container{{end}}
|
||||
{{define "content"}}
|
||||
<h2>Initialize Metacrypt</h2>
|
||||
<p>Set the seal password for this Metacrypt instance. This password will be required to unseal the service after each restart.</p>
|
||||
{{if .Error}}<div class="error">{{.Error}}</div>{{end}}
|
||||
<form method="POST" action="/init">
|
||||
<div class="form-group">
|
||||
<label for="password">Seal Password</label>
|
||||
<input type="password" id="password" name="password" required autofocus>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="confirm">Confirm Password</label>
|
||||
<input type="password" id="confirm" name="confirm" required>
|
||||
</div>
|
||||
<button type="submit">Initialize</button>
|
||||
</form>
|
||||
<div class="auth-header">
|
||||
<div class="brand">Metacrypt</div>
|
||||
<div class="tagline">Cryptographic Services</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-title">Initialize</div>
|
||||
<p>Set the seal password for this instance. This password will be required to unseal the service after each restart.</p>
|
||||
{{if .Error}}<div class="error">{{.Error}}</div>{{end}}
|
||||
<form method="POST" action="/init">
|
||||
<div class="form-group">
|
||||
<label for="password">Seal Password</label>
|
||||
<input type="password" id="password" name="password" required autofocus autocomplete="new-password">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="confirm">Confirm Password</label>
|
||||
<input type="password" id="confirm" name="confirm" required autocomplete="new-password">
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<button type="submit">Initialize</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
{{define "title"}} - Initializing{{end}}
|
||||
{{define "container-class"}}auth-container{{end}}
|
||||
{{define "content"}}
|
||||
<h2>Initializing...</h2>
|
||||
<p>Metacrypt is being initialized. Please wait.</p>
|
||||
<div hx-get="/v1/status" hx-trigger="every 2s" hx-swap="none"
|
||||
hx-on::after-request="if(JSON.parse(event.detail.xhr.responseText).state==='unsealed')window.location='/dashboard'">
|
||||
<p>Checking status...</p>
|
||||
<div class="auth-header">
|
||||
<div class="brand">Metacrypt</div>
|
||||
<div class="tagline">Cryptographic Services</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-title">Initializing</div>
|
||||
<p>Metacrypt is being initialized. This will only take a moment.</p>
|
||||
<div hx-get="/v1/status" hx-trigger="every 2s" hx-swap="none"
|
||||
hx-on::after-request="if(JSON.parse(event.detail.xhr.responseText).state==='unsealed')window.location='/dashboard'">
|
||||
<p style="color: var(--f2); font-size: 0.875rem;">Waiting for service to come online…</p>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
@@ -1,60 +1,63 @@
|
||||
{{define "title"}} - Issuer: {{.IssuerName}}{{end}}
|
||||
{{define "content"}}
|
||||
<h2>Issuer: {{.IssuerName}}</h2>
|
||||
|
||||
<p>
|
||||
<a href="/pki">← PKI: {{.MountName}}</a>
|
||||
—
|
||||
<a href="/pki/{{.IssuerName}}" download="{{.IssuerName}}.pem">Download Issuer Cert (PEM)</a>
|
||||
</p>
|
||||
|
||||
<h3>Certificates</h3>
|
||||
|
||||
<form method="get" action="/pki/issuer/{{.IssuerName}}" style="margin-bottom: 1rem;">
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="name_filter">Filter by name</label>
|
||||
<input type="text" id="name_filter" name="name" value="{{.NameFilter}}" placeholder="common name contains...">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="sort_by">Sort by</label>
|
||||
<select id="sort_by" name="sort">
|
||||
<option value="cn"{{if eq .SortBy "cn"}} selected{{end}}>Common Name</option>
|
||||
<option value="expiry"{{if eq .SortBy "expiry"}} selected{{end}}>Expiry Date</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" style="align-self: flex-end;">
|
||||
<button type="submit">Apply</button>
|
||||
</div>
|
||||
<div class="page-header">
|
||||
<h2>Issuer: {{.IssuerName}}</h2>
|
||||
<div class="page-meta">
|
||||
<a href="/pki">← PKI: {{.MountName}}</a>
|
||||
 · 
|
||||
<a href="/pki/{{.IssuerName}}" download="{{.IssuerName}}.pem">Download Issuer Cert (PEM)</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{{if .Certs}}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Common Name</th>
|
||||
<th>Profile</th>
|
||||
<th>Serial</th>
|
||||
<th>Issued By</th>
|
||||
<th>Issued At</th>
|
||||
<th>Expires At</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range .Certs}}
|
||||
<tr>
|
||||
<td>{{index . "cn"}}</td>
|
||||
<td>{{index . "profile"}}</td>
|
||||
<td><code>{{index . "serial"}}</code></td>
|
||||
<td>{{index . "issued_by"}}</td>
|
||||
<td>{{index . "issued_at"}}</td>
|
||||
<td>{{index . "expires_at"}}</td>
|
||||
</tr>
|
||||
<div class="card">
|
||||
<div class="card-title">Certificates</div>
|
||||
<form method="get" action="/pki/issuer/{{.IssuerName}}">
|
||||
<div class="form-row" style="align-items: flex-end; margin-bottom: 1rem;">
|
||||
<div class="form-group" style="margin-bottom: 0;">
|
||||
<label for="name_filter">Filter by name</label>
|
||||
<input type="text" id="name_filter" name="name" value="{{.NameFilter}}" placeholder="common name contains…">
|
||||
</div>
|
||||
<div class="form-group" style="margin-bottom: 0;">
|
||||
<label for="sort_by">Sort by</label>
|
||||
<select id="sort_by" name="sort">
|
||||
<option value="cn"{{if eq .SortBy "cn"}} selected{{end}}>Common Name</option>
|
||||
<option value="expiry"{{if eq .SortBy "expiry"}} selected{{end}}>Expiry Date</option>
|
||||
</select>
|
||||
</div>
|
||||
<div style="flex-shrink: 0; padding-bottom: 1px;">
|
||||
<button type="submit">Apply</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{{if .Certs}}
|
||||
<div class="table-wrapper">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Common Name</th>
|
||||
<th>Profile</th>
|
||||
<th>Serial</th>
|
||||
<th>Issued By</th>
|
||||
<th>Issued At</th>
|
||||
<th>Expires At</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range .Certs}}
|
||||
<tr>
|
||||
<td>{{index . "cn"}}</td>
|
||||
<td>{{index . "profile"}}</td>
|
||||
<td><code>{{index . "serial"}}</code></td>
|
||||
<td>{{index . "issued_by"}}</td>
|
||||
<td>{{index . "issued_at"}}</td>
|
||||
<td>{{index . "expires_at"}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{else}}
|
||||
<p>No certificates found{{if .NameFilter}} matching “{{.NameFilter}}”{{end}}.</p>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{else}}
|
||||
<p>No certificates found{{if .NameFilter}} matching “{{.NameFilter}}”{{end}}.</p>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
@@ -8,13 +8,18 @@
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<header>
|
||||
<h1><a href="/">Metacrypt</a></h1>
|
||||
</header>
|
||||
<main>
|
||||
{{template "content" .}}
|
||||
</main>
|
||||
<nav class="topnav">
|
||||
<a class="topnav-brand" href="/">Metacrypt</a>
|
||||
<div class="topnav-right">
|
||||
{{if .Username}}
|
||||
<span class="topnav-user">{{.Username}}</span>
|
||||
{{if .IsAdmin}}<span class="badge">admin</span>{{end}}
|
||||
<a href="/login" class="btn btn-ghost btn-sm" onclick="fetch('/v1/auth/logout',{method:'POST'})">Logout</a>
|
||||
{{end}}
|
||||
</div>
|
||||
</nav>
|
||||
<div class="{{block "container-class" .}}page-container{{end}}">
|
||||
{{template "content" .}}
|
||||
</div>
|
||||
</body>
|
||||
</html>{{end}}
|
||||
|
||||
@@ -1,21 +1,30 @@
|
||||
{{define "title"}} - Login{{end}}
|
||||
{{define "container-class"}}auth-container{{end}}
|
||||
{{define "content"}}
|
||||
<h2>Login</h2>
|
||||
<p>Authenticate with your MCIAS credentials.</p>
|
||||
{{if .Error}}<div class="error">{{.Error}}</div>{{end}}
|
||||
<form method="POST" action="/login">
|
||||
<div class="form-group">
|
||||
<label for="username">Username</label>
|
||||
<input type="text" id="username" name="username" required autofocus>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Password</label>
|
||||
<input type="password" id="password" name="password" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="totp_code">TOTP Code (if enabled)</label>
|
||||
<input type="text" id="totp_code" name="totp_code" autocomplete="one-time-code">
|
||||
</div>
|
||||
<button type="submit">Login</button>
|
||||
</form>
|
||||
<div class="auth-header">
|
||||
<div class="brand">Metacrypt</div>
|
||||
<div class="tagline">Cryptographic Services</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-title">Sign In</div>
|
||||
<p>Authenticate with your MCIAS credentials.</p>
|
||||
{{if .Error}}<div class="error">{{.Error}}</div>{{end}}
|
||||
<form method="POST" action="/login">
|
||||
<div class="form-group">
|
||||
<label for="username">Username</label>
|
||||
<input type="text" id="username" name="username" required autofocus autocomplete="username">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Password</label>
|
||||
<input type="password" id="password" name="password" required autocomplete="current-password">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="totp_code">TOTP Code <small style="text-transform:none;letter-spacing:0;">(if enabled)</small></label>
|
||||
<input type="text" id="totp_code" name="totp_code" autocomplete="one-time-code" inputmode="numeric">
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<button type="submit">Login</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
@@ -1,82 +1,115 @@
|
||||
{{define "title"}} - PKI: {{.MountName}}{{end}}
|
||||
{{define "content"}}
|
||||
<h2>PKI Engine: {{.MountName}}</h2>
|
||||
<div class="page-header">
|
||||
<h2>PKI: {{.MountName}}</h2>
|
||||
<div class="page-meta">
|
||||
<a href="/dashboard">← Dashboard</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p><a href="/dashboard">← Dashboard</a></p>
|
||||
{{if .Error}}<div class="error">{{.Error}}</div>{{end}}
|
||||
|
||||
{{if .Error}}
|
||||
<div class="error">{{.Error}}</div>
|
||||
{{end}}
|
||||
|
||||
<h3>Root CA</h3>
|
||||
{{if .HasRoot}}
|
||||
<table>
|
||||
<tr><th>Common Name</th><td>{{.RootCN}}</td></tr>
|
||||
<tr><th>Organization</th><td>{{.RootOrg}}</td></tr>
|
||||
<tr><th>Valid From</th><td>{{.RootNotBefore}}</td></tr>
|
||||
<tr>
|
||||
<th>Valid Until</th>
|
||||
<td>
|
||||
{{.RootNotAfter}}
|
||||
{{if .RootExpired}} <span class="badge badge-danger">Expired</span>{{end}}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p style="margin-top: 0.5rem;">
|
||||
<a href="/v1/pki/{{.MountName}}/ca" download="root-ca.pem">Download Root CA (PEM)</a>
|
||||
</p>
|
||||
{{else}}
|
||||
<p>No root CA configured.</p>
|
||||
{{end}}
|
||||
<div class="card">
|
||||
<div class="card-title">Root CA</div>
|
||||
{{if .HasRoot}}
|
||||
<table class="kv-table">
|
||||
<tbody>
|
||||
<tr><th>Common Name</th><td>{{.RootCN}}</td></tr>
|
||||
<tr><th>Organization</th><td>{{.RootOrg}}</td></tr>
|
||||
<tr><th>Valid From</th><td>{{.RootNotBefore}}</td></tr>
|
||||
<tr>
|
||||
<th>Valid Until</th>
|
||||
<td>
|
||||
{{.RootNotAfter}}
|
||||
{{if .RootExpired}} <span class="badge badge-danger">Expired</span>{{end}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p style="margin-top: 1rem; margin-bottom: 0;">
|
||||
<a href="/v1/pki/{{.MountName}}/ca" download="root-ca.pem">Download Root CA (PEM)</a>
|
||||
</p>
|
||||
{{else}}
|
||||
<p>No root CA configured.</p>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
{{if .IsAdmin}}
|
||||
{{if or (not .HasRoot) .RootExpired}}
|
||||
<h3>Import Root CA</h3>
|
||||
<p>{{if .RootExpired}}The current root CA has expired. Import a new one.{{else}}No root CA is present. Import one to get started.{{end}}</p>
|
||||
<form method="post" action="/pki/import-root" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
<label for="cert_file">Certificate PEM</label>
|
||||
<input type="file" id="cert_file" name="cert_file" accept=".pem,.crt">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="cert_pem">Or paste certificate PEM</label>
|
||||
<textarea id="cert_pem" name="cert_pem" rows="6" class="pem-input" placeholder="-----BEGIN CERTIFICATE-----"></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="key_file">Private Key PEM</label>
|
||||
<input type="file" id="key_file" name="key_file" accept=".pem,.key">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="key_pem">Or paste private key PEM</label>
|
||||
<textarea id="key_pem" name="key_pem" rows="6" class="pem-input" placeholder="-----BEGIN PRIVATE KEY-----"></textarea>
|
||||
</div>
|
||||
<button type="submit">Import Root CA</button>
|
||||
</form>
|
||||
<div class="card">
|
||||
<div class="card-title">Import Root CA</div>
|
||||
<p>{{if .RootExpired}}The current root CA has expired. Import a new one to continue issuing certificates.{{else}}No root CA is present. Import one to get started.{{end}}</p>
|
||||
<form method="post" action="/pki/import-root" enctype="multipart/form-data">
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="cert_file">Certificate PEM file</label>
|
||||
<input type="file" id="cert_file" name="cert_file" accept=".pem,.crt">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="key_file">Private Key PEM file</label>
|
||||
<input type="file" id="key_file" name="key_file" accept=".pem,.key">
|
||||
</div>
|
||||
</div>
|
||||
<details>
|
||||
<summary>Or paste PEM directly</summary>
|
||||
<div class="form-group">
|
||||
<label for="cert_pem">Certificate PEM</label>
|
||||
<textarea id="cert_pem" name="cert_pem" rows="6" class="pem-input" placeholder="-----BEGIN CERTIFICATE-----"></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="key_pem">Private Key PEM</label>
|
||||
<textarea id="key_pem" name="key_pem" rows="6" class="pem-input" placeholder="-----BEGIN PRIVATE KEY-----"></textarea>
|
||||
</div>
|
||||
</details>
|
||||
<div class="form-actions">
|
||||
<button type="submit">Import Root CA</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
<h3>Issuers</h3>
|
||||
{{if .Issuers}}
|
||||
<table>
|
||||
<thead><tr><th>Name</th><th>Actions</th></tr></thead>
|
||||
<tbody>
|
||||
{{range .Issuers}}
|
||||
<tr>
|
||||
<td><a href="/pki/issuer/{{.}}">{{.}}</a></td>
|
||||
<td><a href="/pki/{{.}}" download="{{.}}.pem">Download Cert (PEM)</a></td>
|
||||
</tr>
|
||||
<div class="card">
|
||||
<div class="card-title">Issuers</div>
|
||||
{{if .Issuers}}
|
||||
<div class="table-wrapper">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range .Issuers}}
|
||||
<tr>
|
||||
<td><a href="/pki/issuer/{{.}}">{{.}}</a></td>
|
||||
<td><a href="/pki/{{.}}" download="{{.}}.pem">Download Cert (PEM)</a></td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{else}}
|
||||
<p>No issuers configured.</p>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{else}}
|
||||
<p>No issuers configured.</p>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
{{if and .HasRoot .Issuers}}
|
||||
<h3>Issue Certificate</h3>
|
||||
{{if .IssuedCert}}
|
||||
<div class="success">
|
||||
<p>Certificate issued successfully.</p>
|
||||
<div class="card">
|
||||
<div class="card-title">Issue Certificate</div>
|
||||
{{if .IssuedCert}}
|
||||
<div class="success">
|
||||
<p><strong>Certificate issued successfully.</strong></p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Serial</label>
|
||||
<input type="text" class="pem-input" value="{{index .IssuedCert "serial"}}" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Expires</label>
|
||||
<input type="text" value="{{index .IssuedCert "expires_at"}}" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Certificate PEM</label>
|
||||
<textarea rows="8" class="pem-input" readonly>{{index .IssuedCert "cert_pem"}}</textarea>
|
||||
@@ -89,89 +122,122 @@
|
||||
<label>Chain PEM</label>
|
||||
<textarea rows="8" class="pem-input" readonly>{{index .IssuedCert "chain_pem"}}</textarea>
|
||||
</div>
|
||||
<p><small>Serial: {{index .IssuedCert "serial"}} — Expires: {{index .IssuedCert "expires_at"}}</small></p>
|
||||
</div>
|
||||
{{else}}
|
||||
<form method="post" action="/pki/issue">
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="issue_cn">Common Name</label>
|
||||
<input type="text" id="issue_cn" name="common_name" placeholder="example.com" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="issue_issuer">Issuer</label>
|
||||
<select id="issue_issuer" name="issuer" required>
|
||||
<option value="">-- select issuer --</option>
|
||||
{{range .Issuers}}<option value="{{.}}">{{.}}</option>{{end}}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="issue_profile">Profile</label>
|
||||
<select id="issue_profile" name="profile">
|
||||
<option value="server">server (default)</option>
|
||||
<option value="client">client</option>
|
||||
<option value="peer">peer</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="issue_ttl">TTL (optional)</label>
|
||||
<input type="text" id="issue_ttl" name="ttl" placeholder="2160h">
|
||||
</div>
|
||||
</div>
|
||||
<details>
|
||||
<summary>SANs</summary>
|
||||
{{else}}
|
||||
<form method="post" action="/pki/issue">
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="issue_dns">DNS Names (one per line)</label>
|
||||
<textarea id="issue_dns" name="dns_names" rows="3" placeholder="example.com www.example.com"></textarea>
|
||||
<label for="issue_cn">Common Name</label>
|
||||
<input type="text" id="issue_cn" name="common_name" placeholder="example.com" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="issue_ips">IP Addresses (one per line)</label>
|
||||
<textarea id="issue_ips" name="ip_addresses" rows="3" placeholder="10.0.0.1"></textarea>
|
||||
<label for="issue_issuer">Issuer</label>
|
||||
<select id="issue_issuer" name="issuer" required>
|
||||
<option value="">— select issuer —</option>
|
||||
{{range .Issuers}}<option value="{{.}}">{{.}}</option>{{end}}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
<button type="submit">Issue Certificate</button>
|
||||
</form>
|
||||
{{end}}
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="issue_profile">Profile</label>
|
||||
<select id="issue_profile" name="profile">
|
||||
<option value="server">server (default)</option>
|
||||
<option value="client">client</option>
|
||||
<option value="peer">peer</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="issue_ttl">TTL <small style="text-transform:none;letter-spacing:0;">(optional)</small></label>
|
||||
<input type="text" id="issue_ttl" name="ttl" placeholder="2160h">
|
||||
</div>
|
||||
</div>
|
||||
<details>
|
||||
<summary>Subject Alternative Names</summary>
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="issue_dns">DNS Names <small style="text-transform:none;letter-spacing:0;">(one per line)</small></label>
|
||||
<textarea id="issue_dns" name="dns_names" rows="3" placeholder="example.com www.example.com"></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="issue_ips">IP Addresses <small style="text-transform:none;letter-spacing:0;">(one per line)</small></label>
|
||||
<textarea id="issue_ips" name="ip_addresses" rows="3" placeholder="10.0.0.1"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
<details open>
|
||||
<summary>Key Usages</summary>
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label>Key Usages</label>
|
||||
<div class="checkbox-group">
|
||||
<label class="checkbox-label"><input type="checkbox" name="key_usages" value="digital signature"> Digital Signature</label>
|
||||
<label class="checkbox-label"><input type="checkbox" name="key_usages" value="key encipherment"> Key Encipherment</label>
|
||||
<label class="checkbox-label"><input type="checkbox" name="key_usages" value="content commitment"> Content Commitment</label>
|
||||
<label class="checkbox-label"><input type="checkbox" name="key_usages" value="data encipherment"> Data Encipherment</label>
|
||||
<label class="checkbox-label"><input type="checkbox" name="key_usages" value="key agreement"> Key Agreement</label>
|
||||
<label class="checkbox-label"><input type="checkbox" name="key_usages" value="cert sign"> Cert Sign</label>
|
||||
<label class="checkbox-label"><input type="checkbox" name="key_usages" value="crl sign"> CRL Sign</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Extended Key Usages</label>
|
||||
<div class="checkbox-group">
|
||||
<label class="checkbox-label"><input type="checkbox" name="ext_key_usages" value="server auth"> Server Auth</label>
|
||||
<label class="checkbox-label"><input type="checkbox" name="ext_key_usages" value="client auth"> Client Auth</label>
|
||||
<label class="checkbox-label"><input type="checkbox" name="ext_key_usages" value="code signing"> Code Signing</label>
|
||||
<label class="checkbox-label"><input type="checkbox" name="ext_key_usages" value="email protection"> Email Protection</label>
|
||||
<label class="checkbox-label"><input type="checkbox" name="ext_key_usages" value="time stamping"> Time Stamping</label>
|
||||
<label class="checkbox-label"><input type="checkbox" name="ext_key_usages" value="ocsp signing"> OCSP Signing</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
<div class="form-actions">
|
||||
<button type="submit">Issue Certificate</button>
|
||||
</div>
|
||||
</form>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{if .IsAdmin}}
|
||||
{{if .HasRoot}}
|
||||
<h3>Create Issuer</h3>
|
||||
{{if .IssuerError}}<div class="error">{{.IssuerError}}</div>{{end}}
|
||||
<form method="post" action="/pki/create-issuer">
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="issuer_name">Issuer Name</label>
|
||||
<input type="text" id="issuer_name" name="name" placeholder="default" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="issuer_expiry">Expiry</label>
|
||||
<input type="text" id="issuer_expiry" name="expiry" placeholder="26280h (3 years)">
|
||||
</div>
|
||||
</div>
|
||||
<details>
|
||||
<summary>Advanced options</summary>
|
||||
<div class="card">
|
||||
<div class="card-title">Create Issuer</div>
|
||||
{{if .IssuerError}}<div class="error">{{.IssuerError}}</div>{{end}}
|
||||
<form method="post" action="/pki/create-issuer">
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="issuer_key_alg">Key Algorithm</label>
|
||||
<input type="text" id="issuer_key_alg" name="key_algorithm" placeholder="ecdsa (default)">
|
||||
<label for="issuer_name">Issuer Name</label>
|
||||
<input type="text" id="issuer_name" name="name" placeholder="default" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="issuer_key_size">Key Size</label>
|
||||
<input type="text" id="issuer_key_size" name="key_size" placeholder="521 (default)">
|
||||
<label for="issuer_expiry">Expiry</label>
|
||||
<input type="text" id="issuer_expiry" name="expiry" placeholder="26280h (3 years)">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="issuer_max_ttl">Max Leaf TTL</label>
|
||||
<input type="text" id="issuer_max_ttl" name="max_ttl" placeholder="2160h (90 days)">
|
||||
<details>
|
||||
<summary>Advanced options</summary>
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="issuer_key_alg">Key Algorithm</label>
|
||||
<input type="text" id="issuer_key_alg" name="key_algorithm" placeholder="ecdsa (default)">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="issuer_key_size">Key Size</label>
|
||||
<input type="text" id="issuer_key_size" name="key_size" placeholder="521 (default)">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="issuer_max_ttl">Max Leaf TTL</label>
|
||||
<input type="text" id="issuer_max_ttl" name="max_ttl" placeholder="2160h (90 days)">
|
||||
</div>
|
||||
</details>
|
||||
<div class="form-actions">
|
||||
<button type="submit">Create Issuer</button>
|
||||
</div>
|
||||
</details>
|
||||
<button type="submit">Create Issuer</button>
|
||||
</form>
|
||||
</form>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
{{define "title"}} - Unseal{{end}}
|
||||
{{define "container-class"}}auth-container{{end}}
|
||||
{{define "content"}}
|
||||
<h2>Unseal Metacrypt</h2>
|
||||
<p>The service is sealed. Enter the seal password to unseal.</p>
|
||||
{{if .Error}}<div class="error">{{.Error}}</div>{{end}}
|
||||
<form method="POST" action="/unseal">
|
||||
<div class="form-group">
|
||||
<label for="password">Seal Password</label>
|
||||
<input type="password" id="password" name="password" required autofocus>
|
||||
</div>
|
||||
<button type="submit">Unseal</button>
|
||||
</form>
|
||||
<div class="auth-header">
|
||||
<div class="brand">Metacrypt</div>
|
||||
<div class="tagline">Cryptographic Services</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-title">Unseal</div>
|
||||
<p>The service is sealed. Enter the seal password to restore access.</p>
|
||||
{{if .Error}}<div class="error">{{.Error}}</div>{{end}}
|
||||
<form method="POST" action="/unseal">
|
||||
<div class="form-group">
|
||||
<label for="password">Seal Password</label>
|
||||
<input type="password" id="password" name="password" required autofocus autocomplete="current-password">
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<button type="submit">Unseal</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
Reference in New Issue
Block a user