average-policeman-69189
03/15/2023, 8:08 PMremote_json
to call keto to allow access based on API method and path pattern, it work beautifully, now I need to implement access rule per entity id, what's the best way to do it ? Keto check api allow only one tuple to be checked, so I will need kind of a proxy API to check the API access tuple and the entity id access rule ... or is it better to delegate the entity based id check to the backend API ? Thanks for your helpsteep-lamp-91158
average-policeman-69189
03/16/2023, 4:40 PMaverage-policeman-69189
03/22/2023, 5:43 PMsteep-lamp-91158
class Product implements Namespace {
related: {
owner: (Team | User)[]
viewer: (Team | User)[]
}
permits = {
publish: (ctx) => this.related.owner.includes(ctx.subject),
edit: (ctx) => this.related.owner.includes(ctx.subject),
view: (ctx) => this.related.owner.includes(ctx.subject) || this.related.viewer.includes(ctx.subject),
}
}
then you have to select the right permission depending on the path and method, basically by having multiple access rules, one for each permission
- id: product-publish
match:
methods: [POST]
url: "/api/product/<.*>/publish"
authorizer:
handler: remote_json
config: # with the publish permission
- id: product-view
match:
methods: [GET]
url: "/api/product/<.*>"
authorizer:
handler: remote_json
config: # with the view permission
- id: product-edit
match:
methods: [PUT, POST]
url: "/api/product/<.*>"
authorizer:
handler: remote_json
config: # with the edit permission
steep-lamp-91158
average-policeman-69189
03/23/2023, 2:34 PMaverage-policeman-69189
03/23/2023, 10:59 PMsteep-lamp-91158