22 Commits

Author SHA1 Message Date
bluefateludi
4277138581 perf(auth): format only the requested account for profile lookups (#3033) 2026-11-30 11:12:32 +08:00
Bingxi Zhao (Frank)
42cf57bf96 fix(auth): scope password changes and expose temporary-password state 2026-10-31 17:15:58 +08:00
yuleihaotong
35512dccff feat(auth): prompt users who still hold an admin-assigned password
Creating an account through the admin UI means the administrator picks the
password, so the owner starts life with a secret someone else knows. Nothing
in the UI said so: the password form existed, but nobody was sent to it.

- identity: accounts carry must_change_password, set on admin creation and
  cleared once the owner changes the password themselves
- POST /login returns the flag so the client can act on it right away
- GET /profile exposes it for the profile page
- web: after login, a flagged account goes straight to /profile, which shows
  why; the banner disappears once the change succeeds

Backend tests cover both directions: a successful change clears the flag, a
failed one (wrong current password) leaves it alone.
2026-10-30 17:44:24 +08:00
polaris-smart
5357e0c29d refactor(auth): gate learner-only paths on "non-admin" instead of "exactly user"
Align the five remaining two-value gate idioms with the "only 'admin'
elevates" invariant that #1556 now documents: self-service learner-profile
access (_require_local_learner), the admin-managed learner-profile
GET/PUT target checks, the identity-layer set_learner_profile writer, and
device-credential activation (_active_account) admit every non-admin role
instead of only "user".

While the admitted vocabulary is still {"admin", "user"} this is
behavior-preserving; once "teacher"/"student" exist, ordinary accounts
keep learner profiles and device logins instead of being silently
excluded. Admins stay excluded everywhere, including admins carrying a
learner preset.

Tests: a teacher with a learner preset manages their own profile through
the self-service endpoints and via an admin actor; admins (even with a
learner preset) stay rejected at the self-service, admin-managed,
storage, and device-credential layers; a device credential issued for a
teacher logs in and reports the teacher role, while issuance for an admin
still fails closed.
2026-09-24 08:19:39 +08:00
Bingxi Zhao (Frank)
8880529c65 Merge PR batch with local follow-up fixes
Preserve precise learner KB route guards, combine UI and response language domains, carry normalized EPUB extraction, and regenerate frontend contracts.

Update locale fallback coverage for the completed Ukrainian translation bundle.
2026-09-23 12:01:14 +08:00
Bingxi Zhao (Frank)
c0d19dae04 fix(multi-user): preserve newer grant writes during preset rollback 2026-09-23 11:15:47 +08:00
Hermes
3f621d403a refactor(auth): converge all role whitelists on normalize_role, add set_role tests
- models.py: add VALID_ROLES + normalize_role as the single source of truth
- identity.py: route _canonical_record/_migrate_legacy_users/load_users/set_role through normalize_role
- context.py: token payload role mapping via normalize_role
- services/auth.py + api/routers/auth.py: set_role guards validate against VALID_ROLES
- tests/multi_user/test_role_normalization.py: 16 tests, first set_role coverage in repo

Zero behavior change: legal roles pass through; unknown values keep the
same least-privilege degrade path; only guard error strings derived from
sorted(VALID_ROLES) differ.
2026-09-23 01:21:17 +08:00
Bingxi Zhao (Frank)
15c31267cc Merge pull request #1124 from evan188199-tech/codex/feat-learner-profile-controls
# Conflicts:
#	deeptutor/multi_user/identity.py
#	deeptutor/services/session/turn_runtime.py
2026-08-31 20:39:42 +08:00
Bingxi Zhao (Frank)
bac45240be Merge pull request #1113 from evan188199-tech/codex/feat-guardian-authorization
# Conflicts:
#	deeptutor/multi_user/router.py
2026-08-31 20:25:49 +08:00
XZH
93d1a80310 feat(learner): add account-scoped learner profiles 2026-08-30 17:15:01 -07:00
XZH
3f62d85997 feat(learner): add guardian authorization 2026-08-30 07:07:29 -07:00
XZH
8ea83989a6 feat(learner): add server-enforced account presets (#1111) 2026-08-30 06:47:11 -07:00
Bingxi Zhao (Frank)
ce7c2dc2dc release: v1.6.1 — one key, one navigator, one sidebar you arrange
Model configuration was one layer replicated seven times: every service
stored its own profile with its own credentials, so a single OpenRouter
key had to be pasted into five separate pages. This release splits that
in two — a **connection** holds one vendor credential and links it down
to every service that vendor can serve, and a **task model** takes the
calls nobody asks for (naming a conversation, writing the composer's
starting points) off the model picked for actual reasoning. Both are
opt-in; existing per-service profiles resolve exactly as before.

Around that: Settings drops the card grid for a persistent searchable
navigator whose landing page answers "what state am I in" instead of
repeating the directory; Mastery Path files study conversations under
their topic and opens them in the tutor rather than dropping them on
/home; the sidebar folds features into More and reorders by drag; the
reading companion is rebuilt from /home's own chat components; and the
LightRAG engine talks to the SDK directly, so its extra no longer drags
MinerU in transitively.

Also back-merges PR #1041 (Anthropic SDK 1.x temperature via extra_body)
and PR #741 (owner-only auth secret/token files), which had been merged
straight into main and never flowed back to dev.

Release notes: assets/releases/ver1-6-1.md
Gates: pre-commit 15/15, ruff clean, pytest 5802 passed, web 450 node
tests, eslint 0 errors, docs build clean.
2026-08-30 13:19:42 +08:00
Bingxi Zhao
3f6e82405e Merge pull request #741 from lukiod/fix/secret-file-permissions 2026-08-29 11:27:40 +08:00
Bingxi Zhao (Frank)
bd9f6a7625 release: v1.6.0 — connected learning workspaces
Release notes: assets/releases/ver1-6-0.md

Ship source-faithful reading, Courses and Little Tutor, Ask Questions,
bounded web-source sync, and shared Books with private reader state.
2026-08-27 22:03:09 +08:00
Souptik Chakraborty
a5879735b7 fix: Keep env-bootstrapped admin usable and unpromoted (#851)
The identity store had two bugs that combined into a lockout for
deployments whose admin comes from auth.json rather than /register.

load_users() returned the bootstrap admin only when the store was empty,
so writing the first real account dropped it and the operator's login
started returning 401. save_user() then decided first-admin promotion
from load_users() called with no env arguments, an env-blind view, so
with an empty store the first account an admin created from /admin/users
was silently promoted to admin even though that endpoint documents
role="user". Together: create one student account, the student is the
only admin, the operator is locked out.

load_users() now merges the bootstrap admin whenever it is configured; a
stored record with the same username still wins, so the account can be
adopted into the store. The merge stays in memory because no write path
passes the env arguments, so a rotation of auth.json is never shadowed by
a stale persisted hash. save_user() counts a configured bootstrap admin
as an existing account, except when saving that same username, which is
an adoption and keeps the admin role.

The genuinely-empty deployment is unchanged: with no bootstrap
credentials the first /register user is still promoted. A username
configured with an empty hash cannot authenticate and so does not count,
which matters because that is the shipped default.

Fixes #849
2026-08-16 19:07:52 +08:00
lukiod
255e00b19c fix: create auth secret and token files with owner only permissions
Three sites wrote secrets with Path.write_text and narrowed them with chmod
afterwards. write_text creates using 0o666 & ~umask, so the contents were
readable by other local users until the chmod landed, and permanently whenever
it raised, since the error was discarded.

Affected: the auth secret in multi_user/identity.py, minted with
secrets.token_hex(32) and written world readable at creation, the same file on
the legacy migration path, and the skill hub tokens in
services/skill/credentials.py.

write_secret_text passes the mode to os.open so it applies at creation. The
parent directory is created 0700, and a leftover from an interrupted run is
replaced rather than truncated.

Measured on Linux under the default umask: 0644 holding the secret before being
narrowed to 0600.
2026-07-27 22:08:26 +05:30
Ilia Avdeev
7901368bb2 feat: user profile page with avatar (icons + image upload) 2026-06-14 17:43:13 +02:00
Bingxi Zhao (Frank)
46093e5e2b update msg 2026-06-11 20:03:34 +08:00
Bingxi Zhao (Frank)
85779c846b refactor env settings and installation 2026-05-11 12:59:56 +08:00
Bingxi Zhao (Frank)
72bcdd77d8 prepare v1.3.9 release 2026-05-09 02:53:14 +08:00
Bingxi Zhao (Frank)
2c4769a96f prepare v1.3.8 release
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-08 02:36:24 +08:00