forked from mtusi2026/mtusi2026lab7
Close certificate auth before revoking worker tokens and rotating its secret
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import json
|
||||
import ssl
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
@@ -51,6 +52,18 @@ def main():
|
||||
checks[name] = exc.code in {400, 403}
|
||||
except (OSError, urllib.error.URLError):
|
||||
checks[name] = True
|
||||
try:
|
||||
request = urllib.request.Request(
|
||||
"https://openbao:8200/v1/secret/data/services/worker",
|
||||
headers={"X-Vault-Token": old["REVOKED_BAO_TOKEN"]},
|
||||
)
|
||||
with urllib.request.urlopen(request, context=ctx, timeout=3):
|
||||
checks["previously_issued_bao_token_denied"] = False
|
||||
except urllib.error.HTTPError as exc:
|
||||
checks["previously_issued_bao_token_denied"] = exc.code == 403
|
||||
checks["old_bao_token_rejected_before_original_lease_expiry"] = (
|
||||
time.time() < old["REVOKED_BAO_TOKEN_EXPIRES_AT"]
|
||||
)
|
||||
print(json.dumps({"checks": checks, "passed": all(checks.values())}))
|
||||
if not all(checks.values()):
|
||||
raise SystemExit(1)
|
||||
|
||||
Reference in New Issue
Block a user