Commit Graph

21 Commits

Author SHA1 Message Date
pulse-triage[bot]
9170ad8868 Align OIDC CSRF lifecycle and API security, RBAC, and org Help docs
Align two unclaimed shipped Help guides and their frontend-modern mirrors
with landed runtime behavior in internal/api/:

- docs/OIDC.md: replace the stale "browser cookies with a 24-hour
  lifetime" claim with the landed session vs. CSRF cookie split
  (24-hour __Host-pulse_session / pulse_session cookie; 3-hour 55-minute
  pulse_csrf cookie matching the 4-hour server-side TTL and 8-token cap,
  auto-refreshed and 30-minute proactively rotated on GET /api/*) across
  both OIDC and SAML sections.
- docs/API.md: document GET /api/security/status's three detailLevel
  tiers (public, authenticated, privileged) and Bearer/query-token
  exclusion, GET /api/security/tokens/<id>, POST /api/security/apply-restart
  auth and X-Setup-Token bootstrap gating, RBAC's wildcard (*) token-scope
  and non-default org refusal plus GET /api/admin/rbac/integrity and
  POST /api/admin/rbac/reset-admin, and replace the false "Default org
  members cannot be managed." claim with POST /api/orgs/default/members
  (viewer-only, HTTP 200 / 400 invalid_role), DELETE
  /api/orgs/default/members/{userId}, and the seven invitation and
  incoming-share routes.
- Mirror both guides to frontend-modern/public/docs/ and add
  source-bound regression assertions in scripts/tests/test_oidc_session_docs.py
  and scripts/tests/test_admin_docs.py.

Contract-Neutral: Documentation and source-bound docs tests aligning OIDC and API Help guides with existing internal/api runtime behavior with no runtime, API, or UI contract changes
Change-source: pulse-maintainer
2026-11-29 02:26:45 +00:00
rcourtman
81df19aade Refresh expired CSRF cookies on GET and cap cookie MaxAge (#5398)
## Summary
Fixes `CSRF token validation failed` errors on non-replayed (`retry:
false`) mutations (such as clicking **Generate command** in the remote
commands dialog) after a browser session has been open for more than 4
hours.

### Root Cause
- `CSRFTokenStore` expires server-side tokens after 4 hours, while
`pulse_csrf` cookies were issued with a 24-hour (or 30-day Remember Me)
`MaxAge`.
- `GET /api/*` middleware only issued a `pulse_csrf` cookie when the
cookie was missing, never when an existing cookie was expired or
invalid.
- Because the stale cookie remained in `document.cookie`, `apiClient`
never called `ensureCSRFToken()`, and `retry: false` mutations surfaced
the 403 directly on the first attempt.

### Changes
- Added `csrfTokenTTL` (4h), `csrfCookieMaxAgeSeconds` (3h55m), and
`csrfCookieMaxAge(sessionDuration)` so every `pulse_csrf` cookie expires
slightly before the server-side token (or matches shorter session
durations).
- Updated `GET /api/*` middleware in `internal/api/router.go` to refresh
missing, empty, invalid, or expired `pulse_csrf` cookies for live
sessions, and to proactively rotate valid cookies with less than 30
minutes remaining (coalesced across a 30-second window via
`HasRecentToken` so concurrent page-load GETs mint at most one
replacement token).
- Added unit and middleware regression tests in `csrf_store_test.go`,
`security_test.go`, and `router_csrf_middleware_test.go`.

### Verification
- `go test -v -count=1 ./internal/api -run
'TestCSRF|TestCSRFCookie|TestIssueNewCSRFCookie|TestClearCSRFCookie|TestRouter.*CSRF|TestCheckCSRF'`
- `go test -race -count=1 ./internal/api -run
'TestCSRFTokenStore|TestRouter.*CSRF|TestIssueNewCSRFCookie|TestCSRFCookieMaxAge'`
- `go test -count=1 ./internal/api -run
'Test.*Login|Test.*SAML|Test.*MagicLink|Test.*CloudHandoff|Test.*BasicAuth|Test.*SecuritySetup'`
- `go vet ./internal/api/...`
2026-11-28 16:06:00 +00:00
rcourtman
1b405c35d6 Refresh expired CSRF cookies on GET and cap cookie MaxAge
Server-side CSRF tokens expire after 4 hours in CSRFTokenStore, while pulse_csrf browser cookies were issued with a 24-hour or 30-day MaxAge. On GET /api/*, the router only issued a cookie when pulse_csrf was missing and never checked whether an existing cookie had expired or become invalid.

Once a session passed the 4-hour mark, browsers kept sending the expired pulse_csrf cookie across page loads and GET requests without triggering apiClient's ensureCSRFToken fallback. Non-replayed mutations (retry: false), such as generating a host agent install command, then failed on the first click with 403 CSRF token validation failed.

Fix both halves of the lifecycle:
- Bound pulse_csrf cookie MaxAge across all session and CSRF issuance sites to 3h55m (5 minutes below the 4-hour server TTL, or the session duration when shorter) so idle tabs drop stale cookies before server expiry.
- Refresh missing, empty, or invalid/expired pulse_csrf cookies on GET /api/* for live sessions, and proactively rotate still-valid cookies within 30 minutes of expiry (coalesced over a 30-second window so parallel page-load GETs mint at most one replacement token).

Contract-Neutral: Bug fix aligning pulse_csrf cookie MaxAge with the 4-hour server CSRF token TTL and refreshing expired or near-expiry CSRF cookies on GET /api/* for live sessions, keeping all CSRF admission, 8-token bound, hash-only storage, and retry: false contracts unchanged
2026-11-28 14:12:31 +00:00
pulse-triage[bot]
ffbc0d4f97 Align SAML 2.0 SSO, RBAC, and HSTS Help with runtime
Document shipped SAML 2.0 setup, SP Metadata and ACS endpoints, SAML
Test scope, optional AuthnRequest signing, 10-minute browser-cookie
request binding, SameSite ACS repost handling, IdP-initiated SSO risk,
Single Logout boundaries, and SAML error codes in docs/OIDC.md. Note
SAML's saml_role_assignment audit event alongside OIDC in docs/RBAC.md,
document Strict-Transport-Security and upgrade-insecure-requests on
HTTPS responses in SECURITY.md, sync their shipped Help mirrors, and
add source-bound regression checks in test_oidc_session_docs.py.

Contract-Neutral: Documentation and regression-test alignment only; no runtime, API, security, or UI contract changes.
Change-source: pulse-maintainer
2026-11-28 13:39:09 +00:00
pulse-triage[bot]
9ef5b524eb Align OIDC and RBAC Help with issuer binding and role revocation
Document landed SSO and RBAC access-boundary behaviours from #5034
(36ff8eaa81) and #5079 (9f71173b7a) across docs/OIDC.md, docs/RBAC.md,
and their shipped mirrors in frontend-modern/public/docs/, with
source-bound regression tests in scripts/tests/test_oidc_session_docs.py:

- docs/OIDC.md (+ mirror): document required exact `openid` scope
  validation on enabled OIDC provider writes, partial missing-role
  replacement and fail-closed `session_failed` / `invalid_state`
  callback handling, automatic withdrawal of mapping-origin roles when
  Group Role Mappings are cleared (while preserving manually assigned
  roles), issuer-bound SSO principals when a provider is repointed, and
  exclusion of unverified OIDC emails from legacy assignment migration.
- docs/RBAC.md (+ mirror): document issuer-bound SSO principals when
  repointing an existing provider, partial missing-role replacement and
  `session_failed` refusal, and withdrawal of mapping-origin roles when
  group mappings are cleared.
- scripts/tests/test_oidc_session_docs.py: bind each documented
  behaviour directly to internal/api/identity_sso_handlers.go,
  internal/api/auth_principal_identity.go,
  internal/api/oidc_handlers.go, and internal/api/saml_handlers.go, and
  verify the RBAC.md shipped mirror matches docs/RBAC.md.

Contract-Neutral: Documentation, mirrored in-app Help, and Python doc-regression test alignment for already-landed runtime behaviour with no runtime, API, schema, or subsystem contract changes.
Change-source: pulse-maintainer
2026-11-27 18:55:38 +00:00
pulse-triage[bot]
7b73ade72f Align SSO and Ceph in-app Help with landed UI behaviour
Update docs/FAQ.md, docs/OIDC.md, and their shipped
frontend-modern/public/docs/ mirrors so administrators get accurate
guidance matching current Settings and Proxmox Ceph behaviour:
- SAML setup in FAQ.md now shows that SP Metadata and ACS URL can be
  copied inside Edit while sign-in is disabled, documents metadata-first
  Test precedence and certificate warnings (No signing cert read,
  Expired cert found), and notes that editing a saved SAML provider
  preserves an unset email attribute.
- OIDC.md now explains double-quoting exact directory group names
  containing commas or = in Allowed Groups and Group Role Mappings,
  local rejection of duplicate groups or incomplete pairs, intentional
  blank clears, and inline retry via Edit when settings fail to open.
- Ceph FAQ now explains that clusters without a recognised health
  verdict show Unknown in the table and drawer and stay out of Healthy.

Bind all added guidance to live frontend source in
scripts/tests/test_faq_deployment_docs.py and
scripts/tests/test_oidc_session_docs.py.

Contract-Neutral: Documentation and Python doc-consistency test alignment with already-landed SSO and Proxmox Ceph UI behaviour; no runtime, API, payload, route, or access contract changes.
Change-source: pulse-maintainer
2026-11-26 19:46:49 +00:00
pulse-triage[bot]
2434f8b2ba Keep SAML registration URLs available while sign-in is off
Point administrators to Edit for disabled providers and let them copy
the exact saved SP Metadata and ACS addresses there. Report missing
addresses without falling back to stale inventory. Keep Test, Preview,
manual setup guidance and the editor footer in view on a phone.

Keep the card component unchanged and assert the OIDC setup guidance
in the OIDC form instead of relying on unrelated SAML copy.

Contract-Neutral: Repairs registration guidance and reuses the shared copy control with the existing selected-provider detail fields; card copy visibility, access rules, API, payloads and provider lifecycle are unchanged.
Change-source: pulse-maintainer
2026-11-23 13:13:41 +00:00
pulse-triage[bot]
3f843985b7 Follow the returned OIDC discovery message in docs checks
Check the issuer-match wording on the returned message or its default prefix, with the credential and sign-in limitation on the common return. Keep the issuer rejection checks and add a negative control for losing the complete-discovery qualifier.

Change-source: pulse-maintainer
2026-11-22 19:02:00 +00:00
pulse-triage[bot]
d08c157e59 Keep each OIDC allowlist independent in admin recovery guidance
Keep the empty-groups distinction next to Allowed Groups. Require the independent administrator login after SSO works instead of requiring the old removal suggestion. Retain the existing checks for each callback gate and exercise both misleading alternatives.

Contract-Neutral: Preserves existing sign-in restrictions and role grants in the guide and tests; no runtime, API or access changes.
Change-source: pulse-maintainer
2026-11-20 14:39:45 +00:00
pulse-triage[bot]
9998fa7a2c Let readers restart a stalled SSO provider check
Keep the existing warning and write interlocks while replacing only the pending inventory GET. Let the latest same-reader check settle acknowledged writes, reject displaced read results, and keep keyboard focus in the inventory without overriding deliberate focus changes.

Contract-Neutral: Recovery of an existing authorized inventory read; no change to the SSO API, permission decisions, saved-provider shape, write sequencing, or shared frontend primitives.
Change-source: pulse-maintainer
2026-11-19 08:30:21 +00:00
pulse-triage[bot]
b787f192be Follow the read-only SSO recovery callback in guide checks
Bind the guide consistency check to the visible Check saved providers control and follow its named read callback instead of requiring the old inline spelling. Preserve inventory and detail no-write checks, and reject mutation delegates, direct API writes and duplicate reads with five negative controls. Runtime and existing browser proof are unchanged.

Contract-Neutral: Repair source-consistency verification for an existing read-only recovery control; no runtime, documentation, API or authority contract change.
Change-source: pulse-maintainer
2026-11-17 16:34:10 +00:00
pulse-triage[bot]
b8b55328fa Distinguish saved OIDC providers from deployment-managed configuration
Correct the field-lock and global-override claims, explain the managed-provider rejection and persisted legacy precedence, and document the actual legacy callback default. Keep provider identity, recovery and existing-session boundaries intact.

Contract-Neutral: Documentation and source-consistency tests only. No OIDC runtime, permissions, API or deployment contract changes.
Change-source: pulse-maintainer
2026-11-07 05:31:17 +00:00
pulse-triage[bot]
7b3eb26827 Explain how OIDC login allowlists combine
Put the callback's existing intersection of email, domain and group restrictions at the setup point. Correct the claim that an empty group list admits every identity while preserving administrator mapping and recovery guidance. Bind the help to the independent callback denials and protect it against misleading bypass descriptions.

Contract-Neutral: Documentation and source-consistency coverage only. No authentication, access policy, API or session behaviour changes.
Change-source: pulse-maintainer
2026-11-07 04:29:47 +00:00
pulse-triage[bot]
f28daf5996 Explain recovery from unconfirmed SSO provider changes
Read the current provider list without repeating an uncertain mutation. Preserve administrator access and stop on unexpected absence rather than recreate saved providers. A list or masked field cannot establish secret retention, working sign-in or revocation.

Contract-Neutral: Existing OIDC help and source-consistency checks only. No runtime, endpoint, permission or lifecycle contract changes.
Change-source: pulse-maintainer
2026-11-06 08:14:29 +00:00
pulse-triage[bot]
5c810e0dd8 Correct SSO role-assignment audit guidance
Match the existing OIDC callback and RBAC guide: only successful non-empty assignments emit the assignment event, not cleared roles. Add source-consistency controls to the existing documentation suite.

Contract-Neutral: Correct documentation and drift checks only. Preserve all OIDC, role-assignment, audit, session and access-control behaviour.
Change-source: pulse-maintainer
2026-11-06 07:07:29 +00:00
pulse-triage[bot]
25c7fd2309 Preserve detached persistence for live-owned OIDC refresh
Compose the retained stale-refresh repair with landed session-store persistence isolation. Release the authentication mutex before the synchronous save, adapt source checks and fixtures, and prove registered reads plus a newer logout while real refresh persistence is paused.

Contract-Neutral: Preserve documented session lifetimes, current-session refresh and invalidation policy, provider selection, grants, response fields and encrypted persistence formats; obsolete work cannot act on a replacement or expired session, and persistence remains outside the authentication mutex.
Change-source: pulse-maintainer
2026-11-05 22:35:30 +00:00
pulse-triage[bot]
d0c499941a Follow store-owned OIDC refresh in documentation checks
Repair the preflight source-consistency check after refresh ownership moved into SessionStore. Keep session lifetime, provider-skip, invalidation, rotation and persistence assertions, and check that seven broken ownership/persistence variants are still rejected. Runtime and user-facing documentation remain unchanged.

Contract-Neutral: Test-only source consistency repair; no runtime behavior, documented policy, routes, grants, persisted formats or frontend content changes.
Change-source: pulse-maintainer
2026-11-05 18:01:15 +00:00
pulse-triage[bot]
dc5ce319d3 Align OIDC help smoke checks with truthful issuer discovery
Replace the stale success-copy literal with checks for missing and unequal issuer rejection and qualified discovery-only success. Keep every existing setup/session/access assertion, and use in-memory mutations to prove the consistency check rejects false-green regressions without changing runtime source.

Contract-Neutral: Documentation/source consistency tests only. The completed OIDC runtime, API contract, guides and browser-verified consumer remain unchanged.
Change-source: pulse-maintainer
2026-10-27 12:35:42 +00:00
pulse-triage[bot]
2117b86ea4 Check administrator rights without assuming non-admins are read-only
SSO operators can hold permitted non-administrative write capabilities. The guide now checks the actual instance-administration boundary, without instructing a settings mutation or changing roles.

Change-source: pulse-maintainer
2026-10-12 06:50:03 +01:00
pulse-triage[bot]
0e021c5cb8 Make OIDC setup order and access checks usable
Copy generated callbacks only after provider save, align group-claim advice with provider-specific scopes, and retain administrator access until separate-session permission checks pass. Keep shipped documentation and regression checks in step without changing authentication or provider behaviour.

Change-source: pulse-maintainer
2026-10-12 06:34:38 +01:00
pulse-triage[bot]
7ab21e217e Explain OIDC session and access-removal limits truthfully
Separate browser-cookie lifetime, sliding server sessions and request-driven token refresh. Remove the false provider-change revocation promise, preserve administrator access and document the existing targeted user-removal boundary and private diagnosis.

Contract-Neutral: Documentation and source-consistency tests only; no authentication, session, authorisation or deployment contract changes.
Change-source: pulse-maintainer
2026-10-07 22:51:30 +01:00