pediatric-ai-scribe-v3/docs/logic/auth-admin-learning.md
Daniel 025290d64a
Some checks failed
Forgejo Android APK / Root app tests (push) Successful in 47s
Forgejo Docker Build / Root app tests (push) Successful in 45s
Forgejo Android APK / Build signed APK (push) Successful in 2m1s
Forgejo Docker Build / Build Docker image (push) Successful in 9s
Forgejo Docker Build / Deploy to the host (push) Failing after 0s
feat: retire Learning Hub
My Resources generates better slides than Learning Hub ever did — a typed deck
the model fills in, rendered by python-pptx with fit-to-slide text, figures, a
vision review and themes, against Learning Hub's markdown-through-pandoc — and
the articles and quizzes now live in the quiz app. Keeping a second, weaker
generator and a whole CMS beside it was not earning its maintenance.

Removed: three routers, the Learning Hub and Content Manager tabs, their
components and frontend modules, the five database tables, the WebDAV browser,
the content embedding column and its vector index.

Content was exported first — every article as markdown plus a full SQL dump of
all five tables — to ops-backups/learning-hub-export-*. That export is the
restore path; the migration's down() can recreate the shape but never the rows,
and says so.

Two things this simplifies rather than merely deletes:

generated_image_links existed only to record which published content an image
appeared in, and it was the sole reason a generated image could be read by
someone who did not make it. Images are now owner-only — the visibility rule is
one WHERE clause instead of a join across two tables and a published flag.

embeddings.js keeps the model discovery the admin panel uses and loses
searchSimilar and generateContentEmbedding, which queried a table that no longer
exists.

Kept deliberately: Nextcloud connect, disconnect and export, which are how a
generated note reaches a real filesystem and have nothing to do with Learning
Hub; learningRetrieval, which despite its name is the clinical corpus search My
Resources depends on; and the pandoc reference deck, still the fallback when the
python renderer fails, moved from assets/learning to assets/deck now that the
old name misleads.

Tests: four Learning-Hub-only files removed, and the individual cases inside
shared files that asserted its behaviour. Where a test used a Learning endpoint
only as a convenient example — the account-boundary token test, the policy
matrix — it now uses one that still exists, so the property it proves is
unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dv6sqaY6Vq3ChZHMem3cnU
2026-09-12 20:14:20 +02:00

62 lines
2 KiB
Markdown

# Auth, Admin, And Learning Hub Logic
This doc summarizes the current auth/admin/Learning Hub responsibilities. The
source of truth is `server.js`, `src/routes/*.js`, and the focused top-level
docs.
## Auth
- Local auth uses argon2id for new password hashes and bcrypt fallback/rehash
for legacy rows.
- Web sessions use the `ped_auth` httpOnly cookie.
- Mobile sessions use secure token storage and `Authorization: Bearer`.
- `user_sessions` is the authoritative session registry.
- OIDC uses Authorization Code + PKCE through `src/routes/oidc.js`.
- 2FA uses TOTP plus one-time backup codes.
See [`../authentication.md`](../authentication.md) for details.
## Admin Panel
Admin routes live under `/api/admin` and require admin middleware unless the
specific route is explicitly public (for example public config reads used by the
login screen). Admin responsibilities include:
- user management and role changes
- settings and feature flags
- model allowlist/defaults/custom models
- prompt overrides
- SMTP/OIDC/security settings
- health/log views
- milestone management
- admin docs browser
## Learning Hub
Learning Hub has two surfaces:
- learner/user-facing routes under `/api/learning`
- moderator/admin CMS routes under `/api/admin/learning`
Content types include articles, pearls, quizzes, and presentations. AI content
generation can use topic text, uploaded files, or connected Nextcloud/WebDAV
sources. Semantic search uses pgvector embeddings on `learning_content` when an
embedding provider is configured.
See
[`../embeddings-setup.md`](../embeddings-setup.md).
## Security Rules
- Never expose raw secrets in admin health/config responses.
- Keep OIDC issuer validation and SSRF protections intact.
- Keep login, password reset, 2FA, and session endpoints rate-limited.
- Treat Learning Hub uploads as untrusted input and keep file-type checks.
- Sanitize rendered Learning Hub content.
## Change Checklist
1. Check the relevant route and frontend module together.
2. Preserve role middleware order.
3. Run `node --check` on touched JS files.
4. Run `npm test`.