Реализовать ЛР 7 на оценку 4
Skeleton contracts / contracts (pull_request) Blocked by required conditions

This commit is contained in:
2026-12-04 16:15:18 +03:00
parent 7996ebbb48
commit 94a8a5c1da
29 changed files with 918 additions and 85 deletions
+15 -10
View File
@@ -20,8 +20,8 @@ def bundle(role: str, passwords: dict[str, str]) -> dict[str, str]:
)}
if 'redis' in passwords:
result['REDIS_URL'] = f'rediss://{name}:{passwords["redis"]}@redis:6379/0'
if 'broker' in passwords:
result['BROKER_URL'] = f'amqps://{name}:{passwords["broker"]}@broker:5671/'
if role in ('publisher', 'worker'):
result['BROKER_URL'] = 'amqps://broker:5671/?auth=external'
if 's3' in passwords:
result.update(
S3_ACCESS_KEY_ID=f'messenger-{role}',
@@ -41,6 +41,18 @@ def seal_status(client: BaoClient) -> dict:
raise AssertionError('unreachable')
def configure_identity(client: BaoClient, directory: Path, role: str, root: str, ttl: int = 300) -> None:
policy = f'messenger-{role}'
certificate = (directory / policy / 'public.crt').read_text(encoding='utf-8')
client.request(f'auth/cert/certs/{role}', {
'certificate': certificate,
'token_policies': [policy],
'token_no_default_policy': True,
'token_ttl': ttl,
'token_max_ttl': ttl,
}, token=root)
def provision(client: BaoClient, directory: Path) -> None:
operator = directory / 'operator'
recovery = operator / 'openbao-init.json'
@@ -78,14 +90,7 @@ def provision(client: BaoClient, directory: Path) -> None:
'path "auth/token/revoke-self" { capabilities = ["update"] }'
),
}, token=root)
certificate = (directory / policy / 'public.crt').read_text(encoding='utf-8')
client.request(f'auth/cert/certs/{role}', {
'certificate': certificate,
'token_policies': [policy],
'token_no_default_policy': True,
'token_ttl': 300,
'token_max_ttl': 300,
}, token=root)
configure_identity(client, directory, role, root)
secret = bundle(role, credentials[role])
try:
previous = client.read_service(role, root)