44 "context"
55 "encoding/json"
66 "fmt"
7+ "log/slog"
78 "net/http"
89 "time"
910
@@ -49,12 +50,17 @@ func handleConfigFactory(cfg *config.Config) func(http.ResponseWriter, *http.Req
4950 w .Header ().Set ("Content-Type" , "application/json" )
5051 // Rather than outputting the entire config,
5152 // customize the output to redact the client secret.
52- json .NewEncoder (w ).Encode (config.Config {
53+ err := json .NewEncoder (w ).Encode (config.Config {
5354 Mode : cfg .Mode ,
5455 Inbound : cfg .Inbound ,
5556 Outbound : cfg .Outbound ,
5657 Identity : config.IdentityConfig {
57- Type : cfg .Identity .Type ,
58+ Type : cfg .Identity .Type ,
59+ // We report the ClientID unredacted. In Kagenti, the ID will be something like
60+ // "spiffe://localtest.me/ns/team1/sa/my-weather-service-with-authbridge"
61+ // Although a brute force attack is possible, showing the ClientID here does
62+ // not introduce new security concerns, as an attacker can already construct
63+ // the ClientID from the pod's namespace and name, available in the UI.
5864 ClientID : cfg .Identity .ClientID ,
5965 ClientSecret : "*redacted*" ,
6066 ClientIDFile : "*redacted*" ,
@@ -68,13 +74,19 @@ func handleConfigFactory(cfg *config.Config) func(http.ResponseWriter, *http.Req
6874 Routes : cfg .Routes ,
6975 Stats : cfg .Stats ,
7076 })
77+ if err != nil {
78+ slog .Default ().Info ("Failed to send configuration" , "err" , err )
79+ }
7180 }
7281}
7382
7483func handleStatsFactory (stats * auth.Stats ) func (http.ResponseWriter , * http.Request ) {
7584 return func (w http.ResponseWriter , r * http.Request ) {
7685 w .Header ().Set ("Content-Type" , "application/json" )
77- json .NewEncoder (w ).Encode (stats )
86+ err := json .NewEncoder (w ).Encode (stats )
87+ if err != nil {
88+ slog .Default ().Info ("Failed to send stats" , "err" , err )
89+ }
7890 }
7991}
8092
0 commit comments