microscopic-policeman-50029
09/11/2022, 2:10 PMfeatures := []string{"f1","f2"}
roles := []string{"r1","r2"}
features /roles r1. r2
f1. {"view","delete"} {"delete","edit"}
f2. {"view"} {"delete"}
features_role_rights_array := [][][]string{{{"view","delete"},{"delete","edit"}},{{"view"},{"delete"}}}
Now Say a user with id user-1 has a role r2, I want to see over a feature what access does he has?
Is there any way to get this information, with implementing it using keto.
I have tried this kind of configuration:
features:f1#view@(roles:r1#member)
features:f1#delete@(roles:r1#member)
features:f1#delete@(roles:r2#member)
features:f1#edit@(roles:r2#member)
features:f2#view@(roles:r1#member)
features:f2#delete@(roles:r2#member)
roles:r2#member@user-1
Now in order to get my query I am not able to get the details of accesses user-1 has.
Is there any way to get this information?magnificent-energy-493
microscopic-policeman-50029
09/12/2022, 10:32 AMmicroscopic-policeman-50029
09/12/2022, 10:38 AM#!/bin/bash
set -euo pipefail
export KETO_WRITE_REMOTE="127.0.0.1:4467"
echo '
features:f1#view@(roles:r1#member)
features:f1#delete@(roles:r1#member)
features:f1#delete@(roles:r2#member)
features:f1#edit@(roles:r2#member)
features:f2#view@(roles:r1#member)
features:f2#delete@(roles:r2#member)
roles:r2#member@user-1
' | \
keto relation-tuple parse - --format json | \
keto relation-tuple create - >/dev/null \
&& echo "Successfully created tuples" \
|| echo "Encountered error"
List of Namespaces are;
1. features
2. roles
I am able to get the result in the check api i.e. :
If user-1 has access to delete feature f1
curl --location --request POST 'localhost:4466/relation-tuples/check' \
--header 'Content-Type: application/json' \
--data-raw '{
"namespace": "features",
"object": "f1",
"relation": "delete",
"subject_id": "user-1"
}'
This curl is giving me true as response but I want all the relations user-1 has in features namespace.
curl --location --request GET 'localhost:4466/relation-tuples?namespace=features&object=f1&subject-id=user-1'
Like this api should give me the relations for user-1 with object f1 in namespace features.