Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b7071a318 | ||
|
|
15e71e0e70 | ||
|
|
8c36460dea | ||
|
|
49f3d4b6a5 | ||
|
|
42ea9d6531 | ||
|
|
06366cd106 | ||
|
|
c6bb5b132a | ||
|
|
c29b0cfd63 | ||
|
|
d5f5faf2df | ||
|
|
4d0740dd97 | ||
|
|
3fa32b5076 | ||
|
|
e646dade12 | ||
|
|
eb99b7441b | ||
|
|
88e3a4564b |
No files matched your search
@@ -16,7 +16,7 @@ jobs:
|
|||||||
cache: npm
|
cache: npm
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run lint
|
- run: npm run lint
|
||||||
- run: npm audit --audit-level=high
|
- run: npm audit --omit=dev --audit-level=high
|
||||||
- run: npm test
|
- run: npm test
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ jobs:
|
|||||||
cache: npm
|
cache: npm
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run lint
|
- run: npm run lint
|
||||||
- run: npm audit --audit-level=high
|
- run: npm audit --omit=dev --audit-level=high
|
||||||
- run: npm test
|
- run: npm test
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
|
|
||||||
@@ -66,7 +66,8 @@ jobs:
|
|||||||
- name: Build and push
|
- name: Build and push
|
||||||
run: |
|
run: |
|
||||||
VERSION="${GITHUB_REF_NAME#v}"
|
VERSION="${GITHUB_REF_NAME#v}"
|
||||||
docker build -t "$IMAGE:$VERSION" -t "$IMAGE:latest" .
|
# The runner may be arm64 (a Mac); the deploy host is amd64, so always build for it.
|
||||||
|
docker build --platform linux/amd64 -t "$IMAGE:$VERSION" -t "$IMAGE:latest" .
|
||||||
docker push "$IMAGE:$VERSION"
|
docker push "$IMAGE:$VERSION"
|
||||||
docker push "$IMAGE:latest"
|
docker push "$IMAGE:latest"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
FROM node:22-alpine AS build
|
# The build stage only emits static files, so it runs on the builder's own architecture; only the nginx stage
|
||||||
|
# takes the target platform (linux/amd64, set in the release workflow). No emulation needed.
|
||||||
|
FROM --platform=$BUILDPLATFORM node:22-alpine AS build
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|||||||
@@ -6,11 +6,29 @@ Licensed under the [BSD 3-Clause License](LICENSE).
|
|||||||
|
|
||||||
The UI talks directly to the OpenBao HTTP API from the browser. There is no backend.
|
The UI talks directly to the OpenBao HTTP API from the browser. There is no backend.
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
- [User guide](docs/user-guide.md): signing in, identities, giving access, secrets and dynamic engines, the graph.
|
||||||
|
- [Administrator guide](docs/admin-guide.md): OpenBao setup, CORS, the admin policy, deployment and releases, security notes, troubleshooting.
|
||||||
|
|
||||||
|
## Screenshots
|
||||||
|
|
||||||
|
Taken from the [demo stack](#quick-start-with-docker).
|
||||||
|
|
||||||
|
| | |
|
||||||
|
| --- | --- |
|
||||||
|
|  |  |
|
||||||
|
| **Secrets**: who can reach a secret, and through which policy. | **Graph**: click a box to highlight every link from it. |
|
||||||
|
|  |  |
|
||||||
|
| **Access**: grant or revoke without writing HCL. | **Dynamic secrets**: manage roles, generate credentials, browse leases. |
|
||||||
|
|  |  |
|
||||||
|
| **Generate**: credentials are shown once and never stored. | **Secrets engines**: create, change and delete mounts. |
|
||||||
|
|
||||||
## What it does
|
## What it does
|
||||||
|
|
||||||
- **Connect** with a token or a userpass login. Refuses sealed or uninitialised servers, and explains CORS and connection problems.
|
- **Connect** with a token or a userpass login. Refuses sealed or uninitialised servers, and explains CORS and connection problems.
|
||||||
- **Identities**: create, edit and delete userpass users, identity entities (with userpass aliases) and groups; create, list and revoke tokens. A new token's value is shown once.
|
- **Identities**: create, edit and delete userpass users, identity entities (with userpass aliases) and groups; create, list and revoke tokens. A new token's value is shown once.
|
||||||
- **Secrets**: browse KV v2 mounts and paths (names only; KV secret values are never read) and see which identities can reach a secret, through which policy, with which capabilities.
|
- **Secrets**: browse KV v2 mounts and paths and add new secrets (values are write-only: existing values are never read, shown or overwritten) and see which identities can reach a secret, through which policy, with which capabilities.
|
||||||
- **Secrets engines**: create (KV v2, database, AWS, SSH), change the settings of, and delete secrets engine mounts, including KV v2 settings such as max versions. Deleting asks you to type the mount path, and says what will be lost and which policies still refer to it.
|
- **Secrets engines**: create (KV v2, database, AWS, SSH), change the settings of, and delete secrets engine mounts, including KV v2 settings such as max versions. Deleting asks you to type the mount path, and says what will be lost and which policies still refer to it.
|
||||||
- **Dynamic secrets**: for database (Postgres, ...), AWS and SSH engines, and a raw-JSON editor for any other engine type: create, edit and delete roles; configure the engine (database connections with rotate and reset, AWS root and lease, the SSH signing CA); generate credentials, sign SSH keys or issue OTPs; and browse, renew and revoke leases. Issued credentials are shown once and are never stored or cached by the UI. Passwords and private keys you type into config forms are write-only: they are never shown again.
|
- **Dynamic secrets**: for database (Postgres, ...), AWS and SSH engines, and a raw-JSON editor for any other engine type: create, edit and delete roles; configure the engine (database connections with rotate and reset, AWS root and lease, the SSH signing CA); generate credentials, sign SSH keys or issue OTPs; and browse, renew and revoke leases. Issued credentials are shown once and are never stored or cached by the UI. Passwords and private keys you type into config forms are write-only: they are never shown again.
|
||||||
- **Access**: from an identity's **Access** button, grant it capabilities on a secret path (globs allowed) or access to a dynamic-engine role (generate credentials, manage the role), or revoke them, without writing policy HCL. A role's **Access** button shows who can already use it.
|
- **Access**: from an identity's **Access** button, grant it capabilities on a secret path (globs allowed) or access to a dynamic-engine role (generate credentials, manage the role), or revoke them, without writing policy HCL. A role's **Access** button shows who can already use it.
|
||||||
@@ -143,6 +161,8 @@ path "sys/mounts/*" { capabilities = ["create", "read", "update", "delete
|
|||||||
# KV v2 settings (max versions, check-and-set) of the KV mount
|
# KV v2 settings (max versions, check-and-set) of the KV mount
|
||||||
path "secret/config" { capabilities = ["read", "update"] }
|
path "secret/config" { capabilities = ["read", "update"] }
|
||||||
path "secret/metadata/*" { capabilities = ["list"] }
|
path "secret/metadata/*" { capabilities = ["list"] }
|
||||||
|
# Creating a new KV v2 secret. Create only: values can't be read back and existing secrets can't be overwritten
|
||||||
|
path "secret/data/*" { capabilities = ["create"] }
|
||||||
|
|
||||||
# Dynamic secrets engines: roles, config, credentials and leases. The paths use the default mount
|
# Dynamic secrets engines: roles, config, credentials and leases. The paths use the default mount
|
||||||
# names (database/, aws/, ssh/); repeat a block with your own mount path for each engine you manage.
|
# names (database/, aws/, ssh/); repeat a block with your own mount path for each engine you manage.
|
||||||
@@ -191,7 +211,7 @@ Notes:
|
|||||||
- Creating **orphan** tokens (the "Orphan" checkbox) needs `sudo` on `auth/token/create`. It is deliberately not granted above; add `"sudo"` there if you want it.
|
- Creating **orphan** tokens (the "Orphan" checkbox) needs `sudo` on `auth/token/create`. It is deliberately not granted above; add `"sudo"` there if you want it.
|
||||||
- The `sys/mounts/*` rule lets this account create, change and **delete any secrets engine**, which destroys its data and revokes its leases. Remove it (and the New / Settings / Delete buttons will report permission denied) if mounts are managed elsewhere. Mounting, tuning and deleting do not need `sudo`.
|
- The `sys/mounts/*` rule lets this account create, change and **delete any secrets engine**, which destroys its data and revokes its leases. Remove it (and the New / Settings / Delete buttons will report permission denied) if mounts are managed elsewhere. Mounting, tuning and deleting do not need `sudo`.
|
||||||
- KV v2 settings (max versions, check-and-set) are stored by the engine at `<mount>/config`, so the policy only covers them on `secret/`. Creating another KV store with settings mounts it and then fails to save them; EnvBao tells you the store exists, and you can add `<mount>/config` to the policy and use **Settings**.
|
- KV v2 settings (max versions, check-and-set) are stored by the engine at `<mount>/config`, so the policy only covers them on `secret/`. Creating another KV store with settings mounts it and then fails to save them; EnvBao tells you the store exists, and you can add `<mount>/config` to the policy and use **Settings**.
|
||||||
- If your KV v2 mount is not `secret/`, change `secret/metadata/*` and `secret/config`. The dynamic-engine rules name the default mounts (`database/`, `aws/`, `ssh/`), so change those too, or repeat a block for each mount. They deliberately avoid a `+/roles/*` wildcard, which would also match system paths such as `sys/config/cors`.
|
- If your KV v2 mount is not `secret/`, change `secret/metadata/*`, `secret/data/*` and `secret/config`. The dynamic-engine rules name the default mounts (`database/`, `aws/`, `ssh/`), so change those too, or repeat a block for each mount. They deliberately avoid a `+/roles/*` wildcard, which would also match system paths such as `sys/config/cors`.
|
||||||
- Listing leases and revoking by prefix need `sudo` in OpenBao (looking up, renewing and revoking a single lease do not). Without it the Leases tab shows a permission error.
|
- Listing leases and revoking by prefix need `sudo` in OpenBao (looking up, renewing and revoking a single lease do not). Without it the Leases tab shows a permission error.
|
||||||
- The `creds`, `sign` and `static-creds` lines let this account issue live database logins, AWS keys and SSH certificates. Remove them if the account should manage roles without being able to use them.
|
- The `creds`, `sign` and `static-creds` lines let this account issue live database logins, AWS keys and SSH certificates. Remove them if the account should manage roles without being able to use them.
|
||||||
- The account can create policies and attach them to identities, which is effectively the power to grant access to anything. Treat it as an administrator.
|
- The account can create policies and attach them to identities, which is effectively the power to grant access to anything. Treat it as an administrator.
|
||||||
|
|||||||
@@ -0,0 +1,149 @@
|
|||||||
|
# Administrator guide
|
||||||
|
|
||||||
|
This guide is for the person who installs EnvBao Admin and prepares OpenBao for it. If you want to *use* the UI, see the [user guide](user-guide.md). The README has the short version of everything here.
|
||||||
|
|
||||||
|
## How it fits together
|
||||||
|
|
||||||
|
EnvBao Admin is a static single-page app. There is no server component and no database: your browser loads the page and then talks **directly** to the OpenBao HTTP API, using a token you sign in with. That has three consequences:
|
||||||
|
|
||||||
|
- OpenBao must allow the UI's origin with **CORS**.
|
||||||
|
- Every action is performed with, and limited by, the signed-in account's OpenBao policies. The UI cannot do anything that account could not do with the CLI.
|
||||||
|
- The token is held in the page's memory only. Reloading the page signs you out, and nothing is written to browser storage.
|
||||||
|
|
||||||
|
```
|
||||||
|
browser ──(loads static files)──▶ nginx / any static host
|
||||||
|
│
|
||||||
|
└──(HTTP API, X-Vault-Token, CORS)──▶ OpenBao
|
||||||
|
```
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- OpenBao 2.x, initialised and unsealed. (The UI refuses to connect to a sealed or uninitialised server and says so.)
|
||||||
|
- A KV v2 mount, normally `secret/`.
|
||||||
|
- The **userpass** auth method, if you want to manage users and sign in with a password.
|
||||||
|
- HTTPS for the UI and OpenBao in production. Browsers block an HTTPS page from calling an HTTP OpenBao.
|
||||||
|
|
||||||
|
## 1. Allow the UI's origin (CORS)
|
||||||
|
|
||||||
|
CORS is runtime configuration in OpenBao, not a listener setting:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
bao write sys/config/cors \
|
||||||
|
enabled=true \
|
||||||
|
allowed_origins="https://envbao.example.com" \
|
||||||
|
allowed_headers="X-Vault-Token,Content-Type"
|
||||||
|
```
|
||||||
|
|
||||||
|
`allowed_origins` is a comma-separated list of exact origins (scheme, host and port). Writing `sys/config/cors` **replaces the whole list**, so include every origin each time. Once CORS is enabled, OpenBao rejects any request whose `Origin` is not listed, including OpenBao's own web UI at `/ui`; add OpenBao's own address if you still use it.
|
||||||
|
|
||||||
|
| Where the UI runs | Origin to allow |
|
||||||
|
| --- | --- |
|
||||||
|
| `npm run dev` | `http://localhost:5173` |
|
||||||
|
| Docker image / compose | `http://localhost:8080` |
|
||||||
|
| Production | your UI's origin, e.g. `https://envbao.example.com` |
|
||||||
|
| OpenBao's own web UI | OpenBao's address, e.g. `http://localhost:8200` |
|
||||||
|
|
||||||
|
## 2. Enable what the UI manages
|
||||||
|
|
||||||
|
```sh
|
||||||
|
bao auth enable userpass
|
||||||
|
bao secrets enable -path=secret -version=2 kv # skip if it already exists
|
||||||
|
```
|
||||||
|
|
||||||
|
Dynamic secrets engines are optional. Mount them with the CLI or from the UI (**Secrets → New secrets engine**):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
bao secrets enable database
|
||||||
|
bao secrets enable ssh
|
||||||
|
bao secrets enable aws
|
||||||
|
```
|
||||||
|
|
||||||
|
Not every OpenBao build includes the AWS engine; if `bao secrets enable aws` reports `plugin not found in the catalog`, register the plugin first. The AWS screens follow the engine's documented API but have only been tested without a live AWS engine.
|
||||||
|
|
||||||
|
## 3. Create the administrator policy and login
|
||||||
|
|
||||||
|
The UI's account needs a policy. The least-privilege policy is [`envbao-admin.hcl`](envbao-admin.hcl) (it is also reproduced in the README), and the integration tests run every UI operation with only that policy.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
bao policy write envbao-admin docs/envbao-admin.hcl
|
||||||
|
bao write auth/userpass/users/admin password='...' token_policies=envbao-admin
|
||||||
|
# or, for a token:
|
||||||
|
bao token create -policy=envbao-admin
|
||||||
|
```
|
||||||
|
|
||||||
|
Things to know about this policy:
|
||||||
|
|
||||||
|
- **It is an administrator.** The account can create policies and attach them to identities, which is effectively the power to grant access to anything. Protect it accordingly.
|
||||||
|
- **Mount rules are powerful.** `sys/mounts/*` lets the account create, tune and **delete** any secrets engine. Deleting a mount destroys everything in it and revokes its leases. Remove that block if mounts are managed somewhere else; the Secrets page then shows permission errors on New, Settings and Delete.
|
||||||
|
- **The `creds`, `sign` and `static-creds` lines let the account issue live logins, keys and certificates.** Delete them if the account should manage roles without being able to use them.
|
||||||
|
- **Mount names.** The policy uses the default mount names (`secret/`, `database/`, `ssh/`, `aws/`). If yours differ, repeat the relevant block with your mount path.
|
||||||
|
- **KV settings** (max versions, check-and-set) are changed through `<mount>/config`. The policy grants this for `secret/` only; add a rule for any other KV mount you want to configure.
|
||||||
|
- **Applying a new release does not update the policy.** The deploy ships the UI only. When a release adds features (v0.2.0 added mount management), re-apply `docs/envbao-admin.hcl` with `bao policy write` yourself.
|
||||||
|
|
||||||
|
### Delegating
|
||||||
|
|
||||||
|
You do not have to give everyone the full policy. Anything the signed-in account is denied simply shows OpenBao's permission error in the UI. A common split is a smaller policy for people who only manage roles and grants and never mounts or leases.
|
||||||
|
|
||||||
|
## 4. Deploy the UI
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm ci
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
`dist/` is a static site. Serve it from any static host with a fallback to `index.html` for client-side routes, over HTTPS.
|
||||||
|
|
||||||
|
**Docker.** The release pipeline publishes `pkgs.daubney.dev/envbao/envbao-admin:<version>` and `:latest`. To build your own:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker build -t envbao-admin .
|
||||||
|
docker run -p 8080:80 envbao-admin
|
||||||
|
```
|
||||||
|
|
||||||
|
**nginx / Caddy.** See the README for sample configs. The bundled [`nginx.conf`](../nginx.conf) also sets security headers, including a Content-Security-Policy whose `connect-src` allows any `http:`/`https:` origin, because the OpenBao address is typed on the Connect screen. If you only ever use one OpenBao, tighten `connect-src` to its address.
|
||||||
|
|
||||||
|
There is no build-time or runtime configuration; the OpenBao URL is entered at sign-in.
|
||||||
|
|
||||||
|
## 5. Releases and the deploy pipeline
|
||||||
|
|
||||||
|
Releases are driven by tags in the `envbao-admin` repository:
|
||||||
|
|
||||||
|
1. Bump the version (`package.json`, `package-lock.json`) in a "Release vX.Y.Z" commit and tag it `vX.Y.Z`.
|
||||||
|
2. Pushing the tag runs `.gitea/workflows/release.yml`: lint, audit, unit tests and build; integration tests against OpenBao and Postgres service containers; then the image build and push; then a dispatch to the `EnvBaoAdminDeploy` repository, which runs its Ansible playbook against the host (Docker Compose in `/opt/envbao-admin`).
|
||||||
|
3. Tags containing a `-` (pre-releases) build the image but do not deploy.
|
||||||
|
|
||||||
|
If a release did not deploy, open the run in the Gitea Actions tab: the integration job is the usual place for a release to stop, and a failure there skips the image and the deploy. The deploy can be run by hand from the deploy repository's Actions tab with the tag as input.
|
||||||
|
|
||||||
|
Required secrets: in `envbao-admin`, `PKGS_USER`, `PKGS_PASSWORD` and `DEPLOY_DISPATCH_TOKEN` (a token that may run workflows in the deploy repository); in `EnvBaoAdminDeploy`, `DEPLOY_SSH_KEY`, `DEPLOY_KNOWN_HOSTS`, `PKGS_USER`, `PKGS_PASSWORD` and optionally `NOTIFY_*`.
|
||||||
|
|
||||||
|
## Security notes
|
||||||
|
|
||||||
|
- **Token handling.** The token lives in memory only and is sent only to the OpenBao URL you entered. Anyone who can run script in the page (an XSS bug, a malicious browser extension) could use it, so keep the CSP and serve the UI from a dedicated origin.
|
||||||
|
- **Credentials shown once.** Tokens and dynamic credentials appear when created and are never stored or cached by the UI. Password and private-key fields in configuration forms are write-only.
|
||||||
|
- **Secret values are write-only.** The Secrets page lists names and metadata only and cannot display KV secret values. **New secret** creates a secret (with `cas: 0`, so it can never overwrite one) and needs only `create` on `<mount>/data/*`.
|
||||||
|
- **Audit.** The UI has no audit trail of its own. Turn on an OpenBao audit device; every UI action appears there under the signed-in account.
|
||||||
|
- **Session length.** Sessions last as long as the token. Give the admin account a short TTL if you want people to sign in more often.
|
||||||
|
- **Managed policies.** Grants are stored as policies named `envbao-<kind>-<name>` with an `# envbao-owner:` header. If someone edits one outside EnvBao, the UI treats it as read-only rather than overwrite it. Other policies are shown read-only.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
| Symptom | Cause and fix |
|
||||||
|
| --- | --- |
|
||||||
|
| "Cannot reach OpenBao" or a CORS message on Connect | The UI's origin is not in `sys/config/cors`, or the URL is wrong, or an HTTPS page is calling an HTTP OpenBao. |
|
||||||
|
| OpenBao's own `/ui` stopped working after enabling CORS | Add OpenBao's own address to `allowed_origins`. |
|
||||||
|
| "Server is sealed" / "not initialised" | Unseal or initialise OpenBao. |
|
||||||
|
| Permission denied on New / Settings / Delete (Secrets) | The account's policy lacks `sys/mounts/*`. Re-apply `envbao-admin.hcl`. |
|
||||||
|
| Permission denied on Leases | Listing leases and revoking by prefix need `sudo` on `sys/leases/lookup/*` and `sys/leases/revoke-prefix/*`. The shipped policy includes it. |
|
||||||
|
| Token list is empty or incomplete | Listing token accessors needs `sudo` in OpenBao; the shipped policy includes it. |
|
||||||
|
| A banner says the session has expired | The token expired, was revoked, or OpenBao sealed. Sign in again. |
|
||||||
|
| A policy is read-only in the UI | It is not an EnvBao-managed policy, or it was edited outside EnvBao. Edit it with the CLI. |
|
||||||
|
| Mount created but "saving KV settings failed" | The account may change `sys/mounts` but not `<mount>/config`. Add a `config` rule for that mount. |
|
||||||
|
| A new release is out but nothing changed | Check the release run and the deploy run in Gitea Actions; the UI can also be cached, so hard-reload. |
|
||||||
|
|
||||||
|
## Trying it out: the demo stack
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker compose up --build
|
||||||
|
```
|
||||||
|
|
||||||
|
Open http://localhost:8080 and connect to `http://localhost:8200` with token `root`. This starts a throwaway in-memory OpenBao dev server, a Postgres and an SSH server wired to the database and SSH engines, and the UI, loaded with sample data from `docker/seed.sh` (users `alice`, `bob` and `carol`, password `password123`). It is not for production. The screenshots in these guides were taken from it.
|
||||||
@@ -33,6 +33,8 @@ path "sys/mounts/*" { capabilities = ["create", "read", "update", "delete
|
|||||||
# KV v2 settings (max versions, check-and-set) of the KV mount
|
# KV v2 settings (max versions, check-and-set) of the KV mount
|
||||||
path "secret/config" { capabilities = ["read", "update"] }
|
path "secret/config" { capabilities = ["read", "update"] }
|
||||||
path "secret/metadata/*" { capabilities = ["list"] }
|
path "secret/metadata/*" { capabilities = ["list"] }
|
||||||
|
# Creating a new KV v2 secret. Create only: values can't be read back and existing secrets can't be overwritten
|
||||||
|
path "secret/data/*" { capabilities = ["create"] }
|
||||||
|
|
||||||
# Dynamic secrets engines: roles, config, credentials and leases. The paths use the default mount
|
# Dynamic secrets engines: roles, config, credentials and leases. The paths use the default mount
|
||||||
# names (database/, aws/, ssh/); repeat a block with your own mount path for each engine you manage.
|
# names (database/, aws/, ssh/); repeat a block with your own mount path for each engine you manage.
|
||||||
|
|||||||
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 41 KiB |
|
After Width: | Height: | Size: 25 KiB |
@@ -0,0 +1,168 @@
|
|||||||
|
# User guide
|
||||||
|
|
||||||
|
EnvBao Admin lets you manage who can reach which secrets in OpenBao without writing policy HCL, and shows the result as a graph. This guide walks through the screens. If you are setting EnvBao up, see the [administrator guide](admin-guide.md).
|
||||||
|
|
||||||
|
The screenshots use the demo stack (`docker compose up`), whose sample data has users `alice`, `bob` and `carol`.
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
- [Signing in](#signing-in)
|
||||||
|
- [Identities](#identities)
|
||||||
|
- [Giving someone access](#giving-someone-access)
|
||||||
|
- [Secrets](#secrets)
|
||||||
|
- [Dynamic secrets engines](#dynamic-secrets-engines)
|
||||||
|
- [Managing secrets engines](#managing-secrets-engines)
|
||||||
|
- [The access graph](#the-access-graph)
|
||||||
|
- [Good to know](#good-to-know)
|
||||||
|
|
||||||
|
## Signing in
|
||||||
|
|
||||||
|
Open the UI and choose **Connect**. Enter the OpenBao URL and either a **token**, or choose **Userpass** and enter a username and password. Until you are signed in, only the Connect page is available.
|
||||||
|
|
||||||
|
When you are connected, the Connect page becomes a status page with the server's version and seal state and your session: who you are, your policies, and when the token expires. **Disconnect** signs you out.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Your session lasts as long as your token. When it expires, is revoked, or OpenBao is sealed, a banner links you back to sign in. Reloading the browser page also signs you out, because the token is only kept in memory.
|
||||||
|
|
||||||
|
What you can do depends on your OpenBao policy. If an action is not allowed for your account, OpenBao's "permission denied" message is shown.
|
||||||
|
|
||||||
|
## Identities
|
||||||
|
|
||||||
|
**Identities** has four tabs.
|
||||||
|
|
||||||
|
| Tab | What it is |
|
||||||
|
| --- | --- |
|
||||||
|
| **Users** | Userpass logins (username and password) and the policies attached to them. |
|
||||||
|
| **Entities** | OpenBao identity entities, with their userpass aliases. An entity ties one person's logins together. |
|
||||||
|
| **Groups** | Identity groups. Members inherit the group's policies. |
|
||||||
|
| **Tokens** | Standalone tokens. |
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Each row has **Access**, **Edit** and **Delete**. Use **New user** (or New entity, New group) under the table to create one. Policy chips in the table are green when EnvBao manages the policy and grey for policies it only displays.
|
||||||
|
|
||||||
|
### Tokens
|
||||||
|
|
||||||
|
The Tokens tab lists live tokens with their policies, expiry and accessor. **New token** creates one: set a display name, TTL, policies and whether it is renewable or orphaned. **The token's value is shown once**, right after creation. Copy it then; it cannot be shown again. **Revoke** ends a token immediately. Your own token is marked "(you)" and cannot be revoked here.
|
||||||
|
|
||||||
|
A token's policies are fixed when it is created, so you cannot grant access to an existing token afterwards. Choose its policies up front.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Giving someone access
|
||||||
|
|
||||||
|
Click **Access** on a user, entity or group. The panel has two halves.
|
||||||
|
|
||||||
|
- **Granted by EnvBao** (left): what you have granted through this UI, with a **Revoke** button on each line, and a **Show policy HCL** link if you want to see the policy it writes. Below it, **Other policies** lists anything attached to the identity that was set up outside EnvBao. Those are shown read-only.
|
||||||
|
- **Grant access** (right): the form to add something.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Granting access to a secret
|
||||||
|
|
||||||
|
1. Pick the **secrets engine** (a KV mount such as `secret/`).
|
||||||
|
2. Enter a **path within the mount**, for example `app/database`, or a glob such as `app/*` for everything under `app/`.
|
||||||
|
3. Tick the capabilities: read, create, update, delete, list.
|
||||||
|
4. Press **Grant**.
|
||||||
|
|
||||||
|
You enter the path as it appears inside the mount. EnvBao writes the underlying `data/` and `metadata/` policy paths for you. Granting a path that already has a grant replaces its capabilities.
|
||||||
|
|
||||||
|
### Granting access to a dynamic-engine role
|
||||||
|
|
||||||
|
Choose a database, AWS or SSH engine instead of KV, then pick a **role**, or tick *every role in the engine* to cover roles added later. Two permissions are offered:
|
||||||
|
|
||||||
|
- **Generate credentials**: the identity may request database logins, AWS keys, SSH certificates or one-time passwords from the role.
|
||||||
|
- **Manage role**: the identity may view, change and delete the role and list the engine's roles.
|
||||||
|
|
||||||
|
Unticking a permission and granting again removes it.
|
||||||
|
|
||||||
|
### How it is stored
|
||||||
|
|
||||||
|
For each identity, EnvBao keeps one policy named `envbao-<kind>-<name>` (for example `envbao-user-alice`). Edit such a policy outside EnvBao and the UI will show it read-only instead of overwriting your change.
|
||||||
|
|
||||||
|
## Secrets
|
||||||
|
|
||||||
|
**Secrets** is where you browse and manage secrets engines. At the top:
|
||||||
|
|
||||||
|
- **New secrets engine** adds a mount (see [Managing secrets engines](#managing-secrets-engines)).
|
||||||
|
- The **Secrets engine** drop-down chooses which engine to work with, with **Settings**, **Delete** and (for KV) **New secret** for that engine beside it.
|
||||||
|
|
||||||
|
For a **KV** engine you browse folders and secrets with the breadcrumb under the toolbar. Select a secret to see **who can reach it**: every identity with access, through which policy, and with which capabilities. **Grant access** on that panel opens the grant form for the secret.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
**New secret** (KV engines) adds a secret under the current folder: type a name such as `expo` and one or more key/value pairs. Values are write-only. EnvBao never reads or displays a secret's value, and it refuses to overwrite an existing secret. OpenBao applies the most specific matching policy path, and the table follows the same rule. It does not evaluate parameter constraints, control groups, MFA or templated paths (templated paths are approximated), so a policy using those may be over-reported and is flagged.
|
||||||
|
|
||||||
|
## Dynamic secrets engines
|
||||||
|
|
||||||
|
Database, AWS and SSH engines issue short-lived credentials on request instead of storing fixed secrets. Choosing one of these engines shows three tabs: **Roles**, **Config** and **Leases**. Any other engine type gets a raw JSON role editor only.
|
||||||
|
|
||||||
|
### Roles
|
||||||
|
|
||||||
|
A role describes what to hand out: for the database engine, the SQL that creates a login and its TTLs; for SSH, the certificate rules; for AWS, the policy or IAM settings. The database engine has **Dynamic roles** (a new login each time) and **Static roles** (one fixed login whose password OpenBao rotates).
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- **New role** creates one, and **Edit** changes it. TTLs accept values like `30m` or `1h`. Multi-statement SQL fields take statements separated by a blank line.
|
||||||
|
- **Access** shows who can already use the role, and lets you grant it.
|
||||||
|
- **Delete** removes the role. Credentials already issued from it stay valid until their leases end.
|
||||||
|
|
||||||
|
### Generate credentials
|
||||||
|
|
||||||
|
**Generate** asks OpenBao for credentials from the role: a database login, AWS keys, a signed SSH certificate (paste a public key first), or a one-time password. They appear **once**. Copy them straight away; they are not stored and cannot be shown again. **Revoke now** ends the lease immediately.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Config
|
||||||
|
|
||||||
|
Engine-level settings. For the database engine this is the list of **connections**: the connection URL (with `{{username}}` and `{{password}}` templates), and the roles each connection allows. You can add a connection, edit one, rotate its root credentials and reset it. For SSH it is the signing CA; for AWS the root credentials and lease settings. Password and private-key fields are **write-only**: leave one blank when editing to keep the stored value.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Leases
|
||||||
|
|
||||||
|
Every credential an engine issues has a lease. The tab lets you browse them by role, open **Details** (issued, expires, time remaining, last renewal), **Renew** one if it is renewable, **Revoke** one, or **Revoke all under this prefix** for everything beneath the folder you are in. Revoking makes the credentials stop working at once. Credentials with no lease, such as database static roles, cannot be revoked here.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Managing secrets engines
|
||||||
|
|
||||||
|
### Create
|
||||||
|
|
||||||
|
**New secrets engine** opens a form. Choose a **type** (KV v2, database, AWS or SSH), a **path** (lower-case letters, digits, `-` and `_`, with optional `/` segments; it cannot overlap an existing mount or use a reserved name like `sys`), an optional description, and the type's settings: for KV, max versions, check-and-set and automatic version deletion; for the others, default and maximum lease TTLs. The new engine is selected when it has been created.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
If creating a KV engine succeeds but saving its KV settings fails, the page says so, and the engine remains mounted.
|
||||||
|
|
||||||
|
### Change
|
||||||
|
|
||||||
|
**Settings** edits the description and the settings above. The path and type cannot be changed, and there is no rename.
|
||||||
|
|
||||||
|
### Delete
|
||||||
|
|
||||||
|
**Delete** asks you to type the engine's path before it will proceed, and tells you what you would lose: the number of secrets, roles or leases, and the policies that still mention the engine. Deleting an engine permanently destroys everything in it and revokes all its leases. **It cannot be undone.** Policies that refer to a deleted engine are left in place.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## The access graph
|
||||||
|
|
||||||
|
**Graph** draws identity → policy → path. Identities are on the left, policies in the middle and the paths they grant on the right, with capabilities on the lines. Bold policies are managed by EnvBao, and a dashed policy is attached to something but does not exist. Identities include the policies they inherit through entities and groups.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- **Click a box** to highlight every line connected to it and fade the rest; the side panel shows its details.
|
||||||
|
- **Click a line** between a policy and a path to see the grant, and revoke it.
|
||||||
|
- Use the **Identity** and **Path** filters to narrow a busy graph, **Hide the default policy** to cut noise, and **Refresh** to reload.
|
||||||
|
- Zoom and pan with the controls or your mouse.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Good to know
|
||||||
|
|
||||||
|
- **Copy it now.** Tokens and generated credentials are shown once only.
|
||||||
|
- **Write-only values.** Secret values can be created but are never shown, and existing secrets can't be changed here.
|
||||||
|
- **Whole-instance reads.** The graph and Access panels read every user, entity, group, token and policy each time they load, which can be slow on very large instances.
|
||||||
|
- **Not everything is managed here.** Auth methods other than userpass, nested groups and non-userpass aliases are not followed, and KV v1 mounts are not shown. See the README's limitations for the full list.
|
||||||
|
- **Policies you did not create are read-only.** Change those with the OpenBao CLI.
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "envbao-admin",
|
"name": "envbao-admin",
|
||||||
"version": "0.2.1",
|
"version": "0.3.3",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "envbao-admin",
|
"name": "envbao-admin",
|
||||||
"version": "0.2.1",
|
"version": "0.3.3",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tanstack/react-query": "^5.104.5",
|
"@tanstack/react-query": "^5.104.5",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "envbao-admin",
|
"name": "envbao-admin",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.2.1",
|
"version": "0.3.3",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -71,3 +71,13 @@ describe('access model vs sys/capabilities-self', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('writeSecret', () => {
|
||||||
|
test('creates a secret once and refuses to overwrite it', async () => {
|
||||||
|
const path = `it-${sfx}/new/expo`
|
||||||
|
await secrets.writeSecret(client, 'secret/', path, { TOKEN: 'v1' })
|
||||||
|
await expect(secrets.writeSecret(client, 'secret/', path, { TOKEN: 'v2' })).rejects.toThrow()
|
||||||
|
const res = await client.request<{ data: { data: Record<string, string> } }>('GET', `secret/data/${path}`)
|
||||||
|
expect(res.data.data).toEqual({ TOKEN: 'v1' })
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -72,6 +72,14 @@ export async function listSecrets(c: BaoClient, mount: string, prefix: string):
|
|||||||
/** API path of a secret's data, which is what ACL policies are written against. */
|
/** API path of a secret's data, which is what ACL policies are written against. */
|
||||||
export const dataPath = (mount: string, secret: string) => `${mount}data/${secret}`
|
export const dataPath = (mount: string, secret: string) => `${mount}data/${secret}`
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new KV v2 secret. `cas: 0` makes OpenBao refuse if the secret already exists, so this can never
|
||||||
|
* overwrite a value (and only needs the `create` capability).
|
||||||
|
*/
|
||||||
|
export async function writeSecret(c: BaoClient, mount: string, path: string, data: Record<string, string>): Promise<void> {
|
||||||
|
await c.request('POST', dataPath(mount, enc(path)), { data, options: { cas: 0 } })
|
||||||
|
}
|
||||||
|
|
||||||
export async function readPolicyHcl(c: BaoClient, name: string): Promise<string | null> {
|
export async function readPolicyHcl(c: BaoClient, name: string): Promise<string | null> {
|
||||||
try {
|
try {
|
||||||
const res = await c.request<{ data: { policy: string } }>('GET', `sys/policies/acl/${encodeURIComponent(name)}`)
|
const res = await c.request<{ data: { policy: string } }>('GET', `sys/policies/acl/${encodeURIComponent(name)}`)
|
||||||
|
|||||||
@@ -43,6 +43,12 @@ test('shows issued credentials once, and keeps them out of every cache', async (
|
|||||||
expect(qc.getMutationCache().getAll()).toHaveLength(0)
|
expect(qc.getMutationCache().getAll()).toHaveLength(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('a role that takes no input offers just Generate, with no raw JSON box', () => {
|
||||||
|
setup('database')
|
||||||
|
expect(screen.getByRole('form', { name: 'Generate credentials for ro' })).toBeInTheDocument()
|
||||||
|
expect(screen.queryByLabelText(/JSON/)).not.toBeInTheDocument()
|
||||||
|
})
|
||||||
|
|
||||||
test('revokes the lease on request', async () => {
|
test('revokes the lease on request', async () => {
|
||||||
vi.mocked(creds.generateCreds).mockResolvedValue(issued)
|
vi.mocked(creds.generateCreds).mockResolvedValue(issued)
|
||||||
vi.mocked(leases.revokeLease).mockResolvedValue()
|
vi.mocked(leases.revokeLease).mockResolvedValue()
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ export function GenerateCreds({
|
|||||||
key={kind.id}
|
key={kind.id}
|
||||||
kind={{ fields: kind.inputs }}
|
kind={{ fields: kind.inputs }}
|
||||||
noun={`${kind.label.toLowerCase()} for ${role}`}
|
noun={`${kind.label.toLowerCase()} for ${role}`}
|
||||||
|
title={`${kind.label} for ${role}`}
|
||||||
|
rawJson={false}
|
||||||
showName={false}
|
showName={false}
|
||||||
submitLabel="Generate"
|
submitLabel="Generate"
|
||||||
draft={draft}
|
draft={draft}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ function LeaseRow({ client, id, name, onChanged }: { client: BaoClient; id: stri
|
|||||||
const revoke = useMutation({ mutationFn: () => revokeLease(client, id), onSuccess: onChanged })
|
const revoke = useMutation({ mutationFn: () => revokeLease(client, id), onSuccess: onChanged })
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li>
|
<li className="lease-row">
|
||||||
<span>{name}</span>
|
<span>{name}</span>
|
||||||
<button type="button" aria-expanded={open} aria-label={`Details ${name}`} onClick={() => setOpen(!open)}>
|
<button type="button" aria-expanded={open} aria-label={`Details ${name}`} onClick={() => setOpen(!open)}>
|
||||||
Details
|
Details
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||||
|
import { useState } from 'react'
|
||||||
|
import type { BaoClient } from '../../api/bao'
|
||||||
|
import { writeSecret } from '../../api/secrets'
|
||||||
|
import { validateSecretPath } from '../../model/mounts'
|
||||||
|
|
||||||
|
interface Row {
|
||||||
|
key: string
|
||||||
|
value: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Create a new KV v2 secret under the current path. Values are write-only and existing secrets are never overwritten. */
|
||||||
|
export function NewSecretDialog({ client, mount, prefix, onClose, onDone }: {
|
||||||
|
client: BaoClient
|
||||||
|
mount: string
|
||||||
|
prefix: string
|
||||||
|
onClose: () => void
|
||||||
|
onDone: (path: string) => void
|
||||||
|
}) {
|
||||||
|
const qc = useQueryClient()
|
||||||
|
const [name, setName] = useState('')
|
||||||
|
const [rows, setRows] = useState<Row[]>([{ key: '', value: '' }])
|
||||||
|
const [formError, setFormError] = useState<string | null>(null)
|
||||||
|
|
||||||
|
const create = useMutation({
|
||||||
|
mutationFn: async () => {
|
||||||
|
const path = prefix + name.trim()
|
||||||
|
const data: Record<string, string> = {}
|
||||||
|
for (const r of rows) data[r.key.trim()] = r.value
|
||||||
|
await writeSecret(client, mount, path, data)
|
||||||
|
await qc.invalidateQueries({ queryKey: ['kv-list'] })
|
||||||
|
return path
|
||||||
|
},
|
||||||
|
onSuccess: (path) => onDone(path),
|
||||||
|
})
|
||||||
|
|
||||||
|
const setRow = (i: number, patch: Partial<Row>) => setRows(rows.map((r, j) => (j === i ? { ...r, ...patch } : r)))
|
||||||
|
|
||||||
|
function submit(e: React.FormEvent) {
|
||||||
|
e.preventDefault()
|
||||||
|
setFormError(null)
|
||||||
|
const nameError = validateSecretPath(name.trim())
|
||||||
|
if (nameError) return setFormError(nameError)
|
||||||
|
const keys = rows.map((r) => r.key.trim())
|
||||||
|
if (keys.some((k) => !k)) return setFormError('Every key needs a name.')
|
||||||
|
if (new Set(keys).size !== keys.length) return setFormError('Keys must be unique.')
|
||||||
|
create.mutate()
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section aria-label="New secret" className="mount-dialog">
|
||||||
|
<form aria-label="New secret form" onSubmit={submit}>
|
||||||
|
<label>
|
||||||
|
Name
|
||||||
|
<span className="hint"> in {mount}{prefix}</span>
|
||||||
|
<input value={name} onChange={(e) => setName(e.target.value)} placeholder="expo" autoComplete="off" />
|
||||||
|
</label>
|
||||||
|
<div className="kv-rows">
|
||||||
|
{rows.map((r, i) => (
|
||||||
|
<div className="kv-row" key={i}>
|
||||||
|
<input aria-label={`Key ${i + 1}`} placeholder="key" value={r.key} autoComplete="off" onChange={(e) => setRow(i, { key: e.target.value })} />
|
||||||
|
<input aria-label={`Value ${i + 1}`} type="password" placeholder="value" value={r.value} autoComplete="new-password" onChange={(e) => setRow(i, { value: e.target.value })} />
|
||||||
|
<button type="button" disabled={rows.length === 1} onClick={() => setRows(rows.filter((_, j) => j !== i))}>
|
||||||
|
Remove
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
<div>
|
||||||
|
<button type="button" onClick={() => setRows([...rows, { key: '', value: '' }])}>
|
||||||
|
Add key
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p className="hint">Values are write-only: they are never shown again, and an existing secret is never overwritten.</p>
|
||||||
|
{(formError ?? create.error) && <p role="alert">{formError ?? create.error?.message}</p>}
|
||||||
|
<button type="submit" disabled={create.isPending}>
|
||||||
|
{create.isPending ? 'Saving…' : 'Create'}
|
||||||
|
</button>
|
||||||
|
<button type="button" onClick={onClose}>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -99,6 +99,8 @@ export function RoleEditor({
|
|||||||
noun = 'role',
|
noun = 'role',
|
||||||
showName = true,
|
showName = true,
|
||||||
nameLabel,
|
nameLabel,
|
||||||
|
title: titleOverride,
|
||||||
|
rawJson = true,
|
||||||
submitLabel = 'Save',
|
submitLabel = 'Save',
|
||||||
draft,
|
draft,
|
||||||
pending,
|
pending,
|
||||||
@@ -114,6 +116,10 @@ export function RoleEditor({
|
|||||||
showName?: boolean
|
showName?: boolean
|
||||||
/** Label for the name field; defaults to "<Noun> name". */
|
/** Label for the name field; defaults to "<Noun> name". */
|
||||||
nameLabel?: string
|
nameLabel?: string
|
||||||
|
/** Replaces the generated form title. */
|
||||||
|
title?: string
|
||||||
|
/** Show a raw JSON box when the schema has no fields (generic engines). False for forms that take no input. */
|
||||||
|
rawJson?: boolean
|
||||||
submitLabel?: string
|
submitLabel?: string
|
||||||
draft: RoleDraft
|
draft: RoleDraft
|
||||||
pending: boolean
|
pending: boolean
|
||||||
@@ -122,7 +128,7 @@ export function RoleEditor({
|
|||||||
onSubmit: () => void
|
onSubmit: () => void
|
||||||
onCancel: () => void
|
onCancel: () => void
|
||||||
}) {
|
}) {
|
||||||
const title = draft.isNew ? `New ${noun}` : showName ? `Edit ${draft.name}` : `Edit ${noun}`
|
const title = titleOverride ?? (draft.isNew ? `New ${noun}` : showName ? `Edit ${draft.name}` : `Edit ${noun}`)
|
||||||
function submit(e: FormEvent) {
|
function submit(e: FormEvent) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
onSubmit()
|
onSubmit()
|
||||||
@@ -137,10 +143,12 @@ export function RoleEditor({
|
|||||||
</label>
|
</label>
|
||||||
)}
|
)}
|
||||||
{kind.fields.length === 0 ? (
|
{kind.fields.length === 0 ? (
|
||||||
<label>
|
rawJson && (
|
||||||
Role (JSON)
|
<label>
|
||||||
|
Role (JSON)
|
||||||
<textarea value={draft.json} onChange={(e) => onChange({ ...draft, json: e.target.value })} rows={10} spellCheck={false} />
|
<textarea value={draft.json} onChange={(e) => onChange({ ...draft, json: e.target.value })} rows={10} spellCheck={false} />
|
||||||
</label>
|
</label>
|
||||||
|
)
|
||||||
) : (
|
) : (
|
||||||
kind.fields.map((f) => (
|
kind.fields.map((f) => (
|
||||||
<Field
|
<Field
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { SecretsPage } from './SecretsPage'
|
|||||||
|
|
||||||
vi.mock('../../api/grants')
|
vi.mock('../../api/grants')
|
||||||
vi.mock('../../api/identities')
|
vi.mock('../../api/identities')
|
||||||
vi.mock('../../api/secrets', async (orig) => ({ ...(await orig<typeof api>()), listMounts: vi.fn(), listSecrets: vi.fn(), readPolicyHcl: vi.fn() }))
|
vi.mock('../../api/secrets', async (orig) => ({ ...(await orig<typeof api>()), listMounts: vi.fn(), listSecrets: vi.fn(), readPolicyHcl: vi.fn(), writeSecret: vi.fn() }))
|
||||||
vi.mock('../../api/tokens')
|
vi.mock('../../api/tokens')
|
||||||
vi.mock('../../api/mounts', async (orig) => ({ ...(await orig<typeof mountsApi>()), createMount: vi.fn(), tuneMount: vi.fn(), readKvConfig: vi.fn(), deleteMount: vi.fn(), mountImpact: vi.fn() }))
|
vi.mock('../../api/mounts', async (orig) => ({ ...(await orig<typeof mountsApi>()), createMount: vi.fn(), tuneMount: vi.fn(), readKvConfig: vi.fn(), deleteMount: vi.fn(), mountImpact: vi.fn() }))
|
||||||
|
|
||||||
@@ -292,3 +292,28 @@ test('asks to connect first', () => {
|
|||||||
)
|
)
|
||||||
expect(screen.getByText(/Not connected/)).toBeInTheDocument()
|
expect(screen.getByText(/Not connected/)).toBeInTheDocument()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('adds a new secret under the current folder', async () => {
|
||||||
|
vi.mocked(api.writeSecret).mockResolvedValue()
|
||||||
|
const user = userEvent.setup()
|
||||||
|
render(
|
||||||
|
<QueryClientProvider client={new QueryClient({ defaultOptions: { queries: { retry: false } } })}>
|
||||||
|
<SessionProvider>
|
||||||
|
<MemoryRouter>
|
||||||
|
<Connected />
|
||||||
|
<SecretsPage />
|
||||||
|
</MemoryRouter>
|
||||||
|
</SessionProvider>
|
||||||
|
</QueryClientProvider>,
|
||||||
|
)
|
||||||
|
await user.click(screen.getByRole('button', { name: 'go' }))
|
||||||
|
await user.click(await screen.findByRole('button', { name: 'app/' }))
|
||||||
|
await user.click(await screen.findByRole('button', { name: 'New secret' }))
|
||||||
|
await user.click(screen.getByRole('button', { name: 'Create' }))
|
||||||
|
expect(screen.getByRole('alert')).toHaveTextContent('Name is required.')
|
||||||
|
await user.type(screen.getByLabelText(/^Name/), 'expo')
|
||||||
|
await user.type(screen.getByLabelText('Key 1'), 'TOKEN')
|
||||||
|
await user.type(screen.getByLabelText('Value 1'), 's3cret')
|
||||||
|
await user.click(screen.getByRole('button', { name: 'Create' }))
|
||||||
|
expect(api.writeSecret).toHaveBeenCalledWith(client, 'secret/', 'app/expo', { TOKEN: 's3cret' })
|
||||||
|
})
|
||||||
@@ -9,6 +9,7 @@ import { AccessPanel } from './AccessPanel'
|
|||||||
import { DeleteMountDialog } from './DeleteMountDialog'
|
import { DeleteMountDialog } from './DeleteMountDialog'
|
||||||
import { EngineView } from './EngineView'
|
import { EngineView } from './EngineView'
|
||||||
import { MountDialog } from './MountDialog'
|
import { MountDialog } from './MountDialog'
|
||||||
|
import { NewSecretDialog } from './NewSecretDialog'
|
||||||
|
|
||||||
function Browser({ client }: { client: BaoClient }) {
|
function Browser({ client }: { client: BaoClient }) {
|
||||||
const mounts = useMounts(client)
|
const mounts = useMounts(client)
|
||||||
@@ -16,7 +17,7 @@ function Browser({ client }: { client: BaoClient }) {
|
|||||||
const [mountChoice, setMount] = useState<string | null>(null)
|
const [mountChoice, setMount] = useState<string | null>(null)
|
||||||
const [prefix, setPrefix] = useState('')
|
const [prefix, setPrefix] = useState('')
|
||||||
const [selected, setSelected] = useState<string | null>(null)
|
const [selected, setSelected] = useState<string | null>(null)
|
||||||
const [dialog, setDialog] = useState<'create' | 'edit' | 'delete' | null>(null)
|
const [dialog, setDialog] = useState<'create' | 'edit' | 'delete' | 'secret' | null>(null)
|
||||||
|
|
||||||
const current = mounts.data?.find((m) => m.path === mountChoice) ?? mounts.data?.[0] ?? null
|
const current = mounts.data?.find((m) => m.path === mountChoice) ?? mounts.data?.[0] ?? null
|
||||||
const mount = current?.path ?? null
|
const mount = current?.path ?? null
|
||||||
@@ -58,7 +59,7 @@ function Browser({ client }: { client: BaoClient }) {
|
|||||||
go('')
|
go('')
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
) : dialog && dialog !== 'delete' && (
|
) : dialog && dialog !== 'delete' && dialog !== 'secret' && (
|
||||||
<MountDialog
|
<MountDialog
|
||||||
// Remount per mount so one mount's settings are never shown (or saved) for another.
|
// Remount per mount so one mount's settings are never shown (or saved) for another.
|
||||||
key={dialog === 'edit' ? current?.path : 'create'}
|
key={dialog === 'edit' ? current?.path : 'create'}
|
||||||
@@ -132,12 +133,32 @@ function Browser({ client }: { client: BaoClient }) {
|
|||||||
Settings
|
Settings
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
{isKv && (
|
||||||
|
<button type="button" onClick={() => setDialog(dialog === 'secret' ? null : 'secret')} aria-expanded={dialog === 'secret'}>
|
||||||
|
New secret
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
<button type="button" onClick={() => setDialog(dialog === 'delete' ? null : 'delete')} aria-expanded={dialog === 'delete'}>
|
<button type="button" onClick={() => setDialog(dialog === 'delete' ? null : 'delete')} aria-expanded={dialog === 'delete'}>
|
||||||
Delete
|
Delete
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{dialogs}
|
{dialogs}
|
||||||
|
{dialog === 'secret' && isKv && (
|
||||||
|
<NewSecretDialog
|
||||||
|
key={`${mount}${prefix}`}
|
||||||
|
client={client}
|
||||||
|
mount={mount}
|
||||||
|
prefix={prefix}
|
||||||
|
onClose={closeDialog}
|
||||||
|
onDone={(path) => {
|
||||||
|
closeDialog()
|
||||||
|
const folder = path.includes('/') ? path.slice(0, path.lastIndexOf('/') + 1) : ''
|
||||||
|
setPrefix(folder)
|
||||||
|
setSelected(path)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -491,6 +491,39 @@ td:last-child button + button {
|
|||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* A lease is a row with its own actions, not a folder link: undo the full-width entry button style. */
|
||||||
|
.entries .lease-row {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--s2);
|
||||||
|
padding: var(--s2) var(--s4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.entries .lease-row > span {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
font-family: var(--mono);
|
||||||
|
}
|
||||||
|
|
||||||
|
.entries .lease-row button {
|
||||||
|
display: inline-block;
|
||||||
|
width: auto;
|
||||||
|
padding: 0.4rem var(--s3);
|
||||||
|
text-align: center;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: var(--text-sm);
|
||||||
|
background: var(--surface);
|
||||||
|
border: 1px solid var(--line-strong);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
.entries .lease-row > :is(p, dl) {
|
||||||
|
flex-basis: 100%;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.entries [aria-pressed='true'] {
|
.entries [aria-pressed='true'] {
|
||||||
background: var(--accent-soft);
|
background: var(--accent-soft);
|
||||||
color: var(--accent);
|
color: var(--accent);
|
||||||
@@ -1540,3 +1573,16 @@ button.danger-solid:hover:not(:disabled) {
|
|||||||
border: 1px solid var(--line);
|
border: 1px solid var(--line);
|
||||||
border-radius: var(--radius);
|
border-radius: var(--radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* New secret form: key/value rows. */
|
||||||
|
.kv-rows {
|
||||||
|
display: grid;
|
||||||
|
gap: var(--s2);
|
||||||
|
margin: var(--s3) 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.kv-row {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--s2);
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { expect, test } from 'vitest'
|
import { expect, test } from 'vitest'
|
||||||
import { policiesReferencing, validateMountPath } from './mounts'
|
import { policiesReferencing, validateMountPath, validateSecretPath } from './mounts'
|
||||||
|
|
||||||
const existing = ['secret/', 'database/', 'team/kv/']
|
const existing = ['secret/', 'database/', 'team/kv/']
|
||||||
|
|
||||||
@@ -38,3 +38,8 @@ test('finds policies with rules under a mount, however the mount is written', ()
|
|||||||
expect(policiesReferencing(policies, 'secret')).toEqual(['a-uses', 'b-uses'])
|
expect(policiesReferencing(policies, 'secret')).toEqual(['a-uses', 'b-uses'])
|
||||||
expect(policiesReferencing(policies, 'nothing/')).toEqual([])
|
expect(policiesReferencing(policies, 'nothing/')).toEqual([])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('validateSecretPath accepts plain and nested names and rejects bad ones', () => {
|
||||||
|
for (const p of ['expo', 'shell/expo', 'a b']) expect(validateSecretPath(p), p).toBeNull()
|
||||||
|
for (const p of ['', ' x', '/x', 'x/', 'a//b', 'a/../b', '.']) expect(validateSecretPath(p), p).not.toBeNull()
|
||||||
|
})
|
||||||
@@ -42,3 +42,14 @@ export function policiesReferencing(policies: PolicyText[], mount: string): stri
|
|||||||
.map((p) => p.name)
|
.map((p) => p.name)
|
||||||
.sort((a, b) => a.localeCompare(b))
|
.sort((a, b) => a.localeCompare(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Error message for a secret name/path (relative to a KV mount) that can't be used, or null. */
|
||||||
|
export function validateSecretPath(path: string): string | null {
|
||||||
|
if (!path.trim()) return 'Name is required.'
|
||||||
|
if (path !== path.trim()) return 'Name must not start or end with spaces.'
|
||||||
|
if (path.startsWith('/') || path.endsWith('/')) return 'Name must not start or end with "/".'
|
||||||
|
const parts = path.split('/')
|
||||||
|
if (parts.some((p) => !p)) return 'Name must not contain empty parts ("//").'
|
||||||
|
if (parts.some((p) => p === '.' || p === '..')) return 'Name must not contain "." or ".." parts.'
|
||||||
|
return null
|
||||||
|
}
|
||||||
@@ -4,6 +4,10 @@ import { defineConfig } from 'vitest/config'
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
test: {
|
test: {
|
||||||
include: ['src/**/*.integration.test.ts'],
|
include: ['src/**/*.integration.test.ts'],
|
||||||
testTimeout: 15000,
|
testTimeout: 30000,
|
||||||
|
// Generating an SSH CA key in a beforeAll took over 10s on the CI runner.
|
||||||
|
hookTimeout: 60000,
|
||||||
|
// The files share one OpenBao and one Postgres: concurrent role creation fails with "tuple concurrently updated".
|
||||||
|
fileParallelism: false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||