-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/PB-36900-rootless-support' into develop
- Loading branch information
Showing
7 changed files
with
228 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,87 @@ | ||
#!/bin/bash | ||
|
||
function registerPassboltUser { | ||
local firstname=$1 | ||
local lastname=$2 | ||
local email=$3 | ||
registration=$("$KUBECTL_BINARY" exec -it deployment/passbolt-depl-srv -n default -- su -c "bin/cake passbolt register_user -u $email -f $firstname -l $lastname -r admin" -s /bin/bash www-data 2>/dev/null) | ||
_log "$registration" | ||
user_uuid=$(echo "${registration}" | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" | cut -d/ -f6) | ||
user_token=$(echo "${registration}" | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" | cut -d/ -f7) | ||
local firstname=$1 | ||
local lastname=$2 | ||
local email=$3 | ||
local register_command='bin/cake passbolt register_user -u $0 -f $1 -l $2 -r admin' | ||
#local command_as_root="su -c "$register_command" -- $email $firstname $lastname -s /bin/bash www-data" | ||
#local command_as_www="bash -c "$register_command" -- $email $firstname $lastname" | ||
if [ "$ROOTLESS" == true ]; then | ||
registration=$("$KUBECTL_BINARY" exec -it deployment/passbolt-depl-srv -n default -- bash -c "$register_command" $email $firstname $lastname 2>/dev/null) | ||
else | ||
registration=$("$KUBECTL_BINARY" exec -it deployment/passbolt-depl-srv -n default -- su www-data -c "$register_command" $email $firstname $lastname -s /bin/bash 2>/dev/null) | ||
fi | ||
_log "$registration" | ||
regex='(https?)://[-[:alnum:]\+&@#/%?=~_|!:,.;]*[-[:alnum:]\+&@#/%=~_|]' | ||
if [[ $registration =~ $regex ]]; then | ||
_log User created on database | ||
else | ||
_log User creation failed | ||
return 1 | ||
fi | ||
user_uuid=$(echo "${registration}" | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" | cut -d/ -f6) | ||
user_token=$(echo "${registration}" | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" | cut -d/ -f7) | ||
|
||
createGPGKey "$email" | ||
createGPGKey "$email" | ||
|
||
_log Registering user on passbolt api... | ||
curl -s "https://${PASSBOLT_FQDN}/setup/complete/${user_uuid}" \ | ||
-H "authority: ${PASSBOLT_FQDN}" \ | ||
-H "accept: application/json" \ | ||
-H "content-type: application/json" \ | ||
--data-raw "{\"authenticationtoken\":{\"token\":\"${user_token}\"},\"gpgkey\":{\"armored_key\":\"$(awk '{printf "%s\\n", $0}' public-${email}.asc)\"}}" \ | ||
--compressed >/dev/null | ||
_log User "$email" succesfully registered | ||
# Fixes an issue on the CI, where user with this key isn't found. | ||
sleep 10 | ||
_log Registering user on passbolt api... | ||
curl -s "https://${PASSBOLT_FQDN}/setup/complete/${user_uuid}" \ | ||
-H "authority: ${PASSBOLT_FQDN}" \ | ||
-H "accept: application/json" \ | ||
-H "content-type: application/json" \ | ||
--data-raw "{\"authenticationtoken\":{\"token\":\"${user_token}\"},\"gpgkey\":{\"armored_key\":\"$(awk '{printf "%s\\n", $0}' public-${email}.asc)\"}}" \ | ||
--compressed >/dev/null | ||
_log User "$email" succesfully registered | ||
# Fixes an issue on the CI, where user with this key isn't found. | ||
sleep 10 | ||
} | ||
|
||
function configurePassbolt { | ||
local id=$1 | ||
_log Configuring passbolt cli... | ||
_log $PASSBOLT_CLI_BINARY configure --serverAddress "https://${PASSBOLT_FQDN}" --userPassword "$PASSPHRASE" --userPrivateKeyFile "secret-${id}.asc" | ||
$PASSBOLT_CLI_BINARY configure --serverAddress "https://${PASSBOLT_FQDN}" --userPassword "$PASSPHRASE" --userPrivateKeyFile "secret-${id}.asc" | ||
_log passbolt cli configured | ||
local id=$1 | ||
_log Configuring passbolt cli... | ||
_log $PASSBOLT_CLI_BINARY configure --serverAddress "https://${PASSBOLT_FQDN}" --userPassword "$PASSPHRASE" --userPrivateKeyFile "secret-${id}.asc" | ||
$PASSBOLT_CLI_BINARY configure --serverAddress "https://${PASSBOLT_FQDN}" --userPassword "$PASSPHRASE" --userPrivateKeyFile "secret-${id}.asc" | ||
_log passbolt cli configured | ||
} | ||
|
||
function createPassword { | ||
local name="$1" | ||
local secret="$2" | ||
_log $PASSBOLT_CLI_BINARY create resource --name "${name}" --password "$secret" -j | ||
$PASSBOLT_CLI_BINARY create resource --name "${name}" --password "$secret" -j | ||
local name="$1" | ||
local secret="$2" | ||
_log $PASSBOLT_CLI_BINARY create resource --name "${name}" --password "$secret" -j | ||
$PASSBOLT_CLI_BINARY create resource --name "${name}" --password "$secret" -j | ||
} | ||
|
||
function createPasswordInFolder { | ||
local name="$1" | ||
local secret="$2" | ||
local folder="$3" | ||
_log $PASSBOLT_CLI_BINARY create resource --name "${name}" --password "$secret" -f "$folder" -j | ||
$PASSBOLT_CLI_BINARY create resource --name "${name}" --password "$secret" -f "$folder" -j | ||
local name="$1" | ||
local secret="$2" | ||
local folder="$3" | ||
_log $PASSBOLT_CLI_BINARY create resource --name "${name}" --password "$secret" -f "$folder" -j | ||
$PASSBOLT_CLI_BINARY create resource --name "${name}" --password "$secret" -f "$folder" -j | ||
} | ||
|
||
function createFolder { | ||
local name="$1" | ||
_log $PASSBOLT_CLI_BINARY create folder --name "${name}" -j | ||
$PASSBOLT_CLI_BINARY create folder --name "${name}" -j | ||
local name="$1" | ||
_log $PASSBOLT_CLI_BINARY create folder --name "${name}" -j | ||
$PASSBOLT_CLI_BINARY create folder --name "${name}" -j | ||
} | ||
|
||
function sharePassword { | ||
local id=$1 | ||
local user_id=$2 | ||
local type="$3" | ||
_log $PASSBOLT_CLI_BINARY share resource --id "$id" --user "$user_id" --type "$type" | ||
$PASSBOLT_CLI_BINARY share resource --id "$id" --user "$user_id" --type "$type" | ||
local id=$1 | ||
local user_id=$2 | ||
local type="$3" | ||
_log $PASSBOLT_CLI_BINARY share resource --id "$id" --user "$user_id" --type "$type" | ||
$PASSBOLT_CLI_BINARY share resource --id "$id" --user "$user_id" --type "$type" | ||
} | ||
|
||
function getUserIdByUsername { | ||
local username="$1" | ||
_log $PASSBOLT_CLI_BINARY list user --filter "Username == \"$username\"" -j | jq -r .[0].id | ||
$PASSBOLT_CLI_BINARY list user --filter "Username == \"$username\"" -j | jq -r .[0].id | ||
local username="$1" | ||
_log $PASSBOLT_CLI_BINARY list user --filter "Username == \"$username\"" -j | jq -r .[0].id | ||
$PASSBOLT_CLI_BINARY list user --filter "Username == \"$username\"" -j | jq -r .[0].id | ||
} | ||
|
||
function getPasswordSecretById { | ||
local id="$1" | ||
_log "$PASSBOLT_CLI_BINARY" get resource --id "$id" -j | jq -r .password | ||
"$PASSBOLT_CLI_BINARY" get resource --id "$id" -j | jq -r .password | ||
local id="$1" | ||
_log "$PASSBOLT_CLI_BINARY" get resource --id "$id" -j | jq -r .password | ||
"$PASSBOLT_CLI_BINARY" get resource --id "$id" -j | jq -r .password | ||
} |
Oops, something went wrong.