From 7f9371fad01f25c45b407f700956dc730979f0b0 Mon Sep 17 00:00:00 2001 From: Manuthor Date: Sun, 15 Nov 2026 09:12:54 +0100 Subject: [PATCH 01/11] feat!: serve Vault client routes only under /v1/auth and add userpass login --- CHANGELOG.md | 10 ++ admin-ui/src/constants/apiPaths.ts | 2 +- admin-ui/src/types/api.ts | 2 +- .../tests/e2e/machine-credentials.spec.ts | 2 +- client/src/client/auth_client.rs | 18 +-- client/src/dto/app_auth.rs | 8 +- server/auth_verifier.spire.toml | 2 +- server/documentation/docs/api_reference.md | 10 +- server/documentation/docs/app_auth_api.md | 63 +++++++--- .../docs/authentication_flows.md | 30 ++--- .../docs/server_configuration.md | 16 +++ server/documentation/openapi.yaml | 14 +-- server/src/server/auth_verifier.rs | 50 +++++--- server/src/server/endpoints/approle.rs | 4 +- server/src/server/endpoints/auth_token.rs | 12 +- server/src/server/endpoints/kubernetes.rs | 4 +- server/src/server/endpoints/mod.rs | 3 + server/src/server/endpoints/userpass_login.rs | 113 ++++++++++++++++++ server/src/server/parameters/server_params.rs | 6 + server/src/tests/app_auth_tests.rs | 111 ++++++++++++++++- server/src/tests/params.rs | 1 + 21 files changed, 389 insertions(+), 92 deletions(-) create mode 100644 server/src/server/endpoints/userpass_login.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f420951..24183c4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ All notable changes to this project will be documented in this file. +## [Unreleased] + +### ⚠️ Breaking changes + +- Vault client routes (`approle/login`, `kubernetes/login`, `token/*`) are now served only under `/v1/auth/*`; the unprefixed paths return `404`. Requires Eviden KMS ≥ the release that calls `/v1/auth/token/lookup-self`. Admin CRUD routes (`/auth/approle/role/...`, `/auth/kubernetes/role/...`) are unchanged. + +### Vault userpass login + +- Add `POST/PUT /v1/auth/userpass/login/{username}` (`bao login -method=userpass`), backed by the userpass accounts of the realm named by the new `vault_userpass_realm` setting; disabled when unset. + ## [0.5.0] - 2026-10-26 Replaces the 0.5.0 tag of 2026-10-20, withdrawn because it was cut before the version bump: its packages and images reported version 0.4.0. diff --git a/admin-ui/src/constants/apiPaths.ts b/admin-ui/src/constants/apiPaths.ts index c47676f6..f2c918bd 100644 --- a/admin-ui/src/constants/apiPaths.ts +++ b/admin-ui/src/constants/apiPaths.ts @@ -7,7 +7,7 @@ export const API_VERSION = "/public/version"; /** Machine-credential (Vault-compatible) auth method roots. Global, not realm-scoped. */ export const API_APPROLE = "/auth/approle"; export const API_KUBERNETES = "/auth/kubernetes"; -export const API_TOKEN = "/auth/token"; +export const API_TOKEN = "/v1/auth/token"; /** The special super-admin realm sentinel */ export const SUPER_ADMIN_REALM_ID = "_"; diff --git a/admin-ui/src/types/api.ts b/admin-ui/src/types/api.ts index ce0c7e6a..87529db6 100644 --- a/admin-ui/src/types/api.ts +++ b/admin-ui/src/types/api.ts @@ -254,7 +254,7 @@ export interface K8sRoleRequest { bound_audiences: string[]; } -/** Token metadata returned by GET /auth/token/lookup-self. */ +/** Token metadata returned by GET /v1/auth/token/lookup-self. */ export interface TokenInfo { id: string; entity_id: string; diff --git a/admin-ui/tests/e2e/machine-credentials.spec.ts b/admin-ui/tests/e2e/machine-credentials.spec.ts index a12742a7..7e8cc823 100644 --- a/admin-ui/tests/e2e/machine-credentials.spec.ts +++ b/admin-ui/tests/e2e/machine-credentials.spec.ts @@ -153,7 +153,7 @@ async function mockK8s(page: Page, initial: Record): Prom async function mockToken(page: Page, valid: boolean): Promise { let renewed = false; await page.route( - (url) => url.pathname.startsWith("/auth/token/"), + (url) => url.pathname.startsWith("/v1/auth/token/"), (route) => { const { pathname } = new URL(route.request().url()); const hasToken = Boolean(route.request().headers()["x-vault-token"]); diff --git a/client/src/client/auth_client.rs b/client/src/client/auth_client.rs index 2c8c715c..bf8807e0 100644 --- a/client/src/client/auth_client.rs +++ b/client/src/client/auth_client.rs @@ -889,7 +889,7 @@ impl AuthClient { ) -> AuthResult { use crate::dto::AppRoleLoginRequest; self.post( - "/auth/approle/login", + "/v1/auth/approle/login", &AppRoleLoginRequest { role_id: role_id.to_string(), secret_id: secret_id.map(str::to_string), @@ -950,7 +950,7 @@ impl AuthClient { /// No authentication required. pub async fn k8s_login(&self, role: &str, jwt: &str) -> AuthResult { self.post( - "/auth/kubernetes/login", + "/v1/auth/kubernetes/login", &K8sLoginRequest { role: role.to_string(), jwt: jwt.to_string(), @@ -966,10 +966,10 @@ impl AuthClient { pub const APP_TOKEN_HEADER: &str = "X-Vault-Token"; impl AuthClient { - /// Return metadata for an app token (`GET /auth/token/lookup-self`). + /// Return metadata for an app token (`GET /v1/auth/token/lookup-self`). pub async fn token_lookup_self(&self, token: &str) -> AuthResult { let response = self - .get_raw_with_header("/auth/token/lookup-self", APP_TOKEN_HEADER, token) + .get_raw_with_header("/v1/auth/token/lookup-self", APP_TOKEN_HEADER, token) .await .map_err(|e| AuthError::Generic(format!("lookup-self GET failed: {e}")))?; let status = response.status(); @@ -985,11 +985,11 @@ impl AuthClient { .map_err(|e| AuthError::Generic(format!("failed to parse lookup-self response: {e}"))) } - /// Renew an app token (`POST /auth/token/renew-self`). + /// Renew an app token (`POST /v1/auth/token/renew-self`). pub async fn token_renew_self(&self, token: &str) -> AuthResult { let response = self .post_raw_with_header( - "/auth/token/renew-self", + "/v1/auth/token/renew-self", &serde_json::json!({}), APP_TOKEN_HEADER, token, @@ -1009,11 +1009,11 @@ impl AuthClient { .map_err(|e| AuthError::Generic(format!("failed to parse renew-self response: {e}"))) } - /// Revoke an app token (`POST /auth/token/revoke-self`). + /// Revoke an app token (`POST /v1/auth/token/revoke-self`). /// /// Returns `Ok(())` on success (`204 No Content`). pub async fn token_revoke_self(&self, token: &str) -> AuthResult<()> { - let url = format!("{}/auth/token/revoke-self", self.base_url); + let url = format!("{}/v1/auth/token/revoke-self", self.base_url); let response = self .client .post(&url) @@ -1028,7 +1028,7 @@ impl AuthClient { /// /// Useful in tests to assert that an expired or revoked token returns `403`. pub async fn token_lookup_self_status(&self, token: &str) -> AuthResult { - let url = format!("{}/auth/token/lookup-self", self.base_url); + let url = format!("{}/v1/auth/token/lookup-self", self.base_url); let response = self .client .get(&url) diff --git a/client/src/dto/app_auth.rs b/client/src/dto/app_auth.rs index 64e00a65..05616538 100644 --- a/client/src/dto/app_auth.rs +++ b/client/src/dto/app_auth.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; // ── AppRole auth ───────────────────────────────────────────────────────────── -/// Request body for `POST /auth/approle/login`. +/// Request body for `POST /v1/auth/approle/login`. /// /// `secret_id` is optional: it is required only when the role's `bind_secret_id` /// flag is `true` (the default). Roles with `bind_secret_id: false` may login @@ -121,7 +121,7 @@ pub struct AppRoleRoleConfigData { // ── Kubernetes auth ─────────────────────────────────────────────────────────── -/// Request body for `POST /auth/kubernetes/login`. +/// Request body for `POST /v1/auth/kubernetes/login`. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct K8sLoginRequest { pub role: String, @@ -196,7 +196,7 @@ pub struct K8sRoleConfigData { pub bound_audiences: Vec, } -/// Response body for `GET /auth/token/lookup-self` and auth login responses. +/// Response body for `GET /v1/auth/token/lookup-self` and auth login responses. /// /// Used by SPIRE to verify a token is still valid and to extract the entity name. #[derive(Debug, Clone, Serialize, Deserialize)] @@ -213,7 +213,7 @@ pub struct AppAuth { pub metadata: std::collections::HashMap, } -/// Response body for `GET /auth/token/lookup-self`. +/// Response body for `GET /v1/auth/token/lookup-self`. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct AppTokenLookupResponse { pub data: AppTokenData, diff --git a/server/auth_verifier.spire.toml b/server/auth_verifier.spire.toml index 3cf95c10..f903a5ae 100644 --- a/server/auth_verifier.spire.toml +++ b/server/auth_verifier.spire.toml @@ -22,7 +22,7 @@ # you use to create AppRoles for your SPIRE servers (see "AppRole" note below). # # ── AppRole ────────────────────────────────────────────────────────────────── -# There is NOTHING to enable here for AppRole: the `/auth/approle/login` and the +# There is NOTHING to enable here for AppRole: the `/v1/auth/approle/login` and the # AppRole admin endpoints are always available. AppRoles (role_id + secret_id) # are created at RUNTIME by the super-admin via the admin API, e.g.: # diff --git a/server/documentation/docs/api_reference.md b/server/documentation/docs/api_reference.md index fbf8226c..9453d2b5 100644 --- a/server/documentation/docs/api_reference.md +++ b/server/documentation/docs/api_reference.md @@ -381,7 +381,7 @@ Endpoints for machine-to-machine authentication. These sit under the `/auth/` pr For complete request/response examples and field descriptions see [app_auth_api.md](app_auth_api.md). -### `POST /auth/approle/login` +### `POST /v1/auth/approle/login` Exchange a `role_id` + `secret_id` pair for an opaque app token. Also accepts `PUT` (SPIRE compatibility). @@ -520,7 +520,7 @@ List all AppRole role names. Requires admin session cookie. --- -### `POST /auth/kubernetes/login` +### `POST /v1/auth/kubernetes/login` Exchange a Kubernetes service-account JWT for an app token. @@ -587,7 +587,7 @@ Delete a Kubernetes role. Requires admin session cookie. --- -### `GET /auth/token/lookup-self` +### `GET /v1/auth/token/lookup-self` Validate an app token and return its metadata. @@ -616,7 +616,7 @@ X-Vault-Token: hvs.AAAAAQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRob --- -### `POST /auth/token/renew-self` +### `POST /v1/auth/token/renew-self` Extend a renewable token's TTL back to its configured `lease_duration`. @@ -644,7 +644,7 @@ X-Vault-Token: hvs.AAAAAQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRob --- -### `POST /auth/token/revoke-self` +### `POST /v1/auth/token/revoke-self` Immediately invalidate the current token. diff --git a/server/documentation/docs/app_auth_api.md b/server/documentation/docs/app_auth_api.md index dc807933..02b69ae5 100644 --- a/server/documentation/docs/app_auth_api.md +++ b/server/documentation/docs/app_auth_api.md @@ -59,19 +59,20 @@ Token self-service follows a simple HTTP self-service protocol for token introsp | Method | Path | Auth | Purpose | |--------|------|------|---------| -| `POST`/`PUT` | `/auth/approle/login` | none | Exchange `role_id` + `secret_id` for an app token | +| `POST`/`PUT` | `/v1/auth/approle/login` | none | Exchange `role_id` + `secret_id` for an app token | | `POST` | `/auth/approle/role/{name}` | admin session | Create or update an AppRole role | | `GET` | `/auth/approle/role/{name}/role-id` | admin session | Read the stable `role_id` | | `POST` | `/auth/approle/role/{name}/secret-id` | admin session | Generate a new `secret_id` | | `POST` | `/auth/approle/role/{name}/secret-id/destroy` | admin session | Invalidate a `secret_id` by accessor | | `DELETE` | `/auth/approle/role/{name}` | admin session | Delete a role | | `GET` | `/auth/approle/role?list=true` | admin session | List all roles | -| `POST` | `/auth/kubernetes/login` | none | Exchange a Kubernetes service-account JWT for an app token | +| `POST`/`PUT` | `/v1/auth/userpass/login/{username}` | none | Exchange a userpass password (realm `vault_userpass_realm`) for an app token | +| `POST` | `/v1/auth/kubernetes/login` | none | Exchange a Kubernetes service-account JWT for an app token | | `POST` | `/auth/kubernetes/role/{name}` | admin session | Create or update a Kubernetes role | | `DELETE` | `/auth/kubernetes/role/{name}` | admin session | Delete a Kubernetes role | -| `GET` | `/auth/token/lookup-self` | `X-Vault-Token` | Validate a token and return its metadata | -| `POST` | `/auth/token/renew-self` | `X-Vault-Token` | Extend a renewable token's TTL | -| `POST` | `/auth/token/revoke-self` | `X-Vault-Token` | Immediately invalidate a token | +| `GET` | `/v1/auth/token/lookup-self` | `X-Vault-Token` | Validate a token and return its metadata | +| `POST` | `/v1/auth/token/renew-self` | `X-Vault-Token` | Extend a renewable token's TTL | +| `POST` | `/v1/auth/token/revoke-self` | `X-Vault-Token` | Immediately invalidate a token | **Admin session** means an active `_ea_` cookie issued by `POST /login?realm=_` (the `_` admin realm). See [Authorization and Administration](authorization_and_administration.md) for details. @@ -168,7 +169,7 @@ Save the `secret_id` securely — it cannot be retrieved again. The `secret_id_a The service exchanges its `role_id` + `secret_id` for an app token. Both `POST` and `PUT` are accepted (SPIRE's Go SDK may issue either). ```http -POST /auth/approle/login +POST /v1/auth/approle/login Content-Type: application/json { @@ -273,7 +274,7 @@ Cookie: _ea_= ### Step 2 — Login (client) ```http -POST /auth/kubernetes/login +POST /v1/auth/kubernetes/login Content-Type: application/json { @@ -318,16 +319,48 @@ Cookie: _ea_= --- +## Userpass login (Vault-compatible) + +`bao login -method=userpass username=` against the Auth Verifier (directly, or through the KMS, which forwards `/v1/auth/*`). It authenticates the accounts of one realm, set by [`vault_userpass_realm`](server_configuration.md#vault-userpass-login); when unset every login is refused (`403`). + +```http +POST /v1/auth/userpass/login/alice +Content-Type: application/json + +{ "password": "alice-password" } +``` + +**Response** (same shape as the AppRole login): + +```json +{ + "auth": { + "client_token": "hvs.AAAAAQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRob", + "renewable": true, + "lease_duration": 3600, + "policies": ["User"], + "metadata": { "username": "alice", "realm": "kv-users" } + } +} +``` + +- `policies` are the account's roles; `lease_duration` is the realm's `session_max_age_seconds`. +- The token's `entity_id` is `userpass::`, disjoint from AppRole entities (bare role names). +- Unknown user and wrong password return the same `403`. Accounts with a pending password change or TOTP enabled are refused. +- Rate limited per IP like `/login`. + +--- + ## Token self-service All app tokens — regardless of which auth method produced them — support the same self-service endpoints. These require a valid `X-Vault-Token` header. -### `GET /auth/token/lookup-self` +### `GET /v1/auth/token/lookup-self` Validate a token and return its current metadata. This endpoint is called by the KMS middleware on every request to the `/v1/transit/*` and `/v1//*` scopes (with a 30-second cache). ```http -GET /auth/token/lookup-self +GET /v1/auth/token/lookup-self X-Vault-Token: hvs.AAAAAQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRob ``` @@ -350,12 +383,12 @@ X-Vault-Token: hvs.AAAAAQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRob **Returns `403 Forbidden`** if the token is missing, invalid, expired, or has been revoked. -### `POST /auth/token/renew-self` +### `POST /v1/auth/token/renew-self` Extend a renewable token's TTL back to its configured `lease_duration`. ```http -POST /auth/token/renew-self +POST /v1/auth/token/renew-self X-Vault-Token: hvs.AAAAAQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRob ``` @@ -375,12 +408,12 @@ X-Vault-Token: hvs.AAAAAQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRob `client_token` is the token echoed from the `X-Vault-Token` request header. SPIRE uses this to refresh its in-memory token state. -### `POST /auth/token/revoke-self` +### `POST /v1/auth/token/revoke-self` Immediately invalidate the current token. ```http -POST /auth/token/revoke-self +POST /v1/auth/token/revoke-self X-Vault-Token: hvs.AAAAAQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRob ``` @@ -442,7 +475,7 @@ Raw token values and raw secret IDs are never written to the database — only t ## Integration with the Cosmian KMS -The Authentication Verifier's `/auth/token/lookup-self` endpoint is the only point of contact between the Authentication Verifier and the KMS. The KMS calls it to validate every `X-Vault-Token` presented to its `/v1/transit/*` and `/v1//*` scopes. +The Authentication Verifier's `/v1/auth/token/lookup-self` endpoint is the only point of contact between the Authentication Verifier and the KMS. The KMS calls it to validate every `X-Vault-Token` presented to its `/v1/transit/*` and `/v1//*` scopes. Configure the KMS to point at the Authentication Verifier with these parameters (see [KMS SPIRE/SPIFFE integration guide](../key_management_system/integrations/spire_spiffe.md#configuration-reference)): @@ -464,7 +497,7 @@ vault_token_cache_ttl_secs = 30 ## Security notes -- **Login endpoints are unauthenticated** — `POST /auth/approle/login` and `POST /auth/kubernetes/login` are intentionally open; the credential is the request body. Apply rate limiting at the reverse-proxy level in production. +- **Login endpoints are unauthenticated** — `POST /v1/auth/approle/login` and `POST /v1/auth/kubernetes/login` are intentionally open; the credential is the request body. Apply rate limiting at the reverse-proxy level in production. - **No admin token-revocation endpoint** — a leaked, not-yet-expired token can only be revoked via `revoke-self` (self-service) or direct database deletion. There is no admin endpoint to revoke all tokens for a given role yet. - **Secret ID consumption** — `consume_secret_id` atomically decrements `num_uses_remaining` in a single database transaction, preventing replay. A secret ID with `num_uses = 1` is permanently invalidated after the first login. - **Raw values never stored** — token values and secret IDs follow the same hashing convention as passwords: only SHA-256 hashes are persisted. A database compromise does not expose any usable credential. diff --git a/server/documentation/docs/authentication_flows.md b/server/documentation/docs/authentication_flows.md index 2bf403eb..a5b510cf 100644 --- a/server/documentation/docs/authentication_flows.md +++ b/server/documentation/docs/authentication_flows.md @@ -232,13 +232,13 @@ sequenceDiagram O->>S: Provision role_id + secret_id (out-of-band) - S->>EA: POST /auth/approle/login
{ role_id: "a5d7…", secret_id: "b7c4…" } + S->>EA: POST /v1/auth/approle/login
{ role_id: "a5d7…", secret_id: "b7c4…" } note over EA: 1. Resolve role by role_id
2. Verify SHA-256(secret_id) hash
3. Decrement num_uses_remaining
4. Issue token (SHA-256 hash stored) EA->>DB: Insert app_tokens row (hash only) DB-->>EA: OK EA-->>S: { auth: { client_token: "hvs.…", renewable: true, lease_duration: 3600 } } - S->>EA: GET /auth/token/lookup-self
X-Vault-Token: hvs.… + S->>EA: GET /v1/auth/token/lookup-self
X-Vault-Token: hvs.… EA-->>S: { data: { id: "hvs.…", ttl: 3541, renewable: true, … } } ``` @@ -269,7 +269,7 @@ sequenceDiagram P->>K8s: Read projected token
/var/run/secrets/kubernetes.io/serviceaccount/token K8s-->>P: Service-account JWT (signed by Kubernetes) - P->>EA: POST /auth/kubernetes/login
{ role: "my-k8s-role", jwt: "" } + P->>EA: POST /v1/auth/kubernetes/login
{ role: "my-k8s-role", jwt: "" } note over EA: 1. Fetch JWKS from role's jwks_url
2. Select key by kid from JWT header
3. Validate signature, exp, nbf
4. Parse sub: system:serviceaccount::
5. Check sa_name against bound_sa_names
6. Check namespace against bound_sa_namespaces EA-->>P: { auth: { client_token: "hvs.…", lease_duration: 3600 } } ``` @@ -295,15 +295,15 @@ sequenceDiagram note over S: Service holds a token from AppRole or Kubernetes login - S->>EA: GET /auth/token/lookup-self
X-Vault-Token: hvs.… + S->>EA: GET /v1/auth/token/lookup-self
X-Vault-Token: hvs.… EA-->>S: { data: { id: "hvs.…", entity_id: "spire-server",
renewable: true, ttl: 3541, … } } note over S: Token nearing expiry — renew it - S->>EA: POST /auth/token/renew-self
X-Vault-Token: hvs.… + S->>EA: POST /v1/auth/token/renew-self
X-Vault-Token: hvs.… EA-->>S: { auth: { client_token: "hvs.…",
lease_duration: 3600, renewable: true } } note over S: Service is shutting down — revoke token - S->>EA: POST /auth/token/revoke-self
X-Vault-Token: hvs.… + S->>EA: POST /v1/auth/token/revoke-self
X-Vault-Token: hvs.… EA-->>S: 204 No Content ``` @@ -311,10 +311,10 @@ sequenceDiagram ```mermaid stateDiagram-v2 - [*] --> Active : POST /auth/approle/login or
POST /auth/kubernetes/login - Active --> Active : POST /auth/token/renew-self
(resets TTL to lease_duration) + [*] --> Active : POST /v1/auth/approle/login or
POST /v1/auth/kubernetes/login + Active --> Active : POST /v1/auth/token/renew-self
(resets TTL to lease_duration) Active --> Expired : token_ttl elapsed - Active --> Revoked : POST /auth/token/revoke-self + Active --> Revoked : POST /v1/auth/token/revoke-self Expired --> [*] : Rejected with 403 on next lookup-self Revoked --> [*] : Rejected with 403 immediately ``` @@ -420,7 +420,7 @@ These endpoints produce or manage **app tokens** (`X-Vault-Token`). See [app_aut | Method | Path | Description | Auth required | | ------------ | --------------------- | -------------------------------------- | ----------------- | -| `POST`/`PUT` | `/auth/approle/login` | Exchange `role_id` + `secret_id` for an app token | No (credential is body) | +| `POST`/`PUT` | `/v1/auth/approle/login` | Exchange `role_id` + `secret_id` for an app token | No (credential is body) | #### AppRole — role management (requires admin session cookie) @@ -437,7 +437,7 @@ These endpoints produce or manage **app tokens** (`X-Vault-Token`). See [app_aut | Method | Path | Description | Auth required | | ------ | ------------------------- | ------------------------------------------------ | ----------------- | -| `POST` | `/auth/kubernetes/login` | Exchange a K8s service-account JWT for an app token | No (credential is body) | +| `POST` | `/v1/auth/kubernetes/login` | Exchange a K8s service-account JWT for an app token | No (credential is body) | #### Kubernetes — role management (requires admin session cookie) @@ -450,9 +450,9 @@ These endpoints produce or manage **app tokens** (`X-Vault-Token`). See [app_aut | Method | Path | Description | | ------ | ----------------------------- | -------------------------------------------- | -| `GET` | `/auth/token/lookup-self` | Validate token and return its metadata | -| `POST` | `/auth/token/renew-self` | Extend a renewable token's TTL | -| `POST` | `/auth/token/revoke-self` | Immediately invalidate the current token | +| `GET` | `/v1/auth/token/lookup-self` | Validate token and return its metadata | +| `POST` | `/v1/auth/token/renew-self` | Extend a renewable token's TTL | +| `POST` | `/v1/auth/token/revoke-self` | Immediately invalidate the current token | ### Session JWT — `/whoami` response @@ -607,6 +607,6 @@ in DB, not expired?} → self-service handler] ``` -> **Note:** AppRole login (`POST /auth/approle/login`) and Kubernetes login (`POST /auth/kubernetes/login`) are unauthenticated — the credential is the request body. They are not represented above. +> **Note:** AppRole login (`POST /v1/auth/approle/login`) and Kubernetes login (`POST /v1/auth/kubernetes/login`) are unauthenticated — the credential is the request body. They are not represented above. --- diff --git a/server/documentation/docs/server_configuration.md b/server/documentation/docs/server_configuration.md index ec92bab6..73b7dd7b 100644 --- a/server/documentation/docs/server_configuration.md +++ b/server/documentation/docs/server_configuration.md @@ -25,6 +25,7 @@ A fully commented sample configuration is provided in `auth_verifier.toml` at th - [TLS Configuration](#tls-configuration) - [Generating certificates](#generating-certificates) - [Session JWT Keys](#session-jwt-keys) + - [Vault Userpass Login](#vault-userpass-login) - [SAML Service Provider Key](#saml-service-provider-key) - [Primary Database](#primary-database) - [Redis](#redis) @@ -143,6 +144,21 @@ openssl ec -in jwt.key.pem -pubout -out jwt.pub.pem --- +## Vault Userpass Login + +```toml +# Realm whose userpass accounts may log in through the Vault-compatible +# `POST /v1/auth/userpass/login/{username}` (`bao login -method=userpass`). +# When unset, that endpoint refuses every login. The admin realm `_` is refused. +vault_userpass_realm = "kv-users" +``` + +| Key | Type | Required | Default | +|-----|------|----------|---------| +| `vault_userpass_realm` | `String` | No | `null` (login disabled) | + +--- + ## SAML Service Provider Key Required for [SAML 2.0 single sign-on](saml.md), and only accepted by servers built with the diff --git a/server/documentation/openapi.yaml b/server/documentation/openapi.yaml index af7d919c..158b0a71 100644 --- a/server/documentation/openapi.yaml +++ b/server/documentation/openapi.yaml @@ -60,7 +60,7 @@ tags: login, as for its credential. - name: App Token description: | - App token self-service endpoints (`/auth/token/...`). + App token self-service endpoints (`/v1/auth/token/...`). Require a valid `X-Vault-Token` header. - name: AppRole description: | @@ -100,7 +100,7 @@ components: name: X-Vault-Token description: | AppRole-compatible bearer token issued by this server's AppRole or - Kubernetes login endpoints. Required on `/auth/token/*` endpoints. + Kubernetes login endpoints. Required on `/v1/auth/token/*` endpoints. schemas: @@ -2306,7 +2306,7 @@ paths: # ── App Token ──────────────────────────────────────────────────────────── - /auth/token/lookup-self: + /v1/auth/token/lookup-self: get: tags: [App Token] summary: Look up current token @@ -2335,7 +2335,7 @@ paths: '403': $ref: '#/components/responses/Forbidden' - /auth/token/renew-self: + /v1/auth/token/renew-self: post: tags: [App Token] summary: Renew current token @@ -2356,7 +2356,7 @@ paths: '403': $ref: '#/components/responses/Forbidden' - /auth/token/revoke-self: + /v1/auth/token/revoke-self: post: tags: [App Token] summary: Revoke current token @@ -2372,7 +2372,7 @@ paths: # ── AppRole ────────────────────────────────────────────────────────── - /auth/approle/login: + /v1/auth/approle/login: post: tags: [AppRole] summary: Login with AppRole credentials @@ -2617,7 +2617,7 @@ paths: # ── Kubernetes Auth ─────────────────────────────────────────────────────── - /auth/kubernetes/login: + /v1/auth/kubernetes/login: post: tags: [Kubernetes Auth] summary: Login with a Kubernetes service-account JWT diff --git a/server/src/server/auth_verifier.rs b/server/src/server/auth_verifier.rs index 82c96c4b..189826b0 100644 --- a/server/src/server/auth_verifier.rs +++ b/server/src/server/auth_verifier.rs @@ -53,6 +53,7 @@ use crate::{ update_admin, update_realm, update_userpass, + vault_userpass_login, version_endpoint, whoami, }, @@ -461,6 +462,7 @@ fn build_app( ); #[cfg(feature = "saml")] let saml_rate_limit = login_rate_limit.clone(); + let vault_userpass_rate_limit = login_rate_limit.clone(); // Create an `App` instance and configure the passed data and the various scopes let app = App::new() @@ -606,23 +608,28 @@ fn build_app( // ── AppRole-compatible auth scopes ───────────────────────────────────────── // - // Scope prefixes are kept intentionally specific to avoid Actix-web's - // FIFO matching swallowing requests before they reach the right scope. + // Vault client routes (what `bao`, SPIRE and the KMS call) live under `/v1/auth/*`, + // exactly like OpenBao/Vault. They do not overlap the admin CRUD scopes + // (`/auth/approle`, `/auth/kubernetes`), which are unprefixed. // - // /auth/approle/login — unauthenticated AppRole login (registered first, most specific) - // /auth/kubernetes/login — unauthenticated K8s login - // /auth/approle — AppRole admin CRUD (CookieAuthSameServer + AdminAuth) - // /auth/kubernetes — K8s admin CRUD - // /auth/token — token self-service (AppTokenExtract middleware) - - // Unauthenticated AppRole login — scope must be registered BEFORE /auth/approle - // so that /auth/approle/login requests don't fall into the admin scope. - let approle_login_scope = web::scope("/auth/approle/login") + // /v1/auth/approle/login — unauthenticated AppRole login + // /v1/auth/kubernetes/login — unauthenticated K8s login + // /v1/auth/userpass/login/{user} — unauthenticated Vault userpass login + // /v1/auth/token — token self-service (AppTokenExtract middleware) + // /auth/approle, /auth/kubernetes — admin CRUD (CookieAuthSameServer + AdminAuth) + + // The pre-`/v1` login paths are gone. Without this resource they would fall into the + // admin scopes below and fail with a misleading cookie/admin error instead of a 404. + let legacy_login_resource = + web::resource(["/auth/approle/login", "/auth/kubernetes/login"]).to(unsupported_route); + + // Unauthenticated AppRole login + let approle_login_scope = web::scope("/v1/auth/approle/login") .wrap(Cors::permissive()) .service(approle_login); // Unauthenticated K8s login - let k8s_login_scope = web::scope("/auth/kubernetes/login") + let k8s_login_scope = web::scope("/v1/auth/kubernetes/login") .wrap(Cors::permissive()) .service(k8s_login); @@ -658,7 +665,7 @@ fn build_app( .service(k8s_list_roles); // Token self-service (requires valid X-Vault-Token header) - let auth_token_scope = web::scope("/auth/token") + let auth_token_scope = web::scope("/v1/auth/token") .wrap(AppTokenExtract::new(database.clone())) .wrap(Cors::permissive()) .service(auth_token_lookup_self) @@ -675,13 +682,20 @@ fn build_app( .service(realms_crud_scope) .service(app_scope) .service(admins_scope) - // App auth scopes — most-specific prefixes first so Actix-web doesn't - // swallow requests before they reach the right scope. - .service(approle_login_scope) // /auth/approle/login (unauthenticated) - .service(k8s_login_scope) // /auth/kubernetes/login (unauthenticated) + // App auth scopes. The legacy login resource must precede the admin scopes so + // old `/auth/{approle,kubernetes}/login` clients get a 404, not an admin error. + .service(legacy_login_resource) + .service(approle_login_scope) // /v1/auth/approle/login (unauthenticated) + .service(k8s_login_scope) // /v1/auth/kubernetes/login (unauthenticated) + .service( + web::scope("/v1/auth/userpass/login") + .wrap(Cors::permissive()) + .wrap(vault_userpass_rate_limit) + .service(vault_userpass_login), + ) // /v1/auth/userpass/login/{username} (unauthenticated) .service(approle_admin_scope) // /auth/approle (admin CRUD) .service(k8s_admin_scope) // /auth/kubernetes (admin CRUD) - .service(auth_token_scope) // /auth/token (self-service) + .service(auth_token_scope) // /v1/auth/token (self-service) // Structured fallback for any unmatched route (e.g. a SPIRE server // misconfigured with an unsupported auth method such as `cert_auth`, // which has no `/auth/cert/*` handler). Without this, Actix returns a diff --git a/server/src/server/endpoints/approle.rs b/server/src/server/endpoints/approle.rs index b445cdea..d87f0dcf 100644 --- a/server/src/server/endpoints/approle.rs +++ b/server/src/server/endpoints/approle.rs @@ -4,7 +4,7 @@ //! //! | Method | Path | Description | //! |--------|------|-------------| -//! | POST | `/auth/approle/login` | Login with role_id + secret_id → returns token | +//! | POST | `/v1/auth/approle/login` | Login with role_id + secret_id → returns token | //! //! ## Admin CRUD (requires CookieAuthSameServer + AdminAuth) //! @@ -42,7 +42,7 @@ use uuid::Uuid; /// Login with role_id + secret_id and receive an app token. /// -/// `POST/PUT /auth/approle/login` — both methods accepted; Content-Type-agnostic body parsing. +/// `POST/PUT /v1/auth/approle/login` — both methods accepted; Content-Type-agnostic body parsing. #[route("", method = "POST", method = "PUT")] pub async fn approle_login( body: Bytes, diff --git a/server/src/server/endpoints/auth_token.rs b/server/src/server/endpoints/auth_token.rs index 3984c4cd..936fb6ae 100644 --- a/server/src/server/endpoints/auth_token.rs +++ b/server/src/server/endpoints/auth_token.rs @@ -2,9 +2,9 @@ //! //! | Method | Path | Description | //! |--------|------|-------------| -//! | GET | `/auth/token/lookup-self` | Return metadata for the bearer token | -//! | POST | `/auth/token/renew-self` | Renew a renewable token | -//! | POST | `/auth/token/revoke-self` | Revoke the current token | +//! | GET | `/v1/auth/token/lookup-self` | Return metadata for the bearer token | +//! | POST | `/v1/auth/token/renew-self` | Renew a renewable token | +//! | POST | `/v1/auth/token/revoke-self` | Revoke the current token | use crate::{AuthError, database::Database, middleware::AppTokenClaims}; use actix_web::{HttpMessage, HttpRequest, HttpResponse, get, post, web::Data}; @@ -14,7 +14,7 @@ use std::sync::Arc; /// Return metadata for the current `X-Vault-Token`. /// -/// Equivalent to `GET /auth/token/lookup-self` in the AppRole auth API. +/// Equivalent to `GET /v1/auth/token/lookup-self` in the AppRole auth API. #[get("/lookup-self")] pub async fn auth_token_lookup_self( req: HttpRequest, @@ -66,7 +66,7 @@ pub async fn auth_token_lookup_self( /// Renew a renewable token. /// -/// Equivalent to `POST /auth/token/renew-self` in the AppRole Auth API. +/// Equivalent to `POST /v1/auth/token/renew-self` in the AppRole Auth API. #[post("/renew-self")] pub async fn auth_token_renew_self( req: HttpRequest, @@ -120,7 +120,7 @@ pub async fn auth_token_renew_self( /// Revoke (invalidate) the current token. /// -/// Equivalent to `POST /auth/token/revoke-self` in the AppRole Auth API. +/// Equivalent to `POST /v1/auth/token/revoke-self` in the AppRole Auth API. #[post("/revoke-self")] pub async fn auth_token_revoke_self( req: HttpRequest, diff --git a/server/src/server/endpoints/kubernetes.rs b/server/src/server/endpoints/kubernetes.rs index 2e4e8f0b..4de1da77 100644 --- a/server/src/server/endpoints/kubernetes.rs +++ b/server/src/server/endpoints/kubernetes.rs @@ -2,7 +2,7 @@ //! //! | Method | Path | Description | //! |--------|------|-------------| -//! | POST | `/auth/kubernetes/login` | Login with K8s service-account JWT → returns token | +//! | POST | `/v1/auth/kubernetes/login` | Login with K8s service-account JWT → returns token | //! //! ## Admin CRUD (requires CookieAuthSameServer + AdminAuth) //! @@ -49,7 +49,7 @@ const K8S_LOGIN_GENERIC_ERR: &str = "invalid Kubernetes login credentials"; /// Login with a Kubernetes service-account JWT and receive an app token. /// -/// `POST /auth/kubernetes/login` +/// `POST /v1/auth/kubernetes/login` #[post("")] pub async fn k8s_login( body: Bytes, diff --git a/server/src/server/endpoints/mod.rs b/server/src/server/endpoints/mod.rs index 979efa6e..103aeab1 100644 --- a/server/src/server/endpoints/mod.rs +++ b/server/src/server/endpoints/mod.rs @@ -35,6 +35,9 @@ pub use sessions_endpoints::{ mod auth_token; pub use auth_token::{auth_token_lookup_self, auth_token_renew_self, auth_token_revoke_self}; +mod userpass_login; +pub use userpass_login::vault_userpass_login; + mod approle; pub use approle::{ approle_create_role, approle_delete_role, approle_destroy_secret_id, diff --git a/server/src/server/endpoints/userpass_login.rs b/server/src/server/endpoints/userpass_login.rs new file mode 100644 index 00000000..a5386d91 --- /dev/null +++ b/server/src/server/endpoints/userpass_login.rs @@ -0,0 +1,113 @@ +//! Vault-compatible userpass login: `POST/PUT /v1/auth/userpass/login/{username}` +//! (`bao login -method=userpass`), backed by the Auth Verifier userpass store. + +use crate::{ + AuthError, + database::{AuthDbError, Database}, + models::ADMIN_REALM, + server::parameters::ServerParams, +}; +use actix_web::{ + HttpResponse, route, + web::{Bytes, Data, Path}, +}; +use auth_client::{AppAuth, AppAuthResponse}; +use cosmian_logger::info; +use serde::Deserialize; +use std::sync::Arc; + +#[derive(Deserialize)] +struct VaultUserpassLoginRequest { + password: String, +} + +/// Log in a userpass account of `vault_userpass_realm` and issue a Vault-style app token. +#[route("/{username}", method = "POST", method = "PUT")] +pub async fn vault_userpass_login( + username: Path, + body: Bytes, + database: Data>, + server_params: Data>, +) -> Result { + let username = username.into_inner(); + let realm_id = server_params + .vault_userpass_realm + .as_deref() + .ok_or_else(|| { + AuthError::Forbidden( + "Vault userpass login is disabled: set vault_userpass_realm".to_owned(), + ) + })?; + if realm_id == ADMIN_REALM { + return Err(AuthError::Forbidden( + "vault_userpass_realm must not be the admin realm".to_owned(), + )); + } + let payload: VaultUserpassLoginRequest = serde_json::from_slice(&body) + .map_err(|e| AuthError::BadRequest(format!("invalid userpass login body: {e}")))?; + + match database + .validate_userpass(realm_id, &username, &payload.password) + .await + { + Err(AuthDbError::InvalidCredentials) => { + return Err(AuthError::Forbidden( + "invalid username or password".to_owned(), + )); + } + Err(e) => return Err(e.into()), + Ok(true) => { + return Err(AuthError::Forbidden( + "password change required: log in to the Auth Verifier first".to_owned(), + )); + } + Ok(false) => {} + } + if database + .is_totp_enabled(realm_id, &username) + .await? + .unwrap_or(false) + { + return Err(AuthError::Forbidden( + "TOTP-enabled accounts cannot use Vault userpass login".to_owned(), + )); + } + let policies = database + .get_userpass(realm_id, &username) + .await? + .map(|u| u.roles) + .unwrap_or_default(); + let realm = database.get_realm(realm_id).await?.ok_or_else(|| { + AuthError::Forbidden(format!("vault_userpass_realm '{realm_id}' does not exist")) + })?; + let ttl = realm.session_max_age_seconds; + + let token = super::issue_app_token( + &database, + &format!("userpass:{realm_id}:{username}"), + &policies, + ttl, + true, + ) + .await?; + + info!( + event = "auth.vault_userpass.login.success", + realm = %realm_id, + username = %username, + "Vault userpass login" + ); + + Ok(HttpResponse::Ok().json(AppAuthResponse { + auth: AppAuth { + client_token: token, + renewable: true, + lease_duration: ttl, + policies, + metadata: std::collections::HashMap::from([ + ("username".to_owned(), username), + ("realm".to_owned(), realm_id.to_owned()), + ]), + }, + })) +} diff --git a/server/src/server/parameters/server_params.rs b/server/src/server/parameters/server_params.rs index a27ab0da..12fc3ca8 100644 --- a/server/src/server/parameters/server_params.rs +++ b/server/src/server/parameters/server_params.rs @@ -91,6 +91,12 @@ pub struct ServerParams { /// rate above. #[serde(default = "default_login_rate_limit_burst")] pub login_rate_limit_burst: u32, + + /// Realm whose userpass accounts may log in through the Vault-compatible + /// `POST /v1/auth/userpass/login/{username}` (`bao login -method=userpass`). + /// When unset, that endpoint refuses every login. The admin realm `_` is refused. + #[serde(default)] + pub vault_userpass_realm: Option, } fn default_login_rate_limit_per_second() -> u32 { diff --git a/server/src/tests/app_auth_tests.rs b/server/src/tests/app_auth_tests.rs index 4d59394c..648ece3b 100644 --- a/server/src/tests/app_auth_tests.rs +++ b/server/src/tests/app_auth_tests.rs @@ -4,7 +4,7 @@ //! 1. Starts a fresh in-memory test server. //! 2. Authenticates as the seeded `admin` user. //! 3. Uses the `AuthClient` wrappers to exercise the `/auth/approle/*`, -//! `/auth/kubernetes/*`, and `/auth/token/*` endpoints. +//! `/auth/kubernetes/*`, and `/v1/auth/token/*` endpoints. //! //! ## Standards under test //! @@ -17,7 +17,9 @@ use crate::{ client::AuthClientScheme, dto::{AppRoleRoleRequest, AppRoleSecretIdRequest, K8sRoleRequest}, tests::{ - IdP, RsaIdp, helpers::authenticate_as_admin, init_test_logging, start_default_test_server, + IdP, RsaIdp, get_default_server_params, + helpers::{authenticate_as_admin, create_userpass, test_realm}, + init_test_logging, start_default_test_server, start_test_server, }, }; use cosmian_logger::info; @@ -575,7 +577,7 @@ async fn test_k8s_issuer_mismatch() -> AuthResult<()> { // ── Token self-service tests ────────────────────────────────────────────────── -/// `GET /auth/token/lookup-self` returns correct metadata for a valid token. +/// `GET /v1/auth/token/lookup-self` returns correct metadata for a valid token. #[actix_web::test] async fn test_token_lookup_self() -> AuthResult<()> { init_test_logging(None); @@ -617,7 +619,7 @@ async fn test_token_lookup_self() -> AuthResult<()> { ctx.stop_server().await } -/// `POST /auth/token/renew-self` extends a renewable token's TTL. +/// `POST /v1/auth/token/renew-self` extends a renewable token's TTL. #[actix_web::test] async fn test_token_renew_self() -> AuthResult<()> { init_test_logging(None); @@ -655,7 +657,7 @@ async fn test_token_renew_self() -> AuthResult<()> { ctx.stop_server().await } -/// `POST /auth/token/revoke-self` invalidates the token; subsequent lookup must 403. +/// `POST /v1/auth/token/revoke-self` invalidates the token; subsequent lookup must 403. #[actix_web::test] async fn test_token_revoke_self() -> AuthResult<()> { init_test_logging(None); @@ -834,3 +836,102 @@ async fn test_k8s_get_role_not_found() -> AuthResult<()> { ctx.stop_server().await } + +// ── Vault `/v1` path parity and userpass login ──────────────────────────────── + +/// The pre-`/v1` Vault client routes are gone: a structured 404, never a cookie/admin error. +#[actix_web::test] +async fn test_legacy_vault_routes_return_404() -> AuthResult<()> { + init_test_logging(None); + let ctx = start_default_test_server().await?; + let noauth = ctx.get_test_client(AuthClientScheme::None); + + for path in ["/auth/approle/login", "/auth/kubernetes/login"] { + let resp = noauth + .post_raw( + path, + &serde_json::json!({"role_id": "x", "role": "x", "jwt": "x"}), + ) + .await?; + assert_eq!(resp.status().as_u16(), 404, "{path}"); + } + assert_eq!( + noauth + .get_raw_with_header("/auth/token/lookup-self", "X-Vault-Token", "hvs.x") + .await? + .status() + .as_u16(), + 404 + ); + + ctx.stop_server().await +} + +/// `POST /v1/auth/userpass/login/{user}` issues a token for a `vault_userpass_realm` account. +#[actix_web::test] +async fn test_vault_userpass_login() -> AuthResult<()> { + init_test_logging(None); + let mut params = get_default_server_params()?; + params.vault_userpass_realm = Some("vault-users".to_owned()); + let ctx = start_test_server(params).await?; + let admin = authenticate_as_admin(&ctx).await?; + admin + .create_realm_as_super_admin(&test_realm("vault-users")) + .await?; + let mut alice = create_userpass("vault-users", "alice", "alice-pw", false)?; + alice.roles = vec!["User".to_owned()]; + admin + .create_admin_credentials_in_realm("vault-users", &alice) + .await?; + + let noauth = ctx.get_test_client(AuthClientScheme::None); + let login = |user: &'static str, pw: &'static str| { + let noauth = &noauth; + async move { + noauth + .post_raw( + &format!("/v1/auth/userpass/login/{user}"), + &serde_json::json!({ "password": pw }), + ) + .await + } + }; + + let ok = login("alice", "alice-pw").await?; + assert_eq!(ok.status().as_u16(), 200); + let body: crate::dto::AppAuthResponse = ok + .json() + .await + .map_err(|e| crate::AuthError::Generic(format!("bad login response: {e}")))?; + assert_eq!(body.auth.policies, vec!["User"]); + let lookup = noauth.token_lookup_self(&body.auth.client_token).await?; + assert_eq!(lookup.data.entity_id, "userpass:vault-users:alice"); + + let wrong = login("alice", "nope").await?; + let unknown = login("mallory", "nope").await?; + assert_eq!(wrong.status().as_u16(), 403); + assert_eq!(unknown.status().as_u16(), 403); + assert_eq!( + wrong.text().await.unwrap_or_default(), + unknown.text().await.unwrap_or_default(), + "unknown user and wrong password must be indistinguishable" + ); + + ctx.stop_server().await +} + +/// Without `vault_userpass_realm`, the userpass login refuses everyone. +#[actix_web::test] +async fn test_vault_userpass_login_disabled_by_default() -> AuthResult<()> { + init_test_logging(None); + let ctx = start_default_test_server().await?; + let resp = ctx + .get_test_client(AuthClientScheme::None) + .post_raw( + "/v1/auth/userpass/login/alice", + &serde_json::json!({ "password": "x" }), + ) + .await?; + assert_eq!(resp.status().as_u16(), 403); + ctx.stop_server().await +} diff --git a/server/src/tests/params.rs b/server/src/tests/params.rs index fd7e824f..5e33b5d6 100644 --- a/server/src/tests/params.rs +++ b/server/src/tests/params.rs @@ -88,6 +88,7 @@ pub fn get_default_server_params() -> AuthResult { allowed_origins: Vec::new(), login_rate_limit_per_second: 5, login_rate_limit_burst: 10, + vault_userpass_realm: None, }; Ok(server_params) From 6210c9ac5d3f62867f09dca7888c4fa28aad6af4 Mon Sep 17 00:00:00 2001 From: Manuthor Date: Mon, 16 Nov 2026 07:13:24 +0100 Subject: [PATCH 02/11] fix: add the userpass login to the OpenAPI contract and AuthClient; use the branch changelog --- CHANGELOG.md | 10 ---- CHANGELOG/feat_vault-v1-auth-paths.md | 10 ++++ client/src/client/auth_client.rs | 20 ++++++- client/src/dto/app_auth.rs | 6 ++ client/src/dto/mod.rs | 2 +- client/src/lib.rs | 1 + server/documentation/openapi.yaml | 56 +++++++++++++++++++ server/src/server/endpoints/userpass_login.rs | 8 +-- server/src/tests/app_auth_tests.rs | 7 +-- 9 files changed, 95 insertions(+), 25 deletions(-) create mode 100644 CHANGELOG/feat_vault-v1-auth-paths.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 24183c4a..6f420951 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,16 +2,6 @@ All notable changes to this project will be documented in this file. -## [Unreleased] - -### ⚠️ Breaking changes - -- Vault client routes (`approle/login`, `kubernetes/login`, `token/*`) are now served only under `/v1/auth/*`; the unprefixed paths return `404`. Requires Eviden KMS ≥ the release that calls `/v1/auth/token/lookup-self`. Admin CRUD routes (`/auth/approle/role/...`, `/auth/kubernetes/role/...`) are unchanged. - -### Vault userpass login - -- Add `POST/PUT /v1/auth/userpass/login/{username}` (`bao login -method=userpass`), backed by the userpass accounts of the realm named by the new `vault_userpass_realm` setting; disabled when unset. - ## [0.5.0] - 2026-10-26 Replaces the 0.5.0 tag of 2026-10-20, withdrawn because it was cut before the version bump: its packages and images reported version 0.4.0. diff --git a/CHANGELOG/feat_vault-v1-auth-paths.md b/CHANGELOG/feat_vault-v1-auth-paths.md new file mode 100644 index 00000000..2abed75c --- /dev/null +++ b/CHANGELOG/feat_vault-v1-auth-paths.md @@ -0,0 +1,10 @@ +## Breaking Changes + +- Vault client routes (`approle/login`, `kubernetes/login`, `token/*`) are now served only under `/v1/auth/*`; the unprefixed paths return `404`. Requires Eviden KMS ≥ the release that calls `/v1/auth/token/lookup-self`. Admin CRUD routes (`/auth/approle/role/...`, `/auth/kubernetes/role/...`) are unchanged. + +## Features + +### Vault userpass login + +- Add `POST/PUT /v1/auth/userpass/login/{username}` (`bao login -method=userpass`), backed by the userpass accounts of the realm named by the new `vault_userpass_realm` setting; disabled when unset. +- Add `AuthClient::vault_userpass_login` and the `/v1/auth/userpass/login/{username}` path to `openapi.yaml`. diff --git a/client/src/client/auth_client.rs b/client/src/client/auth_client.rs index bf8807e0..4c3e3e2f 100644 --- a/client/src/client/auth_client.rs +++ b/client/src/client/auth_client.rs @@ -17,7 +17,7 @@ use crate::{ DeleteSessionsRequest, GetSessionRequest, GetSessionsForClientsRequest, GetSessionsForClientsResponse, K8sListRolesResponse, K8sLoginRequest, K8sRoleConfigResponse, K8sRoleRequest, SessionInfo, SessionsAction, TotpGenerateRequest, - TotpGenerateResponse, TotpVerifyRequest, Version, + TotpGenerateResponse, TotpVerifyRequest, VaultUserpassLoginRequest, Version, }, models::{Admin, ClientClaims, LoginRequest, Realm, UserPass}, }; @@ -897,6 +897,24 @@ impl AuthClient { ) .await } + + /// Login a userpass account of the server's `vault_userpass_realm` and receive an app token + /// (`POST /v1/auth/userpass/login/{username}`, as `bao login -method=userpass` does). + /// + /// No authentication required. + pub async fn vault_userpass_login( + &self, + username: &str, + password: &str, + ) -> AuthResult { + self.post( + &format!("/v1/auth/userpass/login/{username}"), + &VaultUserpassLoginRequest { + password: password.to_string(), + }, + ) + .await + } } // ── Kubernetes auth API ─────────────────────────────────────────────────────── diff --git a/client/src/dto/app_auth.rs b/client/src/dto/app_auth.rs index 05616538..a230cf4d 100644 --- a/client/src/dto/app_auth.rs +++ b/client/src/dto/app_auth.rs @@ -19,6 +19,12 @@ pub struct AppRoleLoginRequest { pub secret_id: Option, } +/// Request body for `POST /v1/auth/userpass/login/{username}` (Vault-compatible userpass login). +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct VaultUserpassLoginRequest { + pub password: String, +} + /// Request body for `POST /auth/approle/role/{name}` (create/update). #[derive(Debug, Clone, Serialize, Deserialize)] pub struct AppRoleRoleRequest { diff --git a/client/src/dto/mod.rs b/client/src/dto/mod.rs index 012f24d2..52e55bcb 100644 --- a/client/src/dto/mod.rs +++ b/client/src/dto/mod.rs @@ -22,5 +22,5 @@ pub use app_auth::{ AppRoleRoleConfigResponse, AppRoleRoleIdData, AppRoleRoleIdResponse, AppRoleRoleRequest, AppRoleSecretIdData, AppRoleSecretIdRequest, AppRoleSecretIdResponse, AppTokenData, AppTokenLookupResponse, K8sListData, K8sListRolesResponse, K8sLoginRequest, K8sRoleConfigData, - K8sRoleConfigResponse, K8sRoleRequest, + K8sRoleConfigResponse, K8sRoleRequest, VaultUserpassLoginRequest, }; diff --git a/client/src/lib.rs b/client/src/lib.rs index 2415b63b..a3b98b9d 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -44,6 +44,7 @@ pub use dto::{ TotpGenerateRequest, TotpGenerateResponse, TotpVerifyRequest, + VaultUserpassLoginRequest, Version, }; diff --git a/server/documentation/openapi.yaml b/server/documentation/openapi.yaml index 158b0a71..ad55c0fb 100644 --- a/server/documentation/openapi.yaml +++ b/server/documentation/openapi.yaml @@ -691,6 +691,15 @@ components: # ── AppRole Auth API ───────────────────────────────────────────────────────────── + VaultUserpassLoginRequest: + type: object + required: [password] + properties: + password: + type: string + description: Plaintext password of the userpass account. + example: alice-password + AppRoleLoginRequest: type: object required: [role_id] @@ -2409,6 +2418,53 @@ paths: '403': description: Invalid role_id or secret_id. + /v1/auth/userpass/login/{username}: + parameters: + - name: username + in: path + required: true + schema: + type: string + description: Userpass account of the realm named by `vault_userpass_realm`. + post: + tags: [AppRole] + summary: Login with userpass credentials (Vault-compatible) + description: | + `bao login -method=userpass`. Exchanges the password of a userpass account of the + realm configured by `vault_userpass_realm` for an app token whose `policies` are the + account's roles and whose lifetime is the realm's `session_max_age_seconds`. + `PUT` is accepted as well. The token's `entity_id` is `userpass::`. + When `vault_userpass_realm` is unset the endpoint refuses every login (`403`). + Accounts that must change their password, or that have TOTP enabled, are refused. + Rate limited per IP like `/login`. No authentication required. + operationId: vaultUserpassLogin + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/VaultUserpassLoginRequest' + example: + password: alice-password + responses: + '200': + description: Token issued. + content: + application/json: + schema: + $ref: '#/components/schemas/AppAuthResponse' + example: + auth: + client_token: hvs.AAAAAQKlNmEz... + renewable: true + lease_duration: 3600 + policies: [User] + metadata: + username: alice + realm: kv-users + '403': + description: Invalid username or password, feature disabled, password change required or TOTP enabled. + /auth/approle/role/{name}: post: tags: [AppRole] diff --git a/server/src/server/endpoints/userpass_login.rs b/server/src/server/endpoints/userpass_login.rs index a5386d91..f651224d 100644 --- a/server/src/server/endpoints/userpass_login.rs +++ b/server/src/server/endpoints/userpass_login.rs @@ -11,16 +11,10 @@ use actix_web::{ HttpResponse, route, web::{Bytes, Data, Path}, }; -use auth_client::{AppAuth, AppAuthResponse}; +use auth_client::{AppAuth, AppAuthResponse, VaultUserpassLoginRequest}; use cosmian_logger::info; -use serde::Deserialize; use std::sync::Arc; -#[derive(Deserialize)] -struct VaultUserpassLoginRequest { - password: String, -} - /// Log in a userpass account of `vault_userpass_realm` and issue a Vault-style app token. #[route("/{username}", method = "POST", method = "PUT")] pub async fn vault_userpass_login( diff --git a/server/src/tests/app_auth_tests.rs b/server/src/tests/app_auth_tests.rs index 648ece3b..8d741450 100644 --- a/server/src/tests/app_auth_tests.rs +++ b/server/src/tests/app_auth_tests.rs @@ -897,12 +897,7 @@ async fn test_vault_userpass_login() -> AuthResult<()> { } }; - let ok = login("alice", "alice-pw").await?; - assert_eq!(ok.status().as_u16(), 200); - let body: crate::dto::AppAuthResponse = ok - .json() - .await - .map_err(|e| crate::AuthError::Generic(format!("bad login response: {e}")))?; + let body = noauth.vault_userpass_login("alice", "alice-pw").await?; assert_eq!(body.auth.policies, vec!["User"]); let lookup = noauth.token_lookup_self(&body.auth.client_token).await?; assert_eq!(lookup.data.entity_id, "userpass:vault-users:alice"); From f23b892bbbe2c4327de3295f04858b91dfde3811 Mon Sep 17 00:00:00 2001 From: Manuthor Date: Mon, 16 Nov 2026 19:33:39 +0100 Subject: [PATCH 03/11] ci: fix workflow arg --- .github/workflows/main_base.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/main_base.yml b/.github/workflows/main_base.yml index f13f4598..6c495d8c 100644 --- a/.github/workflows/main_base.yml +++ b/.github/workflows/main_base.yml @@ -33,8 +33,6 @@ jobs: cargo-machete: uses: Cosmian/reusable_workflows/.github/workflows/cargo-machete.yml@develop - with: - toolchain: ${{ inputs.toolchain }} cargo-clippy: name: Cargo test - ${{ matrix.runner }} From c7ac13a78b484ced5a7db60fb030f561003f6b16 Mon Sep 17 00:00:00 2001 From: Manuthor Date: Mon, 16 Nov 2026 19:45:40 +0100 Subject: [PATCH 04/11] fix(admin-ui): declare pnpm overrides in pnpm-workspace.yaml for Dependabot lockfiles pnpm 12 ignores pnpm.overrides in package.json, so a Dependabot-written lockfile lacks the overrides block and pnpm 9 in CI rejects it with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH. Declare the same overrides in pnpm-workspace.yaml; pnpm 9, 10 and 12 all accept the resulting lockfile. --- CHANGELOG/feat_vault-v1-auth-paths.md | 4 ++++ admin-ui/pnpm-workspace.yaml | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG/feat_vault-v1-auth-paths.md b/CHANGELOG/feat_vault-v1-auth-paths.md index 2abed75c..898db213 100644 --- a/CHANGELOG/feat_vault-v1-auth-paths.md +++ b/CHANGELOG/feat_vault-v1-auth-paths.md @@ -8,3 +8,7 @@ - Add `POST/PUT /v1/auth/userpass/login/{username}` (`bao login -method=userpass`), backed by the userpass accounts of the realm named by the new `vault_userpass_realm` setting; disabled when unset. - Add `AuthClient::vault_userpass_login` and the `/v1/auth/userpass/login/{username}` path to `openapi.yaml`. + +## Bug Fixes + +- Declare the admin-ui pnpm `overrides` in `admin-ui/pnpm-workspace.yaml` as well as `package.json`, so a lockfile written by Dependabot's newer pnpm keeps its `overrides:` block and no longer fails the frozen install in CI (`ERR_PNPM_LOCKFILE_CONFIG_MISMATCH`). diff --git a/admin-ui/pnpm-workspace.yaml b/admin-ui/pnpm-workspace.yaml index 85274d90..eba4b0b7 100644 --- a/admin-ui/pnpm-workspace.yaml +++ b/admin-ui/pnpm-workspace.yaml @@ -4,3 +4,12 @@ packages: allowBuilds: "@swc/core": false esbuild: false + +# Keep identical to `pnpm.overrides` in package.json. Newer pnpm (12 ignores package.json) reads only this +# file, pnpm 9 (CI and the Nix build) reads only package.json. A lockfile written without the matching +# `overrides:` block fails `pnpm install --frozen-lockfile` with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH. +overrides: + ws: ">=8.21.0" + esbuild: ">=0.28.1" + js-yaml: ">=4.3.0" + postcss: ">=8.5.18" From a0b55aa348788e95f61040431e11c1bdc297da01 Mon Sep 17 00:00:00 2001 From: Manuthor Date: Mon, 16 Nov 2026 19:46:21 +0100 Subject: [PATCH 05/11] ci(admin-ui): fail when pnpm overrides differ between package.json and pnpm-workspace.yaml --- .github/workflows/admin-ui.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/admin-ui.yml b/.github/workflows/admin-ui.yml index 6e45bac9..9c149568 100644 --- a/.github/workflows/admin-ui.yml +++ b/.github/workflows/admin-ui.yml @@ -34,6 +34,12 @@ jobs: cache: pnpm cache-dependency-path: admin-ui/pnpm-lock.yaml + # pnpm 9 reads the overrides from package.json, newer pnpm only from pnpm-workspace.yaml: they must not drift. + - name: pnpm overrides match in package.json and pnpm-workspace.yaml + run: | + diff <(jq -r '.pnpm.overrides | to_entries[] | "\(.key)=\(.value)"' package.json | sort) \ + <(awk '/^overrides:/{f=1;next} f&&/^[^ #]/{f=0} f&&NF&&!/^ *#/{gsub(/"/,""); sub(/^ +/,""); sub(/: */,"="); print}' pnpm-workspace.yaml | sort) + - name: Install dependencies run: pnpm install --frozen-lockfile From 5b8f8d81a56489ffe52a7279215ba29125e58bb8 Mon Sep 17 00:00:00 2001 From: Manuthor Date: Mon, 16 Nov 2026 20:05:55 +0100 Subject: [PATCH 06/11] fix(admin-ui): restore the pnpm overrides block in pnpm-lock.yaml The merged Dependabot lockfile (#135) was written without the overrides block, so pnpm install --frozen-lockfile fails with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH on develop. Regenerated with pnpm 12 from the pnpm-workspace.yaml overrides; pnpm 9, 10 and 12 accept it. --- admin-ui/pnpm-lock.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/admin-ui/pnpm-lock.yaml b/admin-ui/pnpm-lock.yaml index 41b576d1..59b99172 100644 --- a/admin-ui/pnpm-lock.yaml +++ b/admin-ui/pnpm-lock.yaml @@ -4,6 +4,12 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +overrides: + ws: '>=8.21.0' + esbuild: '>=0.28.1' + js-yaml: '>=4.3.0' + postcss: '>=8.5.18' + importers: .: @@ -2015,7 +2021,7 @@ packages: peerDependencies: '@types/node': ^20.19.0 || >=22.12.0 '@vitejs/devtools': ^0.7.1 || ^0.8.0 - esbuild: ^0.27.0 || ^0.28.0 + esbuild: '>=0.28.1' jiti: '>=1.21.0' less: ^4.0.0 sass: ^1.70.0 From d8ed93d0e08b4725f7ac40d6addae35f9f3991b7 Mon Sep 17 00:00:00 2001 From: Manuthor Date: Mon, 16 Nov 2026 20:10:30 +0100 Subject: [PATCH 07/11] fix(admin-ui): override minimatch to >=11.0.1 (GHSA-g3hv-75wg-m249) and refresh the Nix pnpm hashes Dependabot could not fix alert #58 (security_update_not_possible): eslint and typescript-eslint pin minimatch ^10. Override it in package.json and pnpm-workspace.yaml, regenerate the lockfile and the admin-ui.pnpm.* hashes (nix-build -A admin-ui passes). --- CHANGELOG/feat_vault-v1-auth-paths.md | 2 ++ admin-ui/package.json | 3 ++- admin-ui/pnpm-lock.yaml | 21 ++++++++++++------- admin-ui/pnpm-workspace.yaml | 1 + .../admin-ui.pnpm.darwin.sha256 | 2 +- .../admin-ui.pnpm.linux-aarch64.sha256 | 2 +- .../admin-ui.pnpm.linux-x86_64.sha256 | 2 +- 7 files changed, 22 insertions(+), 11 deletions(-) diff --git a/CHANGELOG/feat_vault-v1-auth-paths.md b/CHANGELOG/feat_vault-v1-auth-paths.md index 898db213..0aeb6104 100644 --- a/CHANGELOG/feat_vault-v1-auth-paths.md +++ b/CHANGELOG/feat_vault-v1-auth-paths.md @@ -12,3 +12,5 @@ ## Bug Fixes - Declare the admin-ui pnpm `overrides` in `admin-ui/pnpm-workspace.yaml` as well as `package.json`, so a lockfile written by Dependabot's newer pnpm keeps its `overrides:` block and no longer fails the frozen install in CI (`ERR_PNPM_LOCKFILE_CONFIG_MISMATCH`). +- Restore the `overrides:` block of `admin-ui/pnpm-lock.yaml` (the merged Dependabot lockfile lacked it, which failed the frozen install on `develop`) and refresh the `admin-ui.pnpm.*` Nix hashes. +- Override the dev-only transitive `minimatch` to `>=11.0.1` (GHSA-g3hv-75wg-m249, Dependabot alert #58): every parent (`eslint`, `typescript-eslint`) pins `^10`, so Dependabot reported `security_update_not_possible`. diff --git a/admin-ui/package.json b/admin-ui/package.json index 996359e4..dcf0fbe6 100644 --- a/admin-ui/package.json +++ b/admin-ui/package.json @@ -53,7 +53,8 @@ "ws": ">=8.21.0", "esbuild": ">=0.28.1", "js-yaml": ">=4.3.0", - "postcss": ">=8.5.18" + "postcss": ">=8.5.18", + "minimatch": ">=11.0.1" } } } diff --git a/admin-ui/pnpm-lock.yaml b/admin-ui/pnpm-lock.yaml index 59b99172..6d1c8ec2 100644 --- a/admin-ui/pnpm-lock.yaml +++ b/admin-ui/pnpm-lock.yaml @@ -9,6 +9,7 @@ overrides: esbuild: '>=0.28.1' js-yaml: '>=4.3.0' postcss: '>=8.5.18' + minimatch: '>=11.0.1' importers: @@ -374,6 +375,9 @@ packages: '@types/node': optional: true + '@isaacs/nonrecursive-glob-match@1.1.0': + resolution: {integrity: sha512-GPm/Dbvk5RLmhRnxXIa7nTpK0xtl4E0wj0MslsuNiJ1FIROU+2+9lgUC/dgF7Ey4QCWhfEsgxilMRMCdHPfDfw==} + '@jridgewell/gen-mapping@0.3.13': resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} @@ -1674,9 +1678,9 @@ packages: resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} engines: {node: '>=4'} - minimatch@10.2.6: - resolution: {integrity: sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==} - engines: {node: 18 || 20 || >=22} + minimatch@11.0.8: + resolution: {integrity: sha512-nFQuYSTVrGvysVBps5Ih+0BdnYFN/Cj3C816r6+p7yK+FHrVLGE4O4N9AFwykrlNlvM2HYt+Rad1Uiro6h88Ig==} + engines: {node: 20 || >=22} ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} @@ -2409,7 +2413,7 @@ snapshots: dependencies: '@eslint/object-schema': 3.0.5 debug: 4.4.3 - minimatch: 10.2.6 + minimatch: 11.0.8 transitivePeerDependencies: - supports-color @@ -2482,6 +2486,8 @@ snapshots: '@types/node': 26.6.6 optional: true + '@isaacs/nonrecursive-glob-match@1.1.0': {} + '@jridgewell/gen-mapping@0.3.13': dependencies: '@jridgewell/sourcemap-codec': 1.6.0 @@ -3204,7 +3210,7 @@ snapshots: '@typescript-eslint/types': 8.72.2 '@typescript-eslint/visitor-keys': 8.72.2 debug: 4.4.3 - minimatch: 10.2.6 + minimatch: 11.0.8 semver: 7.8.6 tinyglobby: 0.2.17 ts-api-utils: 2.5.0(typescript@6.0.3) @@ -3517,7 +3523,7 @@ snapshots: imurmurhash: 0.1.4 is-glob: 4.0.3 json-stable-stringify-without-jsonify: 1.0.1 - minimatch: 10.2.6 + minimatch: 11.0.8 natural-compare: 1.4.0 optionator: 0.9.4 optionalDependencies: @@ -3786,8 +3792,9 @@ snapshots: min-indent@1.0.1: {} - minimatch@10.2.6: + minimatch@11.0.8: dependencies: + '@isaacs/nonrecursive-glob-match': 1.1.0 brace-expansion: 5.0.12 ms@2.1.3: {} diff --git a/admin-ui/pnpm-workspace.yaml b/admin-ui/pnpm-workspace.yaml index eba4b0b7..555ee05c 100644 --- a/admin-ui/pnpm-workspace.yaml +++ b/admin-ui/pnpm-workspace.yaml @@ -13,3 +13,4 @@ overrides: esbuild: ">=0.28.1" js-yaml: ">=4.3.0" postcss: ">=8.5.18" + minimatch: ">=11.0.1" diff --git a/nix/expected-hashes/admin-ui.pnpm.darwin.sha256 b/nix/expected-hashes/admin-ui.pnpm.darwin.sha256 index 44fb4b74..c0d629e0 100644 --- a/nix/expected-hashes/admin-ui.pnpm.darwin.sha256 +++ b/nix/expected-hashes/admin-ui.pnpm.darwin.sha256 @@ -1 +1 @@ -sha256-dxCYAkeEK8G9m7nv+xvtJRadwzKFsRPLHZgZjTAWjuE= \ No newline at end of file +sha256-OGTXPiTjZF5uotIjMry40mFWhylQWklCyBm+M5Miy8M= \ No newline at end of file diff --git a/nix/expected-hashes/admin-ui.pnpm.linux-aarch64.sha256 b/nix/expected-hashes/admin-ui.pnpm.linux-aarch64.sha256 index 44fb4b74..c0d629e0 100644 --- a/nix/expected-hashes/admin-ui.pnpm.linux-aarch64.sha256 +++ b/nix/expected-hashes/admin-ui.pnpm.linux-aarch64.sha256 @@ -1 +1 @@ -sha256-dxCYAkeEK8G9m7nv+xvtJRadwzKFsRPLHZgZjTAWjuE= \ No newline at end of file +sha256-OGTXPiTjZF5uotIjMry40mFWhylQWklCyBm+M5Miy8M= \ No newline at end of file diff --git a/nix/expected-hashes/admin-ui.pnpm.linux-x86_64.sha256 b/nix/expected-hashes/admin-ui.pnpm.linux-x86_64.sha256 index 44fb4b74..c0d629e0 100644 --- a/nix/expected-hashes/admin-ui.pnpm.linux-x86_64.sha256 +++ b/nix/expected-hashes/admin-ui.pnpm.linux-x86_64.sha256 @@ -1 +1 @@ -sha256-dxCYAkeEK8G9m7nv+xvtJRadwzKFsRPLHZgZjTAWjuE= \ No newline at end of file +sha256-OGTXPiTjZF5uotIjMry40mFWhylQWklCyBm+M5Miy8M= \ No newline at end of file From 642a3b1486902b66792e5c5919712a93287b0e25 Mon Sep 17 00:00:00 2001 From: Manuthor Date: Mon, 16 Nov 2026 20:19:48 +0100 Subject: [PATCH 08/11] ci(admin-ui): compare pnpm overrides with jq and yq instead of awk parsing Parse package.json and pnpm-workspace.yaml as data (jq 1.7 and yq 4.54 are preinstalled on ubuntu-24.04) and diff the two override objects, so quoting, ordering and comments in the YAML no longer matter. --- .github/workflows/admin-ui.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/admin-ui.yml b/.github/workflows/admin-ui.yml index 9c149568..90243d5c 100644 --- a/.github/workflows/admin-ui.yml +++ b/.github/workflows/admin-ui.yml @@ -35,10 +35,11 @@ jobs: cache-dependency-path: admin-ui/pnpm-lock.yaml # pnpm 9 reads the overrides from package.json, newer pnpm only from pnpm-workspace.yaml: they must not drift. + # Both files are parsed (jq, yq: preinstalled on ubuntu-24.04) and compared as JSON objects. - name: pnpm overrides match in package.json and pnpm-workspace.yaml run: | - diff <(jq -r '.pnpm.overrides | to_entries[] | "\(.key)=\(.value)"' package.json | sort) \ - <(awk '/^overrides:/{f=1;next} f&&/^[^ #]/{f=0} f&&NF&&!/^ *#/{gsub(/"/,""); sub(/^ +/,""); sub(/: */,"="); print}' pnpm-workspace.yaml | sort) + diff <(jq -S '.pnpm.overrides // {}' package.json) \ + <(yq -o=json '.overrides // {}' pnpm-workspace.yaml | jq -S .) - name: Install dependencies run: pnpm install --frozen-lockfile From 7f6595a6c510be63591cf9b7cf4f2f1dc0f5247f Mon Sep 17 00:00:00 2001 From: Manuthor Date: Mon, 16 Nov 2026 20:19:49 +0100 Subject: [PATCH 09/11] fix(nix): set the Linux admin-ui pnpm deps hash from the Packaging jobs Linux x86_64 and aarch64 report sha256-rgruJeJW...; darwin keeps the value nix-build produced locally (macOS packaging got past the fetch with it). The hashes are no longer identical across platforms: update the docs. --- AGENTS.md | 11 ++++++----- nix/expected-hashes/README.md | 4 ++-- .../admin-ui.pnpm.linux-aarch64.sha256 | 2 +- nix/expected-hashes/admin-ui.pnpm.linux-x86_64.sha256 | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 5bf870ef..13be9321 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -295,14 +295,15 @@ nix-build -A auth-verifier-static 2>&1 | grep "got:" ``` When `admin-ui/pnpm-lock.yaml` changes (including Dependabot PRs), the three -`admin-ui.pnpm.*` hashes become stale. They are always identical (`fetchDeps` -fetches every platform's packages), so regenerate once and write the value to -all three files, without a trailing newline: +`admin-ui.pnpm.*` hashes become stale. Linux x86_64 and aarch64 produce the same hash, +but darwin can differ (observed on this repo), so take each value from a build +on that platform: `nix-build` locally on macOS, or the `got:` line of the failed +`Packaging` job on Linux. Write it without a trailing newline: ```bash -printf 'sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=' > nix/expected-hashes/admin-ui.pnpm.linux-x86_64.sha256 +printf 'sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=' > nix/expected-hashes/admin-ui.pnpm.darwin.sha256 nix-build -A admin-ui --no-out-link 2>&1 | grep "got:" -for p in linux-x86_64 linux-aarch64 darwin; do printf '' > nix/expected-hashes/admin-ui.pnpm.$p.sha256; done +printf '' > nix/expected-hashes/admin-ui.pnpm.darwin.sha256 # linux-x86_64 / linux-aarch64: same, from the Linux build ``` --- diff --git a/nix/expected-hashes/README.md b/nix/expected-hashes/README.md index adffc995..dcac9374 100644 --- a/nix/expected-hashes/README.md +++ b/nix/expected-hashes/README.md @@ -15,8 +15,8 @@ Used by `nix/auth-verifier.nix` to verify reproducible Cargo vendoring: Used by `nix/admin-ui.nix` to verify the pnpm dependency fetch: -- `admin-ui.pnpm..sha256` — always the same - value on all three platforms, because `fetchDeps` fetches every platform's packages +- `admin-ui.pnpm..sha256` — the two Linux files hold the same value; + the darwin value can differ from it, so regenerate each platform on its own builder ### Binary hashes diff --git a/nix/expected-hashes/admin-ui.pnpm.linux-aarch64.sha256 b/nix/expected-hashes/admin-ui.pnpm.linux-aarch64.sha256 index c0d629e0..11d2d433 100644 --- a/nix/expected-hashes/admin-ui.pnpm.linux-aarch64.sha256 +++ b/nix/expected-hashes/admin-ui.pnpm.linux-aarch64.sha256 @@ -1 +1 @@ -sha256-OGTXPiTjZF5uotIjMry40mFWhylQWklCyBm+M5Miy8M= \ No newline at end of file +sha256-rgruJeJW9XxYvfq092Cr44m0DRhunDgXGom0Cl+8Sh4= \ No newline at end of file diff --git a/nix/expected-hashes/admin-ui.pnpm.linux-x86_64.sha256 b/nix/expected-hashes/admin-ui.pnpm.linux-x86_64.sha256 index c0d629e0..11d2d433 100644 --- a/nix/expected-hashes/admin-ui.pnpm.linux-x86_64.sha256 +++ b/nix/expected-hashes/admin-ui.pnpm.linux-x86_64.sha256 @@ -1 +1 @@ -sha256-OGTXPiTjZF5uotIjMry40mFWhylQWklCyBm+M5Miy8M= \ No newline at end of file +sha256-rgruJeJW9XxYvfq092Cr44m0DRhunDgXGom0Cl+8Sh4= \ No newline at end of file From 389bd70dfe0a4fb41fcbbdc37937e5698bb98c90 Mon Sep 17 00:00:00 2001 From: Manuthor Date: Mon, 16 Nov 2026 20:20:24 +0100 Subject: [PATCH 10/11] docs(nix): regenerate each admin-ui pnpm hash from a build on its platform --- AGENTS.md | 10 +++++----- nix/expected-hashes/README.md | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 13be9321..0254192b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -295,15 +295,15 @@ nix-build -A auth-verifier-static 2>&1 | grep "got:" ``` When `admin-ui/pnpm-lock.yaml` changes (including Dependabot PRs), the three -`admin-ui.pnpm.*` hashes become stale. Linux x86_64 and aarch64 produce the same hash, -but darwin can differ (observed on this repo), so take each value from a build -on that platform: `nix-build` locally on macOS, or the `got:` line of the failed -`Packaging` job on Linux. Write it without a trailing newline: +`admin-ui.pnpm.*` hashes become stale. They are usually equal, but do not assume it: take each +value from a build on that platform (`nix-build` locally on macOS for `darwin`, the `got:` line +of the failed `Packaging` job for `linux-x86_64` and `linux-aarch64`). Write it without a +trailing newline: ```bash printf 'sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=' > nix/expected-hashes/admin-ui.pnpm.darwin.sha256 nix-build -A admin-ui --no-out-link 2>&1 | grep "got:" -printf '' > nix/expected-hashes/admin-ui.pnpm.darwin.sha256 # linux-x86_64 / linux-aarch64: same, from the Linux build +printf '' > nix/expected-hashes/admin-ui.pnpm.darwin.sha256 # same for linux-x86_64 / linux-aarch64 ``` --- diff --git a/nix/expected-hashes/README.md b/nix/expected-hashes/README.md index dcac9374..eb01edd1 100644 --- a/nix/expected-hashes/README.md +++ b/nix/expected-hashes/README.md @@ -15,8 +15,8 @@ Used by `nix/auth-verifier.nix` to verify reproducible Cargo vendoring: Used by `nix/admin-ui.nix` to verify the pnpm dependency fetch: -- `admin-ui.pnpm..sha256` — the two Linux files hold the same value; - the darwin value can differ from it, so regenerate each platform on its own builder +- `admin-ui.pnpm..sha256` — usually the same value on the three + platforms, but not guaranteed: take each one from a build on that platform ### Binary hashes From cdb5a065db073207c69b767a9d7913073b74cebb Mon Sep 17 00:00:00 2001 From: Manuthor Date: Mon, 16 Nov 2026 20:28:27 +0100 Subject: [PATCH 11/11] Revert "ci: check the combined docs build on PRs (#122)" This reverts commit e22bd808a275952c238d97bbd29cf4336304c9e7. --- .github/workflows/main_base.yml | 44 --------------------------------- 1 file changed, 44 deletions(-) diff --git a/.github/workflows/main_base.yml b/.github/workflows/main_base.yml index 6c495d8c..460a5dca 100644 --- a/.github/workflows/main_base.yml +++ b/.github/workflows/main_base.yml @@ -117,47 +117,3 @@ jobs: - name: Run unit tests (saml feature) run: nix-shell -I "nixpkgs=$PIN_URL" --run "cargo test --workspace --lib --features auth_verifier/saml -- --nocapture" - - build-documentation: - name: Build documentation - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v6 - with: - submodules: recursive - - - name: Cache mdBook toolchain - id: mdbook-cache - uses: actions/cache@v4 - with: - path: ~/.cargo/bin - key: mdbook-${{ runner.os }}-${{ hashFiles('server/documentation/theme/scripts/setup-mdbook.sh') }} - - - name: Install mdBook toolchain - if: steps.mdbook-cache.outputs.cache-hit != 'true' - run: sh server/documentation/theme/scripts/setup-mdbook.sh - - - name: Build documentation - run: | - export PATH="$HOME/.cargo/bin:$PATH" - cd server/documentation && mdbook build - - # Secrets are unavailable to fork and dependabot PRs - - name: Checkout public_documentation - if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' - uses: actions/checkout@v6 - with: - repository: Cosmian/public_documentation - ref: develop - path: public_documentation - submodules: true - token: ${{ secrets.PAT_TOKEN }} - persist-credentials: false - - - name: Build combined documentation - if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' - run: | - export PATH="$HOME/.cargo/bin:$PATH" - ln -s "$GITHUB_WORKSPACE" public_documentation/authentication - cd public_documentation - bash .github/scripts/build-staging.sh authentication