getStreamSecretStatus returns status for a streaming secret.
(w http.ResponseWriter, r *http.Request)
| 288 | |
| 289 | // getStreamSecretStatus returns status for a streaming secret. |
| 290 | func (y *Server) getStreamSecretStatus(w http.ResponseWriter, r *http.Request) { |
| 291 | w.Header().Set("Cache-Control", "private, no-cache") |
| 292 | w.Header().Set("Content-Type", "application/json") |
| 293 | |
| 294 | key := mux.Vars(r)["key"] |
| 295 | session, _ := y.getSession(r) |
| 296 | audit := y.newAuditor("file.status_checked", y.getRealClientIP(r), session) |
| 297 | audit.setSecretID(key) |
| 298 | |
| 299 | secret, err := y.DB.Status(streamKeyPrefix + key) |
| 300 | if err != nil { |
| 301 | y.Logger.Debug("Stream secret not found", zap.Error(err)) |
| 302 | audit.failure("not found") |
| 303 | jsonError(w, http.StatusNotFound, "Secret not found") |
| 304 | return |
| 305 | } |
| 306 | |
| 307 | audit.success(withOneTime(secret.OneTime), withRequireAuth(secret.RequireAuth)) |
| 308 | resp := map[string]bool{"oneTime": secret.OneTime, "requireAuth": secret.RequireAuth} |
| 309 | if err := json.NewEncoder(w).Encode(resp); err != nil { |
| 310 | y.Logger.Error("Failed to write status response", zap.Error(err)) |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | // isOpenPGPBinary reports whether b is a valid OpenPGP packet tag byte |
| 315 | // for the start of an encrypted message (PKESK tag 1 or SKESK tag 3). |