forked from mtusi2026/mtusi2026lab2
ЛР2: PostgreSQL, сессии (Basic + Bearer), Compose, миграции
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
# Windows twin of scripts/init-secrets.sh. Existing files are kept.
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-Location (Join-Path $PSScriptRoot '..')
|
||||
New-Item -ItemType Directory -Force secrets | Out-Null
|
||||
|
||||
function New-Secret($name, $bytes) {
|
||||
$path = Join-Path 'secrets' $name
|
||||
if ((Test-Path $path) -and (Get-Item $path).Length -gt 0) { "kept secrets/$name"; return }
|
||||
$buffer = New-Object byte[] $bytes
|
||||
[Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($buffer)
|
||||
$value = [Convert]::ToBase64String($buffer) -replace '[+/=]', ''
|
||||
# ASCII, no BOM, no trailing newline.
|
||||
[IO.File]::WriteAllText((Join-Path (Get-Location) $path), $value, [Text.Encoding]::ASCII)
|
||||
"created secrets/$name"
|
||||
}
|
||||
|
||||
New-Secret 'postgres_password' 32
|
||||
New-Secret 'jwt_secret' 64
|
||||
if (-not (Test-Path .env)) { Copy-Item .env.example .env; 'created .env' }
|
||||
Reference in New Issue
Block a user