T9: Usermap provider (fit.me, fit.people.lookup) #8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "t9-usermap"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
T9: Usermap provider (
fit.me,fit.people.lookup)Stacked on #7 (
t8-registry) → … → #1. Merge those first.What
src/providers/usermap.ts, built against the official Usermap API v1 docs:fit.me: the signed-in user's profile (name, e-mail(s), departments, rooms, phones, personal number), raw role codes, and derivedisStudent/isEmployee/isFitMember(FIT is org unit 18000). The username comes from the FIT connection'sexternalId, which is set at login.fit.people.lookup: exactly one ofusername(exact) orname(RSQLname=='…', case- and diacritics-insensitive, partial words), withlimit≤ 20. For other people it returns directory data only: no personal number, no roles.fit.peoplenamespace with Czech keywords (vyučující,kontakt,adresář, …).src/providers/http.ts, a shared FIT API GET helper:redirect: "manual": a 3xx is an error, so the token only ever goes to the exact URL.reauth_required, 403 → a hint about the missing scope, 404 →null, other errors →upstream_errorwith our own message (the body is never echoed).^[a-z0-9][a-z0-9._-]{0,31}$and URL-encoded. Names are RSQL-quoted with\and'escaped, so;roles=…stays inside the string.test/fixtures/usermap/person.doc-example.jsonis the documented example record. T7 will add PII-scrubbed recordings of real responses.Verified
bun run lint && bun run typecheck && bun run test: 125 tests, 16 of them for Usermap and the HTTP helper. They cover the profile mapping, minimal records, 401/403/404/5xx, unexpected shapes, no redirect following, a timeout during the body read, the RSQL query and escaping, argument validation (including../admin), the privacy of lookup output, and Czech and English search.bun run dev+curl /api/functionslistsfit.status,fit.meandfit.people.lookup.auth.fit.cvut.czafter the redirect change (still OK).Astra review (gpt-6-astra)
Fixed:
Authorizationacross origins. Fixed withredirect: "manual"and treating 3xx as an error. Applied in three places: Usermap calls, the T5 FIT token andcheck_tokenrequests (which carry the client secret), and the T6 login profile lookup. Tests added.res.json()turned into "unreadable response" instead oftemporarily_unavailable. Now the body is read as text first and only JSON parse errors are translated. The same change was made in the FIT client. Test added.🤖 Generated with Claude Code