best-businessperson-92294
01/30/2024, 10:40 PMconst oryConfig = new OryKeto.Configuration({
basePath: '<http://keto:4466>' // Run inside Docker net, so this resolves to the keto container IP
});
const client = new OryKeto.PermissionApi(oryConfig);
const permissionRequest = {
namespace: "videos",
object: "/cats/1.mp4",
relation: "view",
subjectId: "*"
};
client.checkPermission(permissionRequest)
.then((res) => {
console.log(res)
})
.catch((err) => {
console.log(err)
});
This returns 404. Here's the log from the keto container:
time=2024-01-30T22:57:34Z level=info msg=completed handling request http_request=map[headers:map[accept:application/json, text/plain, */* connection:close user-agent:axios/0.27.2] host:keto:4466 method:GET path:/relation-tuples/check/openapi query:namespace=videos&object=%2Fcats%2F1.mp4&relation=view&subject_id=* remote:172.18.0.11:46404 scheme:http] http_response=map[headers:map[content-type:text/plain; charset=utf-8 x-content-type-options:nosniff] size:19 status:404 text_status:Not Found took:1.412583ms]
But when I run the same request directly through keto CLI: keto check "*" view videos /cats/1.mp4
it comes back 'Allowed'.
Upon further investigation the SDK is sending the request to this URL:
path: '/relation-tuples/check/openapi?namespace=videos&object=%2Fcats%2F1.mp4&relation=view&subject_id=*',
Do you think this is the correct URL? Or should I use a different basePath? The above 404 looks like returned due to wrong path being provided.
Also, here's the config as well I'm passing to keto to serve:
version: v0.7.0-alpha.1
log:
level: debug
namespaces:
- id: 0
name: videos
serve:
read:
host: 0.0.0.0
port: 4466
write:
host: 0.0.0.0
port: 4467
dsn: sqlite:///var/lib/sqlite/db.sqlite?_fk=true&mode=rwc
Any help will be greatly appreciated!