1
0
Fork 0
mirror of https://codeberg.org/MarkusThielker/next-ory.git synced 2025-04-19 17:11:18 +00:00
next-ory/docker/ory-dev/keto-add-permission-to-role.sh
2025-04-07 11:41:50 +02:00

31 lines
852 B
Bash

# this script gives the referenced identity the admin role
# make sure to provide the id of the identity
# check if a identity id argument was provided
if [ $# -ne 4 ]; then
echo "Usage: $0 <object> <relation> <role> <role_relation>"
exit 1
fi
# set user id variable
OBJECT=$1
RELATION=$2
ROLE=$3
ROLE_RELATION=$4
# execute curl to Ory Keto write endpoint
curl --request PUT \
--url http://localhost:4467/admin/relation-tuples \
--data '{
"namespace": "permissions",
"object": "'"$OBJECT"'",
"relation": "'"$RELATION"'",
"subject_set": {
"namespace": "roles",
"object": "'"$ROLE"'",
"relation": "'"$ROLE_RELATION"'"
}
}'
# write success response to terminal
echo "Added relation Permissions:$OBJECT#$RELATION@(Roles:$ROLE#$RELATION)"