api icon indicating copy to clipboard operation
api copied to clipboard

Is it possible to provide an interface for batch checking, e.g. BatchCheck?

Open Bob1008-Call opened this issue 1 year ago • 4 comments

Bob1008-Call avatar Dec 01 '23 07:12 Bob1008-Call

Hey @caozongkai1008 - the API does not support BatchCheck at the moment, however all our supported SDKs do.

For example, in the JS SDK: https://github.com/openfga/js-sdk#batch-check

const options = {
  // if you'd like to override the authorization model id for this request
  authorizationModelId: "01GXSA8YR785C4FYS3C0RTG7B1",
}
const { responses } = await fgaClient.batchCheck([{
  user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
  relation: "viewer",
  object: "document:budget",
}, {
  user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
  relation: "member",
  object: "document:budget",
}, {
  user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
  relation: "viewer",
  object: "document:roadmap",
  contextual_tuples: [{
    user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    relation: "writer",
    object: "document:roadmap"
  }],
}], options);

/*
responses = [{
  allowed: false,
  _request: {
    user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    relation: "viewer",
    object: "document:budget",
  }
}, {
  allowed: false,
  _request: {
    user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    relation: "member",
    object: "document:budget",
  },
  err: <FgaError ...>
}, {
  allowed: true,
  _request: {
    user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    relation: "viewer",
    object: "document:roadmap",
    contextual_tuples: [{
      user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
      relation: "writer",
      object: "document:roadmap"
    }],
  }},
]
*/

Take a look and let us know what you think!

rhamzeh avatar Dec 01 '23 10:12 rhamzeh

Thanks. I know sdk supports it.

Bob1008-Call avatar Dec 07 '23 03:12 Bob1008-Call

Can you give us your feedback on that interface? We add some features to the SDKs before the API to gather feedback for folks in order to iterate quicker and stabilize on an interface that works for everyone.

Any thoughts on the one in the SDKs? Anything you would like changed in that?

rhamzeh avatar Dec 07 '23 14:12 rhamzeh

thanks, we use OpenFGA for access control (through GRPC), and the usage scenario involves batch check, so it would be great if there is such an interface.

Bob1008-Call avatar Dec 12 '23 09:12 Bob1008-Call