|
STAR
Cal STAR — firmware, DAQ server, and engine design
|
Classes | |
| class | UserData |
Functions | |
| str | _sanitize (str part, *, str fallback) |
| str | slugify (str name) |
| str | slug_user (str email) |
Variables | |
| str | _DEV_USER = "local" |
| _UNSAFE = re.compile(r"[^a-z0-9._@-]+") | |
Per-user data storage, keyed on the caller's identity.
Identity comes from the ``X-Auth-Email`` header Caddy injects in production. The
app never gates on it -- Caddy is the gate; this only decides *whose* folder to
read and write. With no Caddy in front (local dev) there is no header, so the
user falls back to ``local`` and everything lands in a gitignored ``.userdata/``
beside the app. A missing header is never a rejection.
Layout, under ``USERDATA_DIR`` (prod: a mounted volume; dev: ``<subproject>/.userdata``)::
<user>/<app>/index.json -- the user's design list
<user>/<app>/<doc-id>/current.json
<user>/<app>/configs/<slug>.json -- the older named-config library
Designs are shared across users (see :mod:`stardesign.documents`): every design
tool mounts one volume, so "list another user's designs, then copy one" is just
reading sibling ``<user>/`` folders -- which is what this layout was chosen for.
Nothing here gates access; that decision lives in the router.
One :class:`UserData` per app binds the ``<app>`` segment, so callers never pass
it. Each app's ``backend/userdata.py`` is a few lines binding this and
re-exporting the methods under their original names, which is what lets every
existing ``userdata.current_user(request)`` call site stay exactly as it was.
|
protected |
Definition at line 46 of file userdata.py.
Referenced by stardesign.userdata.UserData.all_users(), stardesign.userdata.UserData.current_user(), stardesign.userdata.UserData.site_dir(), slug_user(), slugify(), and stardesign.userdata.UserData.user_dir().
| str stardesign.userdata.slug_user | ( | str | ) |
Normalize an email into the directory segment that identifies its owner. Exactly the transform :meth:`UserData.current_user` applies to the header, so an ``?owner=`` query param and the injected identity compare without any special-casing -- which is what keeps an ownership check from hinging on two slightly different normalizations.
Definition at line 57 of file userdata.py.
References _sanitize().
| str stardesign.userdata.slugify | ( | str | name | ) |
Filename-safe slug from a user-given name; ``""`` if nothing usable.
Definition at line 52 of file userdata.py.
References _sanitize().
|
protected |
Definition at line 37 of file userdata.py.
|
protected |
Definition at line 43 of file userdata.py.