Skip to content

Commit ebfda44

Browse files
Merge pull request #1 from bitwarden-labs/main
sync
2 parents c25a561 + aefa062 commit ebfda44

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

Bash Scripts/inheritparentpermissions-API.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,21 @@
33
# replacewithyoursupersecretstring
44
# With your own encryption phrase, and then running:
55
# echo 'YOUR_MASTER_PASSWORD' | openssl enc -aes-256-cbc -md sha512 -a -pbkdf2 -iter 600001 -salt -pass pass:replacewithyoursupersecretstring > secureString.txt
6-
# echo 'ORG API KEY' | openssl enc -aes-256-cbc -md sha512 -a -pbkdf2 -iter 600001 -salt -pass pass:replacewithyoursupersecretstring > secureSecretString.txt.txt
7-
# jq is required in $PATH https://stedolan.github.io/jq/download/
6+
# echo 'ORG API KEY' | openssl enc -aes-256-cbc -md sha512 -a -pbkdf2 -iter 600001 -salt -pass pass:replacewithyoursupersecretstring > secureSecretString.txt
87
# bw is required in $PATH and logged in https://bitwarden.com/help/cli/
98
# openssl is required in $PATH https://www.openssl.org/
9+
# Usage: ./inheritparentpermissions-API.sh ["Parent Collection Name"]
10+
# If parent name is provided, only processes that specific parent collection
1011

1112
organization_id="REPLACE_WITH_YOUR_ORG_ID" # Set your Org ID
1213
org_client_id="organization.$organization_id" # Auto-generated from organization_id
1314
BW_IDENTITY_HOST="https://identity.bitwarden.com"
1415
BW_API_HOST="https://api.bitwarden.com"
1516
debug=0
1617

18+
# Optional parameter: specific parent collection name
19+
specific_parent="$1"
20+
1721
# org_client_secret will be read from secureSecretString.txt
1822

1923
# Perform CLI auth
@@ -90,7 +94,11 @@ parentcollections=$(bw list org-collections --organizationid $organization_id |
9094
IFS=$'\n'
9195
for parent in $parentcollections; do
9296

93-
97+
# Skip this parent if a specific parent was provided and this isn't it
98+
if [ -n "$specific_parent" ] && [ "$parent" != "$specific_parent" ]; then
99+
continue
100+
fi
101+
94102
# Get the Parent's Collection ID
95103
parentid=$(bw list org-collections --organizationid $organization_id | jq --arg p "$parent" -r '.[] | select(.name == $p) | .id')
96104
if [ -n "$parentid" ]; then

0 commit comments

Comments
 (0)