Close certificate auth before revoking worker tokens and rotating its secret

This commit is contained in:
2026-11-16 12:03:49 +03:00
parent d8455d9417
commit 040fa8d4da
6 changed files with 156 additions and 5 deletions
+33 -1
View File
@@ -78,9 +78,37 @@ def configure():
raise
def revoke_worker_tokens():
# Replacing the pinned certificate prevents NEW auth, but already issued
# tokens must also be revoked before publishing a new working secret.
accessors = call("auth/token/accessors", method="LIST").get("data", {}).get("keys", [])
count = 0
for accessor in accessors:
try:
record = call("auth/token/lookup-accessor", {"accessor": accessor})["data"]
except urllib.error.HTTPError as exc:
if exc.code == 400:
continue
raise
if "worker" in record.get("policies", []):
call("auth/token/revoke-accessor", {"accessor": accessor})
count += 1
return count
def main():
parser = argparse.ArgumentParser()
parser.add_argument("action", choices=["init", "unseal", "configure", "seal"])
parser.add_argument(
"action",
choices=[
"init",
"unseal",
"configure",
"seal",
"revoke-worker-tokens",
"disable-worker-auth",
],
)
args = parser.parse_args()
os.umask(0o077)
if args.action == "init":
@@ -106,6 +134,10 @@ def main():
unseal()
elif args.action == "configure":
configure()
elif args.action == "revoke-worker-tokens":
revoke_worker_tokens()
elif args.action == "disable-worker-auth":
call("auth/cert/certs/worker", method="DELETE")
else:
call("sys/seal", {}, method="PUT")
print("OpenBao operator action complete; credential values were not printed.")