MCPcopy
hub / github.com/jhaals/yopass / getStreamSecretStatus

Method getStreamSecretStatus

pkg/server/server_stream.go:290–312  ·  view source on GitHub ↗

getStreamSecretStatus returns status for a streaming secret.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

288
289// getStreamSecretStatus returns status for a streaming secret.
290func (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).

Calls 11

getSessionMethod · 0.95
newAuditorMethod · 0.95
getRealClientIPMethod · 0.95
jsonErrorFunction · 0.85
withOneTimeFunction · 0.85
withRequireAuthFunction · 0.85
setSecretIDMethod · 0.80
failureMethod · 0.80
successMethod · 0.80
StatusMethod · 0.65
ErrorMethod · 0.45