Files
crowdsec-dashy/web/templates/pages/allowlist.html
T

101 lines
3.3 KiB
HTML

{{template "base" .}}
{{define "content"}}
<div style="max-width:1400px">
<div style="margin-bottom:16px">
<div class="page-title">Allowlist</div>
<div class="page-sub">IPs and ranges exempt from CrowdSec decisions</div>
</div>
{{if .FetchErr}}
<div class="panel" style="margin-bottom:16px">
<div class="panel-body">
<div class="empty-text">Allowlist unavailable</div>
<div class="empty-sub">{{.FetchErr}}</div>
</div>
</div>
{{else}}
<div class="panel" style="margin-bottom:16px">
<div class="panel-header">
<span class="panel-title">Add Entry</span>
</div>
<div class="panel-body">
<form method="POST" action="/allowlist/add">
<input type="hidden" name="_csrf" value="{{.CSRFToken}}">
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:16px;margin-bottom:16px">
<div>
<label class="field-label">Allowlist Name</label>
<input class="field-input" type="text" name="list" placeholder="default" required>
</div>
<div>
<label class="field-label">Value (IP or CIDR)</label>
<input class="field-input" type="text" name="value" placeholder="1.2.3.4 or 1.2.3.0/24" required>
</div>
</div>
<div style="display:flex;justify-content:flex-end">
<button type="submit" class="btn-primary">Add to Allowlist</button>
</div>
</form>
</div>
</div>
{{if .Lists}}
{{range .Lists}}
<div class="panel" style="margin-bottom:16px">
<div class="panel-header">
<span class="panel-title">{{.Name}}</span>
{{if .Description}}<span style="font-size:12px;color:var(--muted)">{{.Description}}</span>{{end}}
</div>
{{if .Items}}
<table class="data-table">
<thead>
<tr>
<th>Value</th>
<th>Comment</th>
<th>Expiry</th>
<th>Action</th>
</tr>
</thead>
<tbody>
{{$listName := .Name}}
{{range .Items}}
<tr>
<td style="font-family:'JetBrains Mono',monospace;font-size:12px">{{.Value}}</td>
<td style="font-size:12px;color:var(--muted)">{{.Comment}}</td>
<td style="font-size:12px;color:var(--muted)">{{if .Expiry}}{{.Expiry}}{{else}}permanent{{end}}</td>
<td>
<form method="POST" action="/allowlist/remove" style="display:inline">
<input type="hidden" name="_csrf" value="{{$.CSRFToken}}">
<input type="hidden" name="list" value="{{$listName}}">
<input type="hidden" name="value" value="{{.Value}}">
<button type="submit" class="btn-danger-sm"
data-confirm="Remove {{.Value}} from allowlist?">Remove</button>
</form>
</td>
</tr>
{{end}}
</tbody>
</table>
{{else}}
<div class="empty-state">
<div class="empty-text">No entries in {{.Name}}</div>
</div>
{{end}}
</div>
{{end}}
{{else}}
<div class="panel">
<div class="empty-state">
<div class="empty-text">No allowlists found</div>
<div class="empty-sub">Create an allowlist with cscli allowlists create, then add entries above</div>
</div>
</div>
{{end}}
{{end}}
</div>
{{end}}
{{define "scripts"}}{{end}}