{{define "title"}} - SSH Certificate: {{.Cert.Serial}}{{end}}
{{define "content"}}
<div class="page-header">
    <h2>SSH Certificate: <code>{{.Cert.Serial}}</code></h2>
    <div class="page-meta">
        <a href="/sshca">&larr; SSH CA</a>
    </div>
</div>

<div class="card">
    <div class="card-title">Details</div>
    <table class="kv-table">
        <tbody>
            <tr><th>Serial</th><td><code>{{.Cert.Serial}}</code></td></tr>
            <tr><th>Type</th><td>{{.Cert.CertType}}</td></tr>
            <tr><th>Key ID</th><td>{{.Cert.KeyID}}</td></tr>
            <tr><th>Principals</th><td>{{range .Cert.Principals}}<code>{{.}}</code> {{end}}</td></tr>
            <tr><th>Profile</th><td>{{if .Cert.Profile}}<a href="/sshca/profile/{{.Cert.Profile}}">{{.Cert.Profile}}</a>{{else}}&mdash;{{end}}</td></tr>
            <tr><th>Issued By</th><td>{{.Cert.IssuedBy}}</td></tr>
            <tr><th>Issued At</th><td>{{.Cert.IssuedAt}}</td></tr>
            <tr><th>Expires At</th><td>{{.Cert.ExpiresAt}}</td></tr>
            <tr>
                <th>Revoked</th>
                <td>
                    {{if .Cert.Revoked}}
                    <span class="badge badge-danger">Revoked</span>
                    {{if .Cert.RevokedAt}} at {{.Cert.RevokedAt}}{{end}}
                    {{if .Cert.RevokedBy}} by {{.Cert.RevokedBy}}{{end}}
                    {{else}}
                    No
                    {{end}}
                </td>
            </tr>
        </tbody>
    </table>
</div>

{{if .Cert.CertData}}
<div class="card">
    <div class="card-title">Certificate</div>
    <textarea rows="6" class="pem-input" readonly>{{.Cert.CertData}}</textarea>
</div>
{{end}}

{{if .IsAdmin}}
<div class="card">
    <div class="card-title">Admin Actions</div>
    {{if not .Cert.Revoked}}
    <form method="post" action="/sshca/cert/{{.Cert.Serial}}/revoke" style="display:inline;">
        {{csrfField}}
        <button type="submit" class="btn-danger" onclick="return confirm('Revoke certificate {{.Cert.Serial}}?')">Revoke</button>
    </form>
    {{end}}
    <form method="post" action="/sshca/cert/{{.Cert.Serial}}/delete" style="display:inline; margin-left: 0.5rem;">
        {{csrfField}}
        <button type="submit" class="btn-danger" onclick="return confirm('Permanently delete certificate {{.Cert.Serial}}?')">Delete</button>
    </form>
</div>
{{end}}
{{end}}
