|
3 | 3 | # replacewithyoursupersecretstring |
4 | 4 | # With your own encryption phrase, and then running: |
5 | 5 | # 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 |
8 | 7 | # bw is required in $PATH and logged in https://bitwarden.com/help/cli/ |
9 | 8 | # 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 |
10 | 11 |
|
11 | 12 | organization_id="REPLACE_WITH_YOUR_ORG_ID" # Set your Org ID |
12 | 13 | org_client_id="organization.$organization_id" # Auto-generated from organization_id |
13 | 14 | BW_IDENTITY_HOST="https://identity.bitwarden.com" |
14 | 15 | BW_API_HOST="https://api.bitwarden.com" |
15 | 16 | debug=0 |
16 | 17 |
|
| 18 | +# Optional parameter: specific parent collection name |
| 19 | +specific_parent="$1" |
| 20 | + |
17 | 21 | # org_client_secret will be read from secureSecretString.txt |
18 | 22 |
|
19 | 23 | # Perform CLI auth |
@@ -90,7 +94,11 @@ parentcollections=$(bw list org-collections --organizationid $organization_id | |
90 | 94 | IFS=$'\n' |
91 | 95 | for parent in $parentcollections; do |
92 | 96 |
|
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 | + |
94 | 102 | # Get the Parent's Collection ID |
95 | 103 | parentid=$(bw list org-collections --organizationid $organization_id | jq --arg p "$parent" -r '.[] | select(.name == $p) | .id') |
96 | 104 | if [ -n "$parentid" ]; then |
|
0 commit comments