Skip to content

Commit 8bcb0d8

Browse files
committed
fix: clean up inspect CA endpoint display and remove vestigial DefaultExpiration
Use key/value format for CA endpoint status in inspect output to match the style of other sections (agents, certificates). Remove unused DefaultExpiration field from discovery responses — it was plumbed through policy server and CA but never consumed.
1 parent 404b695 commit 8bcb0d8

6 files changed

Lines changed: 11 additions & 20 deletions

File tree

cmd/epithet/inspect.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@ func (i *AgentInspectCLI) Run(parent *AgentCLI, logger *slog.Logger) error {
8888
fmt.Printf(" (none)\n")
8989
} else {
9090
for _, ep := range resp.CaEndpoints {
91-
label := "healthy"
91+
status := "healthy"
9292
if ep.State == "open" || ep.State == "half-open" {
93-
label = "broken"
93+
status = "broken"
9494
}
95-
fmt.Printf(" %s (priority %d) — %s\n", ep.Url, ep.Priority, label)
95+
fmt.Printf(" %s\n", ep.Url)
96+
fmt.Printf(" Priority: %d\n", ep.Priority)
97+
fmt.Printf(" Status: %s\n", status)
9698
}
9799
}
98100
fmt.Println()

cmd/epithet/policy.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ func (c *PolicyServerCLI) Run(logger *slog.Logger, tlsCfg tlsconfig.Config) erro
131131
Auth: &authConfig,
132132
MatchPatterns: matchPatterns,
133133
}
134-
if c.DefaultExpiration != "" {
135-
discovery.DefaultExpiration = c.DefaultExpiration
136-
}
137134

138135
handler := policyserver.NewHandler(policyserver.Config{
139136
CAPublicKey: sshcert.RawPublicKey(caPubkey),

pkg/ca/ca.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,8 @@ type PolicyResponse struct {
179179

180180
// DiscoveryResponse is the discovery data fetched from the policy server.
181181
type DiscoveryResponse struct {
182-
Auth *BootstrapAuth `json:"auth"`
183-
MatchPatterns []string `json:"matchPatterns,omitempty"`
184-
DefaultExpiration string `json:"defaultExpiration,omitempty"`
182+
Auth *BootstrapAuth `json:"auth"`
183+
MatchPatterns []string `json:"matchPatterns,omitempty"`
185184

186185
// CacheControl is the Cache-Control header from the policy server response.
187186
// Not serialized to JSON — used by the CA server to pass through to clients.

pkg/caserver/caserver.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ func (s *caServer) DiscoveryHandler() http.Handler {
130130

131131
// Build response: always include auth, only include match patterns if authenticated.
132132
resp := &ca.DiscoveryResponse{
133-
Auth: discovery.Auth,
134-
DefaultExpiration: discovery.DefaultExpiration,
133+
Auth: discovery.Auth,
135134
}
136135
if authenticated {
137136
resp.MatchPatterns = discovery.MatchPatterns

pkg/policyserver/discovery_test.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ func TestHandler_GETDiscovery(t *testing.T) {
1717
ClientID: "test-client-id",
1818
Scopes: []string{"openid", "profile", "email"},
1919
},
20-
MatchPatterns: []string{"*.example.com", "prod-*"},
21-
DefaultExpiration: "5m",
20+
MatchPatterns: []string{"*.example.com", "prod-*"},
2221
}
2322

2423
handler := policyserver.NewHandler(policyserver.Config{
@@ -50,10 +49,6 @@ func TestHandler_GETDiscovery(t *testing.T) {
5049
if len(got.MatchPatterns) != 2 {
5150
t.Errorf("expected 2 match patterns, got %d", len(got.MatchPatterns))
5251
}
53-
if got.DefaultExpiration != "5m" {
54-
t.Errorf("expected default expiration '5m', got %q", got.DefaultExpiration)
55-
}
56-
5752
if ct := w.Header().Get("Content-Type"); ct != "application/json" {
5853
t.Errorf("expected Content-Type 'application/json', got %q", ct)
5954
}

pkg/policyserver/policyserver.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ type Response struct {
2929
// DiscoveryResponse is returned by GET / on the policy server.
3030
// The CA fetches this and serves it to clients on /discovery.
3131
type DiscoveryResponse struct {
32-
Auth *BootstrapAuth `json:"auth"`
33-
MatchPatterns []string `json:"matchPatterns,omitempty"`
34-
DefaultExpiration string `json:"defaultExpiration,omitempty"`
32+
Auth *BootstrapAuth `json:"auth"`
33+
MatchPatterns []string `json:"matchPatterns,omitempty"`
3534
}
3635

3736
// PolicyEvaluator makes authorization decisions based on identity and connection details.

0 commit comments

Comments
 (0)