Add database, aws, approle and ssh engines with credential caching
release / validate (push) Successful in 5s
test / test (push) Successful in 1m6s
release / build (, macos-arm64, macos-arm64) (push) Successful in 1m20s
release / build (amd64, linux-amd64, linux-amd64) (push) Successful in 1m7s
release / build (arm64, linux-arm64, linux-arm64) (push) Successful in 2m2s
release / release (push) Successful in 26s
release / validate (push) Successful in 5s
test / test (push) Successful in 1m6s
release / build (, macos-arm64, macos-arm64) (push) Successful in 1m20s
release / build (amd64, linux-amd64, linux-amd64) (push) Successful in 1m7s
release / build (arm64, linux-arm64, linux-arm64) (push) Successful in 2m2s
release / release (push) Successful in 26s
New OpenBao credential engines (database/PostgreSQL, aws, approle, ssh) backed by a POST-capable BaoClient. Queries can set cache = true on dynamic database and aws roles to reuse the credential until near lease expiry (file store by default, optional keychain), revoking the old lease on refresh. Adds [cache] store and --clear-cache. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
78ff2b0ddd
commit
0cde1ff7f7
20 files changed
+1708
-29
No files matched your search
@@ -20,8 +20,16 @@ class FakeBao:
|
||||
def __init__(self) -> None:
|
||||
self.routes: dict[str, tuple[int, Any]] = {}
|
||||
self.requests: list[tuple[str, dict[str, str]]] = []
|
||||
self.posts: list[tuple[str, Any]] = []
|
||||
self.url = ""
|
||||
|
||||
def route(self, path: str, data: dict[str, Any], status: int = 200) -> None:
|
||||
"""Serve ``{"data": data}`` at ``/v1/<path>`` for both GET and POST."""
|
||||
self.routes[f"/v1/{path}"] = (
|
||||
status,
|
||||
{"data": data, "lease_id": "x/1", "lease_duration": 60},
|
||||
)
|
||||
|
||||
def kv2(self, mount: str, path: str, data: dict[str, Any]) -> None:
|
||||
self.routes[f"/v1/sys/internal/ui/mounts/{mount}"] = (
|
||||
200,
|
||||
@@ -59,6 +67,23 @@ def fake_bao() -> Iterator[FakeBao]:
|
||||
status, body = state.routes.get(self.path, (404, {"errors": []}))
|
||||
self._send(status, body)
|
||||
|
||||
def do_POST(self) -> None: # noqa: N802
|
||||
headers = {k.lower(): v for k, v in self.headers.items()}
|
||||
length = int(headers.get("content-length", "0"))
|
||||
payload = json.loads(self.rfile.read(length) or b"{}")
|
||||
state.requests.append((self.path, headers))
|
||||
state.posts.append((self.path, payload))
|
||||
if headers.get("x-vault-token") != TOKEN:
|
||||
self._send(403, {"errors": ["permission denied"]})
|
||||
return
|
||||
if self.path == "/v1/redirect":
|
||||
self.send_response(307)
|
||||
self.send_header("Location", "http://127.0.0.1:1/steal")
|
||||
self.end_headers()
|
||||
return
|
||||
status, body = state.routes.get(self.path, (404, {"errors": []}))
|
||||
self._send(status, body)
|
||||
|
||||
def _send(self, status: int, body: Any) -> None:
|
||||
raw = body if isinstance(body, bytes) else json.dumps(body).encode()
|
||||
self.send_response(status)
|
||||
|
||||
Reference in new issue
Block a user