serokell / coffer

Multi-backend password store with multiple frontends
4 stars 2 forks source link

/create endpoint: accept an "entry object" instead of a 2-element array #86

Closed dcastro closed 2 years ago

dcastro commented 2 years ago

This issue is blocked by https://github.com/serokell/coffer/pull/37.

Clarification and motivation

Right now the /create endpoint takes a json object with a 2-element array. The 1st element is a json object containing public fields, and the 2nd element is another json object containing private fields.

The rest of the entry's info is in the query string.

Example:

curl -s -D /dev/stderr \
  -H 'token: root' \
  'localhost:8081/api/v1/content/create?path=/ex1&force&tag=tag1&tag=tag2' \
  -X POST \
  -H 'Content-Type: application/json' \
  -d '[{"some-public-field": "a"}, {"some-private-field": "b"}]' | jq

Instead, the endpoint should accept a json object representing the entire "Entry" entity, e.g.

{
  "path": "/ex1",
  "fields": {
    "some-public-field": {
      "contents": "a",
      "visibility": "public"
    },
    "some-private-field": {
      "contents": "b",
      "visibility": "private"
    }
  },
  "tags": [
    "tag1",
    "tag2"
  ]
}

Acceptance criteria

sancho20021 commented 2 years ago