1
0
Fork 0
mirror of https://codeberg.org/MarkusThielker/next-ory.git synced 2025-04-18 16:41:18 +00:00
next-ory/docker/ory-dev/keto-add-permission.sh
2025-04-04 16:20:25 +02:00

26 lines
707 B
Bash

# this script gives the referenced identity the provided permission
# make sure to provide the id of the identity
# check if a required arguments were provided
if [ $# -ne 3 ]; then
echo "Usage: $0 <object> <relation> <identity_id>"
exit 1
fi
# set variables from input
OBJECT=$1
RELATION=$2
IDENTITY_ID=$3
# 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_id": "'"$IDENTITY_ID"'"
}'
# write success response to terminal
echo "Added permission $OBJECT#$RELATION@$IDENTITY_ID"