Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/admin-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ 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.
# 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 -S '.pnpm.overrides // {}' package.json) \
<(yq -o=json '.overrides // {}' pnpm-workspace.yaml | jq -S .)

- name: Install dependencies
run: pnpm install --frozen-lockfile

Expand Down
46 changes: 0 additions & 46 deletions .github/workflows/main_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -119,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
11 changes: 6 additions & 5 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. 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.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 '<got hash>' > nix/expected-hashes/admin-ui.pnpm.$p.sha256; done
printf '<got hash>' > nix/expected-hashes/admin-ui.pnpm.darwin.sha256 # same for linux-x86_64 / linux-aarch64
```

---
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG/feat_vault-v1-auth-paths.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## 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`.

## 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`.
3 changes: 2 additions & 1 deletion admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
29 changes: 21 additions & 8 deletions admin-ui/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions admin-ui/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@ 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"
minimatch: ">=11.0.1"
2 changes: 1 addition & 1 deletion admin-ui/src/constants/apiPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "_";
Expand Down
2 changes: 1 addition & 1 deletion admin-ui/src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion admin-ui/tests/e2e/machine-credentials.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ async function mockK8s(page: Page, initial: Record<string, K8sRoleConfig>): Prom
async function mockToken(page: Page, valid: boolean): Promise<void> {
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"]);
Expand Down
38 changes: 28 additions & 10 deletions client/src/client/auth_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};
Expand Down Expand Up @@ -889,14 +889,32 @@ impl AuthClient {
) -> AuthResult<AppAuthResponse> {
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),
},
)
.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<AppAuthResponse> {
self.post(
&format!("/v1/auth/userpass/login/{username}"),
&VaultUserpassLoginRequest {
password: password.to_string(),
},
)
.await
}
}

// ── Kubernetes auth API ───────────────────────────────────────────────────────
Expand Down Expand Up @@ -950,7 +968,7 @@ impl AuthClient {
/// No authentication required.
pub async fn k8s_login(&self, role: &str, jwt: &str) -> AuthResult<AppAuthResponse> {
self.post(
"/auth/kubernetes/login",
"/v1/auth/kubernetes/login",
&K8sLoginRequest {
role: role.to_string(),
jwt: jwt.to_string(),
Expand All @@ -966,10 +984,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<AppTokenLookupResponse> {
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();
Expand All @@ -985,11 +1003,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<AppAuthResponse> {
let response = self
.post_raw_with_header(
"/auth/token/renew-self",
"/v1/auth/token/renew-self",
&serde_json::json!({}),
APP_TOKEN_HEADER,
token,
Expand All @@ -1009,11 +1027,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)
Expand All @@ -1028,7 +1046,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<u16> {
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)
Expand Down
Loading
Loading