Skip to content

Commit

Permalink
added listing all secrets endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>
  • Loading branch information
Skarlso committed Jun 19, 2024
1 parent 61d9864 commit 659fe4c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/release_notes/v0.1.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Release v0.1.3

Added listing all secrets endpoint.
21 changes: 21 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func (s *Server) Run(_ context.Context) error {

// The header will always contain the right credentials.
warden.Get("/secret", s.getSecretHandler)
warden.Get("/secrets", s.listSecretsHandler)
warden.Delete("/secret", s.deleteSecretHandler)
warden.Post("/secret", s.createSecretHandler)

Expand Down Expand Up @@ -109,6 +110,26 @@ func (s *Server) getSecretHandler(w http.ResponseWriter, r *http.Request) {
s.handleResponse(secretResponse, w)
}

func (s *Server) listSecretsHandler(w http.ResponseWriter, r *http.Request) {
request := &sdk.SecretIdentifiersRequest{}
c, err := s.getClient(r, &request)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)

return
}
defer c.Close()

secretResponse, err := c.Secrets().List(request.OrganizationID)
if err != nil {
http.Error(w, "failed to get secret: "+err.Error(), http.StatusBadRequest)

return
}

s.handleResponse(secretResponse, w)
}

func (s *Server) deleteSecretHandler(w http.ResponseWriter, r *http.Request) {
request := &sdk.SecretsDeleteRequest{}
c, err := s.getClient(r, &request)
Expand Down

0 comments on commit 659fe4c

Please sign in to comment.