STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
backend.checkout Namespace Reference

Functions

None require_design_checkout (Request request)

Variables

str DESIGN_OWNER_HEADER = "X-Design-Owner"
str DESIGN_ID_HEADER = "X-Design-Id"
str DESIGN_OWNER_PARAM = "design_owner"
str DESIGN_ID_PARAM = "design_id"
 DesignCheckout = Depends(require_design_checkout)

Detailed Description

Refuse writes to the live config from someone who does not hold the design.

The design bar already refuses to autosave without the checkout, and
``/api/engine/documents/{id}/autosave`` already 423s a non-holder
(``stardesign.documents``). So why gate the config routes too?

Because between those two points sits the session config, and *that* is what the
UI shows you. Without this, a read-only viewer's edits land in their own session,
the screen updates, and nothing ever tells them the design did not change --
the edit simply evaporates at the next reload. Refusing at the point of the edit
is what turns a silent loss into an error.

This is a correctness guard, not a security boundary. The session config is
per-user, so a write here can only ever affect the caller's own view; the
boundary that protects the shared design is the checkout on /autosave.

Which design the caller has open is not something the backend tracks -- the bar
owns that -- so the client names it, either in the ``X-Design-Owner`` /
``X-Design-Id`` headers or, for the optimizer layers, in ``design_owner`` /
``design_id`` query parameters. Both spellings exist because the layer runs are
consumed with ``EventSource``, which cannot set request headers at all.

When no design is named there is nothing to protect and the write is allowed:
the config routes long predate designs, and the file-upload and scripted paths
still use them with no design open at all.

Function Documentation

◆ require_design_checkout()

None backend.checkout.require_design_checkout ( Request request)
423 unless the caller holds the checkout on the design they name.

A no-op when no design is named, or when the named design cannot be found
(it was deleted, or the header is stale) -- an unknown design is not
somebody else's to protect, and 404-ing a config write on a stale header
would be a worse failure than allowing it.

Definition at line 41 of file checkout.py.

Variable Documentation

◆ DESIGN_ID_HEADER

str backend.checkout.DESIGN_ID_HEADER = "X-Design-Id"

Definition at line 36 of file checkout.py.

◆ DESIGN_ID_PARAM

str backend.checkout.DESIGN_ID_PARAM = "design_id"

Definition at line 38 of file checkout.py.

◆ DESIGN_OWNER_HEADER

str backend.checkout.DESIGN_OWNER_HEADER = "X-Design-Owner"

Definition at line 35 of file checkout.py.

◆ DESIGN_OWNER_PARAM

str backend.checkout.DESIGN_OWNER_PARAM = "design_owner"

Definition at line 37 of file checkout.py.

◆ DesignCheckout

backend.checkout.DesignCheckout = Depends(require_design_checkout)

Definition at line 70 of file checkout.py.