registerUserSecretsAPI wires list/delete for a user's stored persistent secrets. The ciphertext is never returned (json:"-" on the model); only names + timestamps are surfaced. DELETE removes the stored statement so future sessions stop replaying it (and the next session-create wipe drops it from th
(r *gin.RouterGroup, store secretStore)
| 22 | // sessions stop replaying it (and the next session-create wipe drops it from |
| 23 | // the worker) — it does not reach into a live session. |
| 24 | func registerUserSecretsAPI(r *gin.RouterGroup, store secretStore) { |
| 25 | r.GET("/orgs/:id/users/:username/secrets", func(c *gin.Context) { |
| 26 | secrets, err := store.ListOrgUserSecrets(c.Param("id"), c.Param("username")) |
| 27 | if err != nil { |
| 28 | c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) |
| 29 | return |
| 30 | } |
| 31 | c.JSON(http.StatusOK, gin.H{"secrets": secrets}) |
| 32 | }) |
| 33 | |
| 34 | r.DELETE("/orgs/:id/users/:username/secrets/:name", func(c *gin.Context) { |
| 35 | deleted, err := store.DeleteOrgUserSecret(c.Param("id"), c.Param("username"), c.Param("name")) |
| 36 | if err != nil { |
| 37 | c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) |
| 38 | return |
| 39 | } |
| 40 | if !deleted { |
| 41 | c.JSON(http.StatusNotFound, gin.H{"error": "secret not found"}) |
| 42 | return |
| 43 | } |
| 44 | c.JSON(http.StatusOK, gin.H{"deleted": c.Param("name")}) |
| 45 | }) |
| 46 | } |
no test coverage detected