Step-up resume UX and editable session-security settings (D-0053) #130

Merged
hannah-vernon merged 1 commit from feature/stepup-resume-ux into dev 2026-09-23 14:12:35 -05:00
Owner

What does this PR do?

Implements step-up resume UX (D-0053): a step-up-gated POST that arrives without a fresh verification is now captured and replayed after the operator completes step-up, instead of being discarded and forcing the operator to re-enter the form.

  • Capture is centralized in the shared AdminStepUpGate: on a gate miss it snapshots the already-buffered form (path plus every field, including the antiforgery token) into an in-memory single-use IPendingStepUpActionStore keyed by session id, with an expiry from the configurable resume-stash TTL.
  • The TOTP and WebAuthn completion handlers redirect to GET /auth/step-up/continue when a pending action exists; that endpoint consumes the stash, finds the RouteEndpoint matching the stored path and POST, rewrites the request into that POST (method, path, urlencoded content type, Request.Form), and invokes its RequestDelegate so the target re-runs its own antiforgery and step-up gate.
  • Two tunables become a database-owned single-row session_security_settings table following the D-0050/D-0051/D-0052 config-store pattern: StepUpValiditySeconds (now read live by the gate and every page's freshness display, replacing the appsettings-only AdminAuthOptions.StepUpValidity) and ResumeStashTtlSeconds. Seeded on admin-API startup from SessionSecurityOptions, edited on /configuration#session-security (step-up gated, audited), hot-refreshed on the viegard_config_session_security_settings NOTIFY channel, and exposed read-only at GET /api/v1/session-security/settings.
  • Also fixes the needless horizontal scrollbar on the step-up modal, and aligns Bans.razor step-up freshness with the live session-security value (it previously read the appsettings-only value). The prior 15-minute effective step-up validity is preserved by seeding the new SessionSecurity section with StepUpValiditySeconds 900.

Rejected alternatives (see D-0053): middleware re-route (WebApplication adds UseRouting first, so the endpoint is already selected before app.Use middleware); threading the captured form through every gate-fail call site (captured once in the gate instead). The pending stash is process-local and carries the existing in-memory guardrail-state caveat: move to Postgres before running the admin API multi-instance.

Fixes #

How was this tested?

  • dotnet build Viegard.slnx - 0 errors, 0 warnings
  • dotnet test - AdminApi 222 passed, Application 564 passed (Postgres integration suite unchanged from its prior 88-pass run; no persistence-layer change this session)
  • Manually tested on ___

Checklist

  • I have read the Contributing Guide
  • Changes are focused - one logical change per PR
  • Documentation updated (DECISIONS.md D-0053, ARCHITECTURE.md, AGENT-README.md, TODO.md, docs/read-only-api.md)
  • New dependencies are MIT/Apache-2.0/BSD, security-vetted, and recorded in THIRD-PARTY-NOTICES.md (no new dependencies)
  • No secrets, credentials, or real infrastructure identifiers in the diff
  • No commented-out code or debug leftovers
## What does this PR do? Implements step-up resume UX (D-0053): a step-up-gated POST that arrives without a fresh verification is now captured and replayed after the operator completes step-up, instead of being discarded and forcing the operator to re-enter the form. - Capture is centralized in the shared `AdminStepUpGate`: on a gate miss it snapshots the already-buffered form (path plus every field, including the antiforgery token) into an in-memory single-use `IPendingStepUpActionStore` keyed by session id, with an expiry from the configurable resume-stash TTL. - The TOTP and WebAuthn completion handlers redirect to `GET /auth/step-up/continue` when a pending action exists; that endpoint consumes the stash, finds the `RouteEndpoint` matching the stored path and POST, rewrites the request into that POST (method, path, urlencoded content type, `Request.Form`), and invokes its `RequestDelegate` so the target re-runs its own antiforgery and step-up gate. - Two tunables become a database-owned single-row `session_security_settings` table following the D-0050/D-0051/D-0052 config-store pattern: `StepUpValiditySeconds` (now read live by the gate and every page's freshness display, replacing the appsettings-only `AdminAuthOptions.StepUpValidity`) and `ResumeStashTtlSeconds`. Seeded on admin-API startup from `SessionSecurityOptions`, edited on `/configuration#session-security` (step-up gated, audited), hot-refreshed on the `viegard_config_session_security_settings` NOTIFY channel, and exposed read-only at `GET /api/v1/session-security/settings`. - Also fixes the needless horizontal scrollbar on the step-up modal, and aligns `Bans.razor` step-up freshness with the live session-security value (it previously read the appsettings-only value). The prior 15-minute effective step-up validity is preserved by seeding the new `SessionSecurity` section with `StepUpValiditySeconds` 900. Rejected alternatives (see D-0053): middleware re-route (WebApplication adds UseRouting first, so the endpoint is already selected before `app.Use` middleware); threading the captured form through every gate-fail call site (captured once in the gate instead). The pending stash is process-local and carries the existing in-memory guardrail-state caveat: move to Postgres before running the admin API multi-instance. Fixes # ## How was this tested? - [x] `dotnet build Viegard.slnx` - 0 errors, 0 warnings - [x] `dotnet test` - AdminApi 222 passed, Application 564 passed (Postgres integration suite unchanged from its prior 88-pass run; no persistence-layer change this session) - [ ] Manually tested on ___ ## Checklist - [x] I have read the Contributing Guide - [x] Changes are focused - one logical change per PR - [x] Documentation updated (DECISIONS.md D-0053, ARCHITECTURE.md, AGENT-README.md, TODO.md, docs/read-only-api.md) - [x] New dependencies are MIT/Apache-2.0/BSD, security-vetted, and recorded in THIRD-PARTY-NOTICES.md (no new dependencies) - [x] No secrets, credentials, or real infrastructure identifiers in the diff - [x] No commented-out code or debug leftovers
A step-up-gated POST that arrives without a fresh verification is now
captured and replayed after the operator completes step-up, instead of
being discarded.  Capture is centralized in the shared AdminStepUpGate:
on a gate miss it snapshots the already-buffered form (path plus every
field, including the antiforgery token) into an in-memory single-use
IPendingStepUpActionStore keyed by session id, with an expiry from the
configurable resume-stash TTL.  The TOTP and WebAuthn completion handlers
redirect to GET /auth/step-up/continue when a pending action exists; that
endpoint consumes the stash, finds the RouteEndpoint matching the stored
path and POST, rewrites the request into that POST, and invokes its
RequestDelegate so the target re-runs its own antiforgery and step-up gate.

Two tunables become a database-owned single-row session_security_settings
table following the D-0050/D-0051/D-0052 config-store pattern:
StepUpValiditySeconds (now read live by the gate and every page's
freshness display, replacing the appsettings-only
AdminAuthOptions.StepUpValidity) and ResumeStashTtlSeconds.  Seeded on
admin-API startup from SessionSecurityOptions, edited on
/configuration#session-security (step-up gated, audited), hot-refreshed on
the viegard_config_session_security_settings NOTIFY channel, and exposed
read-only at GET /api/v1/session-security/settings.

Also fixes the needless horizontal scrollbar on the step-up modal, and
aligns Bans.razor step-up freshness with the live session-security value
(it previously read the appsettings-only value).  The prior 15-minute
effective step-up validity from appsettings is preserved by seeding the
new SessionSecurity section with StepUpValiditySeconds 900.

Docs updated: DECISIONS.md (D-0053), ARCHITECTURE.md, AGENT-README.md,
TODO.md, docs/read-only-api.md.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
hannah-vernon deleted branch feature/stepup-resume-ux 2026-09-23 14:12:35 -05:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
hannah-vernon/viegard-sentinel!130
No description provided.