Skip to content

Commit 4d3f79a

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

File tree

6 files changed

+18
-0
lines changed

6 files changed

+18
-0
lines changed

acme/api/account.go

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

api/api.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ func Provisioners(w http.ResponseWriter, r *http.Request) {
379379
return
380380
}
381381

382+
w.Header().Set("Cache-Control", "private, no-store")
382383
render.JSON(w, &ProvisionersResponse{
383384
Provisioners: p,
384385
NextCursor: next,
@@ -394,6 +395,7 @@ func ProvisionerKey(w http.ResponseWriter, r *http.Request) {
394395
return
395396
}
396397

398+
w.Header().Set("Cache-Control", "private, no-store")
397399
render.JSON(w, &ProvisionerKeyResponse{key})
398400
}
399401

authority/admin/api/provisioner.go

Lines changed: 8 additions & 0 deletions
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,8 @@ func GetProvisioners(w http.ResponseWriter, r *http.Request) {
7274
render.Error(w, errs.InternalServerErr(err))
7375
return
7476
}
77+
78+
w.Header().Set("Cache-Control", "private, no-store")
7579
render.JSON(w, &GetProvisionersResponse{
7680
Provisioners: p,
7781
NextCursor: next,
@@ -102,6 +106,8 @@ func CreateProvisioner(w http.ResponseWriter, r *http.Request) {
102106
render.Error(w, admin.WrapErrorISE(err, "error storing provisioner %s", prov.Name))
103107
return
104108
}
109+
110+
w.Header().Set("Cache-Control", "private, no-store")
105111
render.ProtoJSONStatus(w, prov, http.StatusCreated)
106112
}
107113

@@ -198,6 +204,8 @@ func UpdateProvisioner(w http.ResponseWriter, r *http.Request) {
198204
render.Error(w, err)
199205
return
200206
}
207+
208+
w.Header().Set("Cache-Control", "private, no-store")
201209
render.ProtoJSON(w, nu)
202210
}
203211

authority/admin/api/webhook.go

Lines changed: 3 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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)