Skip to content

Agent Mesh

console: return users from /admin/status

Tomas Tormo71e6ac97c5f2
diff --git a/cmd/sam-console/public/app.js b/cmd/sam-console/public/app.js
index ef1a0e8d..c68e2c89 100644
--- a/cmd/sam-console/public/app.js
+++ b/cmd/sam-console/public/app.js
@@ -185,8 +185,8 @@ function renderUsersTable(users) {
<tr>
<td><code>${escapeHTML(user.ID)}</code></td>
<td>${escapeHTML(user.Role)}</td>
- <td>${escapeHTML(user.Name)}</td>
<td>${escapeHTML(user.Email)}</td>
+ <td>${new Date(user.CreatedAt).toLocaleString()}</td>
</tr>
`).join('');
}
diff --git a/cmd/sam-console/public/index.html b/cmd/sam-console/public/index.html
index 905624db..e07f364c 100644
--- a/cmd/sam-console/public/index.html
+++ b/cmd/sam-console/public/index.html
@@ -159,10 +159,10 @@
<table class="data-table">
<thead>
<tr>
- <th>ID</th>
<th>Subject (OIDC)</th>
- <th>Name</th>
+ <th>Role</th>
<th>Email</th>
+ <th>Created</th>
</tr>
</thead>
<tbody id="table-users">
diff --git a/internal/controlplane/server_test.go b/internal/controlplane/server_test.go
index 53fa7768..0ff0e7e4 100644
--- a/internal/controlplane/server_test.go
+++ b/internal/controlplane/server_test.go
@@ -970,6 +970,16 @@ func TestAdminPanelAndUI(t *testing.T) {
srv.config.AdminToken = "test-admin-pass"
+ testUser := &storage.User{
+ ID: "oidc-sub-123",
+ Email: "[email protected]",
+ Role: "user",
+ CreatedAt: time.Now(),
+ }
+ if err := store.SaveUser(context.Background(), testUser); err != nil {
+ t.Fatalf("failed to save test user: %v", err)
+ }
+
client := &http.Client{Timeout: 5 * time.Second}
// 1. Query /admin/status without token -> should fail with 401
@@ -1011,6 +1021,13 @@ func TestAdminPanelAndUI(t *testing.T) {
if _, ok := statusData["bootstrap_tokens"]; !ok {
t.Error("status response missing bootstrap_tokens")
}
+ users, ok := statusData["users"].([]any)
+ if !ok || len(users) != 1 {
+ t.Fatalf("expected 1 user in status response, got: %v", statusData["users"])
+ }
+ if got := users[0].(map[string]any)["ID"]; got != testUser.ID {
+ t.Errorf("expected user ID %q, got %v", testUser.ID, got)
+ }
// 3. Query /admin/ UI page -> should fail with 404 as it is removed
resp, err = client.Get(baseURL + "/admin/")
diff --git a/internal/controlplane/ui.go b/internal/controlplane/ui.go
index 2bee6887..ef3db0b7 100644
--- a/internal/controlplane/ui.go
+++ b/internal/controlplane/ui.go
@@ -62,6 +62,13 @@ func (s *Server) HandleAdminStatus(w http.ResponseWriter, r *http.Request) {
return
}
+ users, err := s.store.ListUsers(ctx)
+ if err != nil {
+ logger.Errorf("Failed to list users: %v", err)
+ http.Error(w, "Internal server error", http.StatusInternalServerError)
+ return
+ }
+
roles, bindings, err := s.store.GetMeshPolicy(r.Context())
if err != nil {
logger.Errorf("Failed to list policy: %v", err)
@@ -100,6 +107,7 @@ func (s *Server) HandleAdminStatus(w http.ResponseWriter, r *http.Request) {
}
resp := map[string]any{
+ "users": users,
"active_routers": routers,
"enrolled_nodes": nodes,
"enrollment_requests": reqs,