This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
import json,ssl,subprocess,urllib.request
|
||||
from pathlib import Path
|
||||
root=Path(__file__).resolve().parent.parent
|
||||
init=json.loads((root/'secrets/operator/bao-init.json').read_text())
|
||||
ctx=ssl.create_default_context(cafile=str(root/'certs/ca.crt'))
|
||||
def write(path,body,token=None):
|
||||
headers={'Content-Type':'application/json'}
|
||||
if token:headers['X-Vault-Token']=token
|
||||
request=urllib.request.Request('https://localhost:8200/v1/'+path,data=json.dumps(body).encode(),headers=headers)
|
||||
with urllib.request.urlopen(request,context=ctx,timeout=10) as response:response.read()
|
||||
try:
|
||||
write('sys/seal',{},init['root_token'])
|
||||
p=subprocess.run([str(root/'scripts/dc.sh'),'run','--rm','-T','--no-deps','--entrypoint','/app/worker','worker'],stdout=subprocess.PIPE,stderr=subprocess.PIPE,timeout=20)
|
||||
assert p.returncode==1,'Worker must fail closed when OpenBao is sealed'
|
||||
finally:write('sys/unseal',{'key':init['unseal_keys_b64'][0]})
|
||||
print('PASS: fresh Worker refuses startup with sealed OpenBao; operator unseal restores access')
|
||||
Reference in New Issue
Block a user