Защита стенда и управление секретами через OpenBao

This commit is contained in:
EgorAnti
2026-11-25 19:36:12 +03:00
parent 20afc2c790
commit d23847f953
159 changed files with 9135 additions and 82 deletions
+13
View File
@@ -0,0 +1,13 @@
[CmdletBinding()]
param([string]$EnvFile = '.env')
$ErrorActionPreference = 'Stop'
Set-Location (Join-Path $PSScriptRoot '..')
if ([string]::IsNullOrWhiteSpace($env:BAO_TOKEN)) { throw 'Set BAO_TOKEN for this operator action.' }
foreach($role in 'api','worker') {
$roleName = "messenger-$role"
$secretId = (& docker compose --env-file $EnvFile exec -T -e "BAO_TOKEN=$env:BAO_TOKEN" openbao bao write -field=secret_id -f "auth/approle/role/$roleName/secret-id" | Out-String).Trim()
if($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($secretId)){ throw "Failed to rotate $roleName SecretID" }
[System.IO.File]::WriteAllText((Join-Path "secrets\openbao\$role" 'secret-id'),$secretId,[System.Text.Encoding]::ASCII)
}
Write-Host 'AppRole SecretIDs rotated without printing their values.'