mirror of
https://codeberg.org/MarkusThielker/next-ory.git
synced 2025-04-19 09:01:18 +00:00
NORY-59: add new script to create Keto relationships
This commit is contained in:
parent
17f91cfe50
commit
c395a44bf6
3 changed files with 59 additions and 0 deletions
31
docker/ory-dev/keto-add-permission-to-role.sh
Normal file
31
docker/ory-dev/keto-add-permission-to-role.sh
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# 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)"
|
26
docker/ory-dev/keto-add-permission.sh
Normal file
26
docker/ory-dev/keto-add-permission.sh
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# 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"
|
|
@ -22,6 +22,8 @@ dsn: postgres://postgres:postgres@ory-postgres:5432/keto?sslmode=disable&max_con
|
||||||
namespaces:
|
namespaces:
|
||||||
- id: 0
|
- id: 0
|
||||||
name: roles
|
name: roles
|
||||||
|
- id: 1
|
||||||
|
name: permissions
|
||||||
|
|
||||||
serve:
|
serve:
|
||||||
read:
|
read:
|
||||||
|
|
Loading…
Add table
Reference in a new issue