Skip to content

Commit

Permalink
Add Cache-Control: private, no-store HTTP header to server endpoint…
Browse files Browse the repository at this point in the history
…s that respond with sensitive info.

Fixes #793
  • Loading branch information
km274 committed Jul 20, 2023
1 parent d604a90 commit 2b8a417
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions authority/admin/api/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ func GetProvisioner(w http.ResponseWriter, r *http.Request) {
render.Error(w, err)
return
}

w.Header().Set("Cache-Control", "private, no-store")
render.ProtoJSON(w, prov)
}

Expand All @@ -72,6 +74,7 @@ func GetProvisioners(w http.ResponseWriter, r *http.Request) {
render.Error(w, errs.InternalServerErr(err))
return
}

render.JSON(w, &GetProvisionersResponse{
Provisioners: p,
NextCursor: next,
Expand Down Expand Up @@ -102,6 +105,8 @@ func CreateProvisioner(w http.ResponseWriter, r *http.Request) {
render.Error(w, admin.WrapErrorISE(err, "error storing provisioner %s", prov.Name))
return
}

w.Header().Set("Cache-Control", "private, no-store")
render.ProtoJSONStatus(w, prov, http.StatusCreated)
}

Expand Down Expand Up @@ -198,6 +203,8 @@ func UpdateProvisioner(w http.ResponseWriter, r *http.Request) {
render.Error(w, err)
return
}

w.Header().Set("Cache-Control", "private, no-store")
render.ProtoJSON(w, nu)
}

Expand Down
3 changes: 3 additions & 0 deletions authority/admin/api/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func (war *webhookAdminResponder) CreateProvisionerWebhook(w http.ResponseWriter
return
}

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

Expand Down Expand Up @@ -231,5 +232,7 @@ func (war *webhookAdminResponder) UpdateProvisionerWebhook(w http.ResponseWriter
Auth: newWebhook.Auth,
DisableTlsClientAuth: newWebhook.DisableTlsClientAuth,
}

w.Header().Set("Cache-Control", "private, no-store")
render.ProtoJSONStatus(w, whResponse, http.StatusCreated)
}

0 comments on commit 2b8a417

Please sign in to comment.