Skip to content

Commit

Permalink
Add acls diagnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
NHAS committed May 8, 2024
1 parent e568142 commit 77735f1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
11 changes: 8 additions & 3 deletions ui/daignostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,16 @@ func aclsTest(w http.ResponseWriter, r *http.Request) {
return
}

acl := data.GetEffectiveAcl(username)
b, _ := json.MarshalIndent(acl, "", " ")
acl := ""
if username != "" {
b, _ := json.MarshalIndent(data.GetEffectiveAcl(username), "", " ")
acl = string(b)
}

d := struct {
Page
AclString string
Username string
}{
Page: Page{

Expand All @@ -167,7 +171,8 @@ func aclsTest(w http.ResponseWriter, r *http.Request) {
ServerID: serverID,
ClusterState: clusterState,
},
AclString: string(b),
AclString: acl,
Username: username,
}

renderDefaults(w, r, d, "diagnostics/acl_tester.html")
Expand Down
27 changes: 18 additions & 9 deletions ui/templates/diagnostics/acl_tester.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,24 @@ <h1 class="m-0 text-gray-900">User ACL</h6>
</p>
</div>
<div class="card-body">
<form action="/diag/acls" method="POST">
{{ csrfToken }}
<div class="form-row">
<div class="form-group">
<input type="text" class="form-control" name="username" id="username" placeholder="username">
</div>
<button type="submit" class="btn btn-primary">Check</button>
</form>
<pre>{{.AclString}}</pre>
<div class="row">
<div class="col">
<form class="form-inline" action="/diag/acls" method="POST">
{{ csrfToken }}
<div class="form-group mx-sm-3 mb-2">
<label for="username" class="sr-only">Username</label>
<input type="text" class="form-control" id="username" name="username" value="{{.Username}}"
placeholder="Username">
</div>
<button type="submit" class="btn btn-primary mb-2">Check</button>
</form>
</div>
</div>
<div class="row mt-4 ml-2">
<div class="col">
<pre>{{.AclString}}</pre>
</div>
</div>
</div>
</div>

Expand Down
1 change: 1 addition & 0 deletions ui/templates/menus.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
<h6 class="collapse-header">Tools:</h6>
<a class="collapse-item" href="/diag/firewall">Firewall State</a>
<a class="collapse-item" href="/diag/wg">Wireguard Peers</a>
<a class="collapse-item" href="/diag/acls">ACL Tester</a>
</div>
</div>
</li>
Expand Down

0 comments on commit 77735f1

Please sign in to comment.