Document the accepted MVP and retire superseded development plans
Rust development slice / linux (push) Failing after 14s

This commit is contained in:
2026-11-18 17:21:12 +01:00
parent f37b6dc4f7
commit 6963ad332c
188 changed files with 370 additions and 34933 deletions
-172
View File
@@ -1,172 +0,0 @@
# PostgreSQL pre-auth state adapter
Enable package feature **`postgres-state`**. Dependencies: SQLx 0.8 (PostgreSQL and
Tokio/rustls only; no macros/automatic migrations), RustCrypto `aes-gcm` 0.10.
The default build still has no SQL dependency. No root-workspace changes are needed.
## Migration and least privilege
Export: `rmm_oidc_auth::postgres::MIGRATION_SQL`, exactly the package-owned file
`sql/001_oidc_login_states.sql`. Transfer this SQL into a future **normal server
migration** under the migration/owner identity; the adapter never runs it. It is
deliberately not idempotent and creates a dedicated schema/table:
`rmm_oidc_auth.login_states(state_hash bytea PRIMARY KEY, binding_hash bytea,
expires_at bigint, created_at bigint, encryption_key_ref text,
encryption_nonce bytea, ciphertext bytea)` plus expiry index and integrity checks.
This is **global PREAUTH state**, not tenant data: no tenant IDs, principal IDs,
memberships or user attributes. Use a separate global-auth-service pool/role, not a
tenant transaction with previous RLS context. Grant only:
```sql
GRANT USAGE ON SCHEMA rmm_oidc_auth TO your_auth_service_runtime_role;
GRANT SELECT, INSERT, DELETE ON rmm_oidc_auth.login_states TO your_auth_service_runtime_role;
```
Replace the example role identifier through the normal deployment configuration,
not a request parameter. Runtime must be **non-owner, NOSUPERUSER, NOBYPASSRLS**,
without schema CREATE, UPDATE, TRUNCATE, tenant-table or migration permissions.
No RLS bypass is needed: the global table intentionally has no tenant RLS policy.
Membership and approval checks remain in the tenant-bound application layer.
Use verified PostgreSQL TLS for remote databases and restricted local transport
where appropriate. Never print DB URLs/passwords or enable parameter logging.
## Configuration and public API
```rust,ignore
use rmm_oidc_auth::postgres::PostgresStateStore;
// Pool supplied by the backend with the dedicated restricted global-auth role.
// Configure bounded acquisition timeout (e.g. 5 seconds) and pool size there.
let state_store = PostgresStateStore::new(
global_auth_pool,
secret_resolver.as_ref(),
"secret-store:rmm/oidc-state-key/version-1".into(),
10_000, // global outstanding-state capacity, including expired rows
).await?;
// Pass Arc::new(state_store) as the unchanged StateStore port to
// OidcAuth::discover(..., Profile::Production, ..., ...).
```
`PostgresStateStore::new(PgPool, &dyn SecretResolver, key_ref: String,
capacity: u32) -> Result<Self>` resolves exactly the configured reference, once.
The secret is **32 cryptographically random bytes encoded as unpadded base64url**.
Do not derive it from a password, the OIDC client secret, or a token claim. The
reference must identify an **immutable version**, not a mutable `latest` alias.
Store the key outside PostgreSQL and backups of login-state ciphertext. Ref strings
are metadata, not secret values. Never log the resolved key.
The library does not automatically read environment configuration. A backend may
map e.g. `RMM_OIDC_STATE_BACKEND=postgres`, `RMM_OIDC_STATE_KEY_REF` and a private DB
connection reference to this constructor; these are integration examples, not
implemented server flags. Missing/invalid configuration must fail startup closed.
`is_persistent()` is true for this adapter; `Profile::Production` continues rejecting
the memory adapter independently. No production in-memory fallback is provided.
## Confidentiality, atomicity and lifetime
- The existing flow generates 256-bit opaque state/binding values and passes only
canonical SHA-256 base64url hashes to `StateStore`. PostgreSQL stores their decoded
**32-byte digests**, not raw handles/cookies. Nonce and verifier are validated as
canonical 32-byte random-value encodings before persistence.
- The complete `PendingLogin` JSON is encrypted with **AES-256-GCM**, a fresh random
96-bit encryption nonce and authenticated associated data binding a fixed format
domain/version, state hash, browser-binding hash, expiry and configured key ref.
Plaintext serialization/decryption buffers and resolved key bytes are zeroized.
The store, pending records and key material have no Debug/log implementation.
Hashes, expiry, version reference and ciphertext length remain DB-visible.
A privileged DBA can delete/deny service, but cannot forge a valid encrypted login
without the external key. Protect the auth-service process and secret resolver.
- Insertion refuses expired states, TTL above **300 seconds**, duplicates and
capacity outside 1..=100,000. Database checks independently bound expiry relative
to creation (600 seconds for clock skew); DB clock also rejects expired insertions.
- A transaction-scoped, database-local advisory lock serializes admission checks
across adapter instances. A fresh READ COMMITTED snapshot prevents capacity races,
even on pools with a different default isolation level. All instances sharing a
table must use the **same capacity policy**. No upsert/overwrite path exists.
- Consumption is one parameterized **`DELETE ... WHERE state_hash=$1 AND
binding_hash=$2 AND encryption_key_ref=$3 AND expires_at > GREATEST($4, DB_now)
RETURNING ...`**. Exactly one concurrent callback receives a record. Wrong binding,
wrong key version, missing/replayed or expired state does not delete a valid row.
Thus a guessed-handle/wrong-cookie request cannot burn someone else's state.
- Delete is committed **before** authenticated decryption/parsing. Corruption,
nonce/code-exchange failure or later callback failure never restores state. A
connection failure during commit has uncertain delivery and fails closed: restart
login, never replay a potentially consumed flow.
- `cleanup_expired(batch: u32) -> Result<u64>` deletes only expired rows, at most
`batch` (1..=**1,000**), using the expiry index and one atomic CTE/DELETE.
It intentionally does not use SELECT FOR UPDATE, which would require granting
UPDATE privilege to this read/insert/delete-only role. Concurrent cleanup calls
may select the same expired batch; only one deletes it, another may return zero.
Call periodically from the global auth service; no background scheduler is spawned.
Each adapter transaction uses a 5-second statement timeout and 2-second lock
timeout; pool/network timeouts are the backend's connection policy. Expired rows
count against capacity until cleaned, deliberately failing closed under overload.
Rate-limit login start/callback independently; database capacity is not a rate limit.
- Key rotation for this first adapter is **drain then switch**: pause new logins,
allow outstanding flows to complete/expire, clean expired rows, switch all instances
to a new versioned external key, resume. Do not silently mutate a referenced key or
mix key versions during rolling deployment. Rotate well before 2^32 encryptions per
key. Old/incompatible ciphertext cannot be accepted by a differently configured key.
All queries use fixed schema/table names and bound data. No runtime table/schema
name interpolation, DDL, role changes, tenant RLS changes or session approvals occur.
## Explicit real PostgreSQL test
```sh
python3 crates/oidc-auth/tests/run_postgres.py
```
The runner refuses an existing container named **`rust-discovery-oidc-test`**. It
creates only that disposable PostgreSQL 17.6 container, publishes an automatically
allocated port **only on 127.0.0.1**, generates a private ephemeral password in memory,
and removes its own container/anonymous volumes afterwards. Existing PostgreSQL and
RMM containers are never inspected for credentials, restarted, migrated or reset.
No credential file, stdout secret, host service package or VM change is needed.
The Rust integration test is explicitly ignored in ordinary test runs. The runner
opts in with `RMM_OIDC_TEST_ALLOW_OWNER_DDL=isolated` and a private
`RMM_OIDC_TEST_DATABASE_URL` passed only through process environment; only the
disposable owner test identity applies fixture DDL and creates a separate restricted
runtime role. Do not point these variables at a real server database.
Checks: runtime nonownership/no superuser/no BYPASSRLS/no schema CREATE and actual
DDL rejection; encrypted persistence; wrong-cookie non-burning; caller/DB expiry;
duplicate/replay rejection; exactly one winner among 16 callbacks; authenticated
ciphertext-tamper rejection and consumption; concurrent capacity 2/8; bounded TTL
cleanup; invalid hashes/TTL rejection. This is a local native PostgreSQL test, not
server/VM or external-IdP acceptance. Actual run results are recorded separately.
## Actual local verification — 2026-11-12
Executed on the development Linux host, not the Linux test VM:
- `cargo clippy --manifest-path crates/oidc-auth/Cargo.toml --all-targets --all-features --locked -- -D warnings`: passed.
- `cargo test --manifest-path crates/oidc-auth/Cargo.toml --all-features --locked`:
**13 unit tests passed**, 0 failed; the explicit-owner PostgreSQL test is ignored
in this general run; 0 documentation tests.
- `python3 crates/oidc-auth/tests/run_postgres.py`: **1 actual PostgreSQL integration
test passed**, 0 failed, 0 ignored. PostgreSQL 17.6; restricted non-owner role with
real DDL/UPDATE rejection; **1/16** concurrent consume winners; **2/8** concurrent
capacity admissions. Also checked ciphertext, binding non-burning, DB/caller expiry,
duplicates/replay, tamper consumption, cleanup limits, key-version mismatch,
invalid key/hash and overlong TTL rejection. Own disposable container removed.
- `cargo check --manifest-path crates/oidc-auth/Cargo.toml --lib --no-default-features --locked`: passed.
- `cargo fmt --manifest-path crates/oidc-auth/Cargo.toml --check`: passed.
- `cargo package --manifest-path crates/oidc-auth/Cargo.toml --allow-dirty --features postgres-state --locked`:
packaged **11 files** and verified the extracted package build successfully.
Non-failing warning: package metadata has no description/documentation/homepage/repository.
The first Clippy run rejected a deprecated generic-array nonce constructor; replaced
with array conversion, no lint suppression. The first real database run reached
cleanup but failed there: SELECT FOR UPDATE required UPDATE permission. Cleanup
was changed to a bounded atomic CTE/DELETE, retaining the restricted role rather
than expanding its privileges. Both subsequent real PostgreSQL runs passed, including
the final expanded test. No server DB migration/reset, runtime server restart,
membership change, host package installation, VM effect or production acceptance.
The migration has been applied only to the disposable test database. Applying it
through normal server migrations, provisioning the global auth role/key reference,
and wiring backend configuration/routes remain explicit integration work.
+3 -162
View File
@@ -1,164 +1,5 @@
# RMM OIDC authentication adapter (standalone package)
# Authentisierung im MVP
Optional encrypted SQLx/PostgreSQL login-state storage and its migration/permissions
contract: **[POSTGRES.md](POSTGRES.md)** (`postgres-state` feature).
Die öffentliche WebUI verwendet ein lokales Konto mit Passwort und TOTP. Der MCP-Server prüft kundengebundene Bearer-Tokens. Die Einrichtung dieser beiden Zugänge steht in der [Betriebsanleitung](../../docs/public-access.md).
This crate is **not wired into the server** and does not change the root workspace.
It authenticates against a configured HTTPS OIDC provider using real RSA signatures,
discovery, JWKS and authorization-code exchange. It never grants tenant membership,
roles, approval authority or an RMM session by itself. External IdP configuration is
currently **not_configured**; no external-provider or VM acceptance is claimed.
## Explicit supported provider profile
- RS256 only, RSA signing JWKS with unique `kid`, `alg=RS256`, `use=sig`.
Mixed-algorithm JWKS are deliberately rejected by this initial strict profile.
- Configured issuer is the only authority. Discovery's issuer must match exactly;
authorization, token and JWKS endpoints must be HTTPS, same **origin** (including
port) as that issuer, with no userinfo, fragment or query. Providers using a separate
CDN/origin for JWKS are not supported, rather than automatically trusted.
- Normal rustls trust roots, optional explicitly provisioned CA roots; no HTTP,
insecure certificate mode, HTTP redirects or environment proxy. Administrators
must restrict configured issuers/network egress; user input cannot choose issuers.
- Browser: authorization code, `openid`, PKCE S256, random nonce/state/browser binding,
fixed registered HTTPS callback, `client_secret_post`. The IdP must advertise these
features. PKCE rejection surfaces as `CodeExchange`; response bodies are not logged.
- MCP: RFC 9068 JWT **access** token with `typ=at+jwt`, dedicated resource audience,
approved `client_id`, required `jti`, issuer/signature/expiry/nbf/iat checks, required scopes.
Opaque/introspected tokens and other JWT access-token profiles are unsupported.
Browser ID tokens are never accepted as bearer credentials.
- JWT validity uses zero clock leeway; synchronize clocks. Browser multiple audiences
require matching `azp`; any supplied browser `azp` must match the browser client ID.
- JWKS cache TTL 300 seconds; unknown-kid refresh throttled to once per second,
serialized across callers. A newly rotated key may require retry after one second.
Invalid JWKS/failed refresh clears the old key cache and fails closed. Revocation of
a cached key is bounded by the TTL, not instantaneous. Issuer operator must rotate
to a **new kid** (same-kid replacement is visible on the next TTL refresh).
- HTTP connect timeout 3 seconds, total request timeout 10 seconds, response 128 KiB,
JWT 32 KiB, code 4 KiB, maximum 64 signing keys. No refresh-token persistence.
## Public integration API
```rust,ignore
let auth = OidcAuth::discover(
Config {
issuer: Url::parse("https://idp.example/realms/rmm")?,
browser_client_id: "rmm-browser".into(),
client_secret_ref: "secret-store:rmm/oidc-client".into(),
redirect_uri: Url::parse("https://rmm.example/auth/oidc/callback")?,
mcp_audience: "https://rmm.example/mcp".into(),
mcp_client_ids: BTreeSet::from(["approved-mcp-client".into()]),
},
Profile::Production,
persistent_state_store,
secret_resolver,
vec![], // normal roots; provision a private CA explicitly if necessary
).await?;
let start: LoginStart = auth.login_start().await?;
// Set start.binding_set_cookie and redirect to start.authorization_url.
let identity: Identity = auth.callback(Callback {
code: parsed_query_code,
state: parsed_query_state,
browser_binding: parsed_host_binding_cookie,
}).await?;
let bearer: BearerIdentity = auth
.verify_mcp_bearer(raw_bearer, &["inventory:read"]).await?;
```
`SecretResolver::resolve(reference)` returns `secrecy::SecretString`; resolve from an
authorized secret store, never from a token claim. The adapter exposes only coarse
typed `Error`s, not reqwest errors (which may contain URLs), codes or token bodies.
Do not log callback URLs, authorization URLs, cookies, state records, secrets or JWTs.
Sensitive flow types intentionally do not implement `Debug`.
### Required server/cookie adapter work (not implemented here)
1. Register login start and **GET** callback routes. Rate-limit both; do not allow
caller-supplied issuer, audience, scopes, redirect URI or post-login return URL.
Reject duplicate query/cookie parameters and provider error callbacks. Return
`Cache-Control: no-store` and `Referrer-Policy: no-referrer` on all auth routes;
avoid request/query logging and third-party resources there.
2. Set `LoginStart.binding_set_cookie` verbatim: `__Host-rmm_oidc_binding`, Secure,
HttpOnly, Path=/, **SameSite=Lax**, Max-Age=300, no Domain. Strict would omit this
cookie on the cross-site provider callback. Start replaces an outstanding binding;
multi-tab login is intentionally fail-closed, not a bypass.
3. Pass only parsed code/state and binding cookie value to `callback`. The store must
atomically consume state before token exchange. On terminal callback success or
failure, clear binding with `CLEAR_BINDING_COOKIE`; failures require fresh login.
4. Resolve `Identity { issuer, subject }` to a persistent principal and **current**
scoped memberships. Email and untrusted group/role claims are not identity keys or
memberships (this crate does not expose them). No implicit all-tenant role.
5. On browser success only, rotate/create a new opaque RMM session, bound to that
principal, with bounded expiry and the existing Secure/HttpOnly/host-only
**SameSite=Strict** final session cookie. Keep CSRF token + exact Origin checks
for writes, authorization checks and explicit UI plan approval. An ID token is
not an RMM session cookie or permission to approve a plan.
6. Bearer always wins over browser cookies. Use `verify_mcp_bearer` only for MCP/API
bearer paths; combine returned scopes with persistent memberships on **every**
request. Never construct an interactive browser session or approval context from
a bearer token, even if a principal has an approver membership. Preserve
`pending_approval` and all immutable plan/attempt bindings.
7. Logout must invalidate the **server-side RMM session**, clear the final cookie,
require its normal CSRF/Origin checks and prevent reuse. IdP logout is intentionally
not implemented or falsely advertised; local logout does not end an IdP session.
8. Disable dev identities/simulated principals in production independently of this
crate. Existing dev identity auth is not replaced until the backend is integrated.
### Persistent state store port
Alternative adapters must implement async `StateStore::{insert, consume}` plus `is_persistent() == true` using
shared durable storage. Do not merely return true for a memory-backed adapter.
State lookup keys and browser bindings supplied to the store are SHA-256 base64url
hashes; records contain nonce, verifier and absolute Unix expiry. Protect record
contents at rest and restrict database access. `insert` must enforce unique keys,
bounded capacity and expiry cleanup. `consume` must perform one atomic conditional
delete/return based on `(state_hash, binding_hash, expires_at > now)`; no read-then-
delete race, no restoration after exchange/nonce failure. A SQL transaction or
`DELETE ... WHERE ... RETURNING` is suitable. Store failures must fail closed.
`dev::InMemoryStateStore::new(dev::DevTestOnly)` exists only under the explicit
`dev-memory-store` feature or unit tests. `Profile::Production` rejects it. This is
not a production SQL adapter. The optional PostgreSQL adapter below supplies durable
encrypted storage; applying its migration and server wiring remain integration work.
## Targeted local verification
```sh
cargo fmt --manifest-path crates/oidc-auth/Cargo.toml --check
cargo clippy --manifest-path crates/oidc-auth/Cargo.toml --all-targets --all-features -- -D warnings
cargo test --manifest-path crates/oidc-auth/Cargo.toml --all-features
```
Tests run a native loopback HTTPS OIDC provider with an ephemeral private CA, real
2048-bit RSA signing keys/JWKS, actual one-use authorization codes, real form-encoded
token exchange and server-enforced PKCE. The CA is added only to the test clients,
never to the host truststore. No checked-in private key, external IdP, VM modification,
host-service installation, Docker/server restart or reboot is needed. The provider
is a test double, not a claim of external-provider interoperability or VM acceptance.
Test assertions/counters contain no secret output. Run results are reported separately
by the implementation dispatch, not presumed by these commands.
### Actual local verification (2026-11-12)
Executed on the development Linux host, not the Linux test VM:
- `cargo fmt --manifest-path crates/oidc-auth/Cargo.toml --check`: passed.
- `cargo clippy --manifest-path crates/oidc-auth/Cargo.toml --all-targets --all-features -- -D warnings`: passed.
- `cargo test --manifest-path crates/oidc-auth/Cargo.toml --all-features --locked`:
**13 passed, 0 failed**; 0 documentation tests. Covers real code exchange,
browser binding/replay/expiry/concurrency, PKCE failure, nonce/authorized party,
issuer/audience/expiry/nbf/iat/required claims/scopes, algorithm/signature/ID-token
confusion, JWKS caching/rotation, actual TLS trust/hostname rejection, discovery
origin restrictions, HTTP redirect rejection and response/token size limits.
- `cargo metadata --manifest-path crates/oidc-auth/Cargo.toml --no-deps --format-version 1`:
independent workspace at `crates/oidc-auth`, exactly one member and own lockfile.
Initial build checks found missing URL serde and JWT PEM feature flags; both were
fixed. Clippy found an unnecessary test `format!`, also fixed. The final commands
above passed after those corrections. Pinned lockfile resolves jsonwebtoken 10.4.0,
reqwest 0.12.28 and rustls 0.23.46 on the repository's Rust 1.99.1 toolchain.
Not executed in that initial verification: external real-IdP interoperability, production SQL state adapter,
server routes/cookies/sessions/membership integration, VM execution or browser UI
login against the running RMM server. Timeout values are configured; a deliberately
stalling provider timeout test has not been run. No production acceptance claimed.
Dieses Rust-Paket wird vom Server als lokale Abhängigkeit eingebunden und enthält den separat konfigurierbaren OIDC-Adapter. Im öffentlichen MVP ist dieser Adapter deaktiviert. [Server-Abhängigkeiten](../server/Cargo.toml) · [Authentisierung im Server](../server/src/auth.rs)
-200
View File
@@ -1,200 +0,0 @@
# Integrated OIDC/OAuth authentication
The server now wires `rmm-oidc-auth` into real browser, HTTP and MCP paths. External
IdP deployment is **not_configured** unless the administrator supplies configuration.
No external-provider interoperability or production/VM acceptance is implied.
## Configuration
Set `RMM_OIDC_CONFIG_FILE` to an absolute, regular non-symlink **0600** JSON file
with a same-owner, non-group/world-writable parent. All secret references are absolute
0600 private files with that same owner and safe parent. Their contents are never
passed as argv, logged, reflected in errors or read as shell. Example (placeholders):
```json
{
"issuer": "https://idp.example/realms/rmm",
"browser_client_id": "rmm-browser",
"client_secret_ref": "/private/rmm/oidc-client-secret-v1",
"redirect_uri": "https://rmm.example/auth/oidc/callback",
"mcp_audience": "https://rmm.example/mcp",
"mcp_client_ids": ["approved-mcp-client"],
"auth_database_url_ref": "/private/rmm/oidc-auth-database-url",
"state_key_ref": "/private/rmm/oidc-state-key-v1",
"extra_ca_file": null,
"testsimulation": false
}
```
`RMM_UI_ORIGIN` must be the exact HTTPS origin without trailing slash. The callback
must equal that origin plus `/auth/oidc/callback`. Normal roots are used; optional
`extra_ca_file` explicitly provisions a private IdP CA, never an insecure TLS mode.
Issuer discovery/JWKS/endpoints use configured-issuer same-origin HTTPS, no redirects,
fixed RS256 and bounded requests. The supported provider profile is documented in
`../oidc-auth/README.md` (PKCE S256, nonce, client_secret_post; RFC9068 access tokens).
`state_key_ref` contains 32 random bytes encoded as unpadded base64url, with an
immutable versioned reference. The package's AES-256-GCM state protection, 300-second
TTL, atomic binding/consume, capacity and drain-before-key-rotation rules remain intact.
Global state cleanup runs in bounded 1,000-row batches every 30 seconds.
Production requires `RMM_PROFILE=production`, `RMM_DEV_AUTH=false`, configured OIDC
and **no** RMM_DEV_USERNAME/PASSWORD, RMM_OPERATOR_A/B or RMM_VIEWER_A/B values.
Production with dev auth is rejected before connecting. `testsimulation=true` is
accepted only in the explicit development profile, never derived from token claims.
Development retains the existing separately credentialed browser/viewer/operator
paths. Neither profile silently falls back after invalid explicit bearer credentials.
Non-OIDC production gaps remain: the local ArtifactStore is still development-only;
artifact-dependent features fail closed until a production adapter is supplied.
Root/APT selected policies remain development-only and unchanged in their authority.
## Migration and provisioning
Normal migration **0011_oidc_auth.sql** creates global encrypted pre-auth state and
the administrator-maintained external identity index, extends membership kind with
`human` and constrains authorization audit pairs to exactly:
- `dev_test_browser_simulation` + `testsimulation=true`
- `human_webui` + `testsimulation=false`
The runtime does **not** create schemas, tables, identities, memberships or roles.
Apply normal migrations without resetting DB/PKI. Provision a separate global-auth
login identity with only schema USAGE and table SELECT/INSERT/DELETE on
`rmm_oidc_auth.login_states`. The server verifies that this pool is neither superuser,
BYPASSRLS, table owner nor schema creator, and cannot SELECT tenant memberships.
The tenant application pool remains `rmm_app`, nonowner and RLS-bound. Neither needs
a general RLS bypass. Do not reuse the tenant application's database URL for auth state.
An administrator explicitly registers each external `(issuer,subject)` in
`public.oidc_principals` and assigns tenant routing references; the principal ID is:
`oidc:` + lowercase SHA-256 hex of compact UTF-8 JSON `[issuer,subject]`.
Rust helper: `oidc::principal_id`. Email/group claims are never identity or membership.
The index is routing metadata only: each chosen tenant still requires a current,
unrevoked `memberships` row with explicit permissions. Browser login additionally
requires membership kind **human**. No auto-registration, tenant or role grants occur.
Disabling the index entry revokes subsequent auth and persisted permission rechecks,
including start-time rights checks for existing plans. Membership revocation is read
on every authenticated HTTP/MCP call, not cached from an ID token or browser session.
Only narrow, fixed-search-path SECURITY DEFINER lookup functions expose identity
routing/enabled status to rmm_app; they do not bypass/query memberships RLS or return
foreign inventory. MCP/HTTP permissions intersect the validated access-token scopes
with current membership. Script/root operations retain their additional permission
and selected-helper checks. Bearers have no interactive session context, even with
an approver membership/scope plus a valid browser cookie.
## UI-compatible routes and cookie contract
- `GET /auth/config`: `{oidc_configured,oidc_login_url,dev_login_enabled}`.
`oidc_login_url` is `/auth/oidc/login` when configured, otherwise null. UI can show
a nonempty configured-provider sign-in link without knowing secrets.
- `GET /auth/oidc/login`: code-flow redirect, binding cookie
`__Host-rmm_oidc_binding`, Secure/HttpOnly/Path=/, **SameSite=Lax**, 300 seconds.
- `GET /auth/oidc/callback`: code + state (optional issuer response check), duplicate
query/cookie rejection, one-use DB state, token exchange and nonce/PKCE/signature
checks, persistent principal/membership mapping. Clears binding on success/failure.
Establishes a new opaque RMM session and redirects only to `/`, never user input.
- `GET /auth/session`: existing DTO retained (`principal`, `tenant_id`, `permissions`,
`roles`, `csrf_token`, `testsimulation`, `approval_origin`). Final cookie remains
`__Host-rmm_session`, Secure/HttpOnly/host-only, **SameSite=Strict**, one hour.
Sessions remain in memory; restart requires fresh OIDC login, not job resubmission.
- `POST /auth/logout`: exact Origin + session CSRF; server-side invalidation and cookie
clearing. Local RMM logout only; no false claim of IdP logout.
All auth responses are no-store/no-referrer. Do not enable callback/query logging,
browser traces, HAR, screenshots or third-party resources on auth pages. Browser
writes and plan authorizations retain exact Origin/CSRF and immutable plan binding.
Tenant selection comes from the API path, overriding an incoming X-RMM-Tenant header;
MCP dispatch selects its explicit tenant_id. X-RMM-Tenant is only a selection hint for
other calls, never authority: it must exist in the mapped index AND current tenant
membership. `/api/v1/tenants` lists current readable memberships using separate RLS
transactions. Foreign tenant/asset paths remain not-found, not token-controlled routing.
## Targeted integration tests
`python3 tests/oidc/server_integration.py` starts an ephemeral native TLS mock IdP
and native loopback API instance against the existing development PostgreSQL. It
provisions/removes only its own synthetic identity/human membership and a distinct
restricted auth-state login role. No approval/job/permit/VM fixture is fabricated.
It uses a private ephemeral CA, real RSA signatures/JWKS, actual one-use code exchange
and PKCE. The Chromium step uses a temporary NSS truststore, no TLS bypass/artifacts,
and actual provider UI navigation/cross-site callback; **no job approval** occurs.
It also starts a configured production-profile API with simulation false to check
the production auth path, not to claim real-provider/human production acceptance.
Credentials are parsed internally from local private development configuration;
never printed, sourced, passed in argv or included in test failure output.
Existing backend contract, transport, pages/catalog, sync and local integration tests
remain required after deployment. Actual commands/counts are returned by the dispatch;
the descriptions here are not presumed successful test results.
## Verified local auth increment (2026-11-12)
- Native server build and `cargo clippy -p rmm-server --all-targets --locked -- -D warnings`
passed; changed server files passed targeted rustfmt checking.
- Targeted Rust tests: server **7**, domain **11**, protocol **3**, persistence **0**;
all passed. Three server tests cover the added cookie/scope/identity contracts.
- Standalone OIDC package: **13** unit tests passed; the ordinary run explicitly
ignores its owner-opt-in database test, then `tests/run_postgres.py` ran that **1**
real PostgreSQL integration test successfully (1/16 consume, 2/8 capacity).
- Integrated native server/real mock TLS/real PostgreSQL/Chromium test:
**35 assertions passed**, including production-profile startup with OIDC configured,
simulation false and dev login absent, and actual MCP tool scope enforcement.
No plan was approved or executed by this increment.
- Python syntax checks and Node browser-script syntax check passed.
Initial build/harness failures were corrected without weakening checks: root Cargo
needed to exclude the nested standalone OIDC workspace; Python environment merging
needed to avoid duplicate keywords; dev login must not register its JSON extractor
route in production; MCP testing must consume a concrete SSE response instead of
waiting for stream closure. A backend regression also exposed that tenant-denied
authentication must preserve NOT_FOUND in the MCP/HTTP structured error code; the
shared mapper now preserves it instead of calling every failure UNAUTHENTICATED.
External IdP configuration and all VM/real-human production-approval acceptance
remain open. The running development deployment intentionally retains its existing
dev identities unless an administrator provisions the OIDC configuration and the
separate state-pool identity; no sample provider is silently enabled there.
### Final deployed backend verification
Normal additive migrations **0009, 0010 and 0011** were applied without DB/PKI
reset; successful migration history is **1 through 11**. Docker release build of
server **and agent** succeeded after adding the exact embedded helper unit
`deploy/linux/rmm-apt-helper.service` to the Docker COPY/context whitelist. The
unit/helper/provider source and its hardening were not altered by this auth work.
`python3 deploy/dev.py up` rebuilt/recreated only the project server/migration service;
existing PostgreSQL stayed running. Final server observation:
- started **2026-11-12T19:12:38.969913632Z**, status running;
- image `sha256:545318218433a5d0be96c9368096cb2850b059be0b690bee5044ab28aad5cb82`;
- published TLS port only `127.0.0.1:18443`; PostgreSQL has no published port;
- actual `/auth/config` returns dev login enabled, OIDC not configured, login URL null.
All five affected backend integration programs then passed against that deployment:
| Program | Actual PASS assertions |
| --- | ---: |
| `tests/backend_contract.py` | 42 |
| `tests/backend_transport.py` | 20 |
| `tests/backend_pages_catalog.py` | 25 |
| `tests/backend_sync.py` | 28 |
| `tests/local_integration.py` | 35 |
| **Total** | **150** |
These are assertion counts in five integration programs, not 150 Rust test cases.
They cover unchanged immutable pending/approval boundaries, mTLS and rotation,
fencing/housekeeping, catalog/pagination/membership, signing-key/bootstrap,
Sync/reconnect/restore denial, extended native inventory and tenant isolation.
The final NOT_FOUND mapper correction passed the previously failing MCP foreign-
tenant contract. Four additional actual database-boundary assertions passed:
rmm_app cannot directly read pre-auth state or the external identity index, the
narrow lookup rejects a missing identity, and rmm_app remains non-superuser/non-BYPASSRLS.
No VM/systemd/root/APT effect, positive plan approval or privileged-helper execution
was performed by this dispatch. Linux-MVP, positive consumed-job/helper SyncAck and
real external-IdP/human production-approval acceptance remain separate gates.
+1 -1
View File
@@ -1,7 +1,7 @@
//! Pure release verification. This crate does not install, stage, start services,
//! grant approval, persist antirollback state, or trust keys from the network.
//!
//! See docs/agent-updater-proposal.md for the separate, unfinished integration.
//! The release catalog and deployment workflow are described in `docs/development.md`.
mod bootstrap;
mod manifest;