Skip to content

Commit e15db84

Browse files
committed
Add Cache-Control: private, no-store HTTP header to server endpoints that respond with sensitive info.
Fixes smallstep#793
1 parent d39a285 commit e15db84

File tree

5 files changed

+15
-0
lines changed

5 files changed

+15
-0
lines changed

acme/api/account.go

+2
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ func NewAccount(w http.ResponseWriter, r *http.Request) {
162162
linker.LinkAccount(ctx, acc)
163163

164164
w.Header().Set("Location", getAccountLocationPath(ctx, linker, acc.ID))
165+
w.Header().Set("Cache-Control", "private, no-store")
165166
render.JSONStatus(w, acc, httpStatus)
166167
}
167168

@@ -212,6 +213,7 @@ func GetOrUpdateAccount(w http.ResponseWriter, r *http.Request) {
212213
linker.LinkAccount(ctx, acc)
213214

214215
w.Header().Set("Location", linker.GetLink(ctx, acme.AccountLinkType, acc.ID))
216+
w.Header().Set("Cache-Control", "private, no-store")
215217
render.JSON(w, acc)
216218
}
217219

acme/api/handler.go

+2
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ func GetAuthorization(w http.ResponseWriter, r *http.Request) {
306306
linker.LinkAuthorization(ctx, az)
307307

308308
w.Header().Set("Location", linker.GetLink(ctx, acme.AuthzLinkType, az.ID))
309+
w.Header().Set("Cache-Control", "private, no-store")
309310
render.JSON(w, az)
310311
}
311312

@@ -359,6 +360,7 @@ func GetChallenge(w http.ResponseWriter, r *http.Request) {
359360

360361
w.Header().Add("Link", link(linker.GetLink(ctx, acme.AuthzLinkType, azID), "up"))
361362
w.Header().Set("Location", linker.GetLink(ctx, acme.ChallengeLinkType, azID, ch.ID))
363+
w.Header().Set("Cache-Control", "private, no-store")
362364
render.JSON(w, ch)
363365
}
364366

authority/admin/api/provisioner.go

+7
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ func GetProvisioner(w http.ResponseWriter, r *http.Request) {
5555
render.Error(w, err)
5656
return
5757
}
58+
59+
w.Header().Set("Cache-Control", "private, no-store")
5860
render.ProtoJSON(w, prov)
5961
}
6062

@@ -72,6 +74,7 @@ func GetProvisioners(w http.ResponseWriter, r *http.Request) {
7274
render.Error(w, errs.InternalServerErr(err))
7375
return
7476
}
77+
7578
render.JSON(w, &GetProvisionersResponse{
7679
Provisioners: p,
7780
NextCursor: next,
@@ -102,6 +105,8 @@ func CreateProvisioner(w http.ResponseWriter, r *http.Request) {
102105
render.Error(w, admin.WrapErrorISE(err, "error storing provisioner %s", prov.Name))
103106
return
104107
}
108+
109+
w.Header().Set("Cache-Control", "private, no-store")
105110
render.ProtoJSONStatus(w, prov, http.StatusCreated)
106111
}
107112

@@ -198,6 +203,8 @@ func UpdateProvisioner(w http.ResponseWriter, r *http.Request) {
198203
render.Error(w, err)
199204
return
200205
}
206+
207+
w.Header().Set("Cache-Control", "private, no-store")
201208
render.ProtoJSON(w, nu)
202209
}
203210

authority/admin/api/webhook.go

+3
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ func (war *webhookAdminResponder) CreateProvisionerWebhook(w http.ResponseWriter
127127
return
128128
}
129129

130+
w.Header().Set("Cache-Control", "private, no-store")
130131
render.ProtoJSONStatus(w, newWebhook, http.StatusCreated)
131132
}
132133

@@ -231,5 +232,7 @@ func (war *webhookAdminResponder) UpdateProvisionerWebhook(w http.ResponseWriter
231232
Auth: newWebhook.Auth,
232233
DisableTlsClientAuth: newWebhook.DisableTlsClientAuth,
233234
}
235+
236+
w.Header().Set("Cache-Control", "private, no-store")
234237
render.ProtoJSONStatus(w, whResponse, http.StatusCreated)
235238
}

scep/api/api.go

+1
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ func writeResponse(w http.ResponseWriter, res Response) {
359359
}
360360

361361
w.Header().Set("Content-Type", contentHeader(res))
362+
w.Header().Set("Cache-Control", "private, no-store")
362363
_, _ = w.Write(res.Data)
363364
}
364365

0 commit comments

Comments
 (0)