Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions cra-scripts/bito-cra.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -698,13 +698,21 @@ $docker_enc_params=

if ($mode -eq "server") {
if (-not([string]::IsNullOrEmpty($props[$param_bito_access_key])) -and -not([string]::IsNullOrEmpty($props[$param_git_access_token]))) {
$git_secret = "$($props[$param_bito_access_key])@#~^$($props[$param_git_access_token])"
if ($props[$param_git_provider] -eq "BITBUCKET") {
$git_secret = $props[$param_git_access_token]
# Truncate if longer than 60 characters
if ($git_secret.Length -gt 60) {
$git_secret = $git_secret.Substring(0, 60)
}
} else {
$git_secret = "$($props[$param_bito_access_key])@#~^$($props[$param_git_access_token])"
}
$encryption_key = [System.Convert]::ToBase64String((1..32 | ForEach-Object { [byte](Get-Random -Minimum 0 -Maximum 256) }))
$git_secret_encrypted = Encrypt-GitSecret -key $encryption_key -plaintext $git_secret
$docker_enc_params=" --git.secret=$git_secret_encrypted --encryption_key=$encryption_key"
$docker_cmd += " ${docker_enc_params}"

Write-Host "Use below as Gitlab and Github Webhook secret:"
Write-Host "Use below as Gitlab and Github or Bitbucket Webhook secret:"
Write-Host $git_secret_encrypted
Write-Host
}
Expand Down
15 changes: 12 additions & 3 deletions cra-scripts/bito-cra.sh
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ optional_params_cli=(
"support_email"
)

# Parameters that are required/optional in mode server
# Parameters that are required/optional in the mode server
required_params_server=(
"mode"
"code_feedback"
Expand Down Expand Up @@ -720,16 +720,25 @@ encrypt_git_secret() {

param_bito_access_key="bito_cli.bito.access_key"
param_git_access_token="git.access_token"
param_git_provider="git.provider"

docker_enc_params=
if [ "$mode" == "server" ]; then
if [ -n "${props[$param_bito_access_key]}" ] && [ -n "${props[$param_git_access_token]}" ]; then
git_secret="${props[$param_bito_access_key]}@#~^${props[$param_git_access_token]}"
if [[ "${props[$param_git_provider]}" == "BITBUCKET" ]]; then
git_secret="${props[$param_git_access_token]}"
# Truncate only for Bitbucket if longer than 60 characters
if [ ${#git_secret} -gt 60 ]; then
git_secret="${git_secret:0:60}"
fi
else
git_secret="${props[$param_bito_access_key]}@#~^${props[$param_git_access_token]}"
fi
encryption_key=$(openssl rand -base64 32)
git_secret=$(encrypt_git_secret "$encryption_key" "$git_secret")
docker_enc_params=" --git.secret=$git_secret --encryption_key=$encryption_key"

echo "Use below as Gitlab and Github Webhook secret:"
echo "Use below as Gitlab and Github or Bitbucket Webhook secret:"
echo "$git_secret"
echo
fi
Expand Down