The server admin's endpoints, under /api/admin/..., for users with the
account role admin (docs/accounts.md). Called by the server admin page
(ServerAdmin.tsx, through api/serverApi.ts).
- Authentication: the session cookie of an admin (with
x-annotinder: 1), from a login with the second factor; without one, 403mfa_required. The sensitive actions below need a recent login too (403step_up_required;security.md§1). - Not with an API key: a key works as a researcher at most, also an
admin's, so every endpoint here answers a key 403
admin_required. - Non-admins get 403
admin_required. Admins get no study data here (no designs, units or answers). Every change goes to the admin log. - Errors as everywhere (README). Rate limits: the
researcher API's (
security.md§3). - Contracts:
adminEndpointsincontracts/src/endpoints/admin.ts, schemas incontracts/src/admin.ts. Implementation:server/src/researcher/admin.tsand one file per section next to it (admin.settings.ts,admin.plans.ts,admin.users.ts,admin.requests.ts,admin.studies.ts,admin.log.ts), withshared/adminQueries.ts,shared/accounts.tsandshared/limits.ts.
| Endpoint | Request | Response | |
|---|---|---|---|
| getWarnings | GET /admin/warnings |
– | ServerWarningSchema[] |
| getSettings | GET /admin/settings |
– | ServerSettingsSchema |
| putSettings | PUT /admin/settings |
ServerSettingsSchema |
ServerSettingsSchema |
| listPlans | GET /admin/plans |
– | PlanSchema[] |
| createPlan | POST /admin/plans |
PlanWriteSchema |
PlanSchema (201) |
| updatePlan | PUT /admin/plans/:id |
PlanWriteSchema |
PlanSchema |
| deletePlan | DELETE /admin/plans/:id |
– | – (409 for the default plan) |
| listDomains | GET /admin/domains |
– | DomainRuleSchema[] |
| putDomain | PUT /admin/domains/:domain |
DomainRuleWriteSchema |
DomainRuleSchema |
| deleteDomain | DELETE /admin/domains/:domain |
– | – |
| listUsers | GET /admin/users?q= |
– | { users: AdminUserSchema[], next? } (a list; 200 a page) |
| createUser | POST /admin/users |
AdminUserCreateSchema |
AdminUserSchema (201) |
| updateUser | PUT /admin/users/:id |
AdminUserUpdateSchema |
AdminUserSchema |
| deleteInvitation | DELETE /admin/users/:id |
– | – (a user who hasn't logged in yet) |
| getUserDeletion | GET /admin/users/:id/deletion |
– | AccountDeletionSchema |
| deleteUser | DELETE /admin/users/:id |
ConfirmDeletionSchema |
– (a registered user) |
| listResearcherRequests | GET /admin/requests |
– | ResearcherRequestSchema[] (the oldest 200 open ones) |
| decideResearcherRequest | POST /admin/requests/:userId |
{ approve } |
– |
| listAdminStudies | GET /admin/studies?q= |
– | { studies: AdminStudySchema[], next? } (a list; newest first, 200 a page) |
| updateAdminStudy | PUT /admin/studies/:id |
AdminStudyUpdateSchema |
AdminStudySchema |
| listAdminLog | GET /admin/log?q= |
– | { entries: AdminLogEntrySchema[], next? } (a list; newest first, 100 a page) |
Notes:
- warnings: what makes the server less secure (
2fa_not_required,email_verification_not_required,unverified_roles,no_2fa_signal,migration_not_finished,no_session_check;security.md§1 "Hardening warnings"). - settings:
registration(open: every user with an email address is a researcher, a role row for everyone;requests: users can ask),defaultPlanId, and the largest unit (unitBytes) and answer (answerBytes), in bytes of JSON. - domains:
uni.nlmatches that domain,*.uni.nlalso its subdomains.researcher: users with a verified email there are researchers (a role row by domain,docs/accounts.md§2);planId: their plan (the most generous of several). - plans:
limits(LimitsSchema) holds the limits (a number, ornull/ left out for none) andcrowdSignIn: whether a crowd's coders may sign in in the studies of researchers on the plan (true; left out orfalse: no;docs/accounts.md§3). - updateUser: fields left out stay.
limitsreplaces the user's overrides ({}clears them;nullfor a limit is no limit;crowdSignIn: trueorfalsegoes over the plan's, left out takes it).blockedends their sessions; API keys stop working while blocked. An admin can't block themselves or take away their own admin role (409). Every change of who is an admin is sensitive (403step_up_requiredwithout a recent login): giving or taking theadminrole, and blocking, unblocking or restoring the roles of a user who holds it. - listUsers:
qfinds users by email address or name. Per user also theirnameat the login provider (for display), where their account role comes from (roleVia: their own role, theirdomain, oreveryone), whether they logged in yet (registered; else an invitation,invitationExpiredafter 3 months), roles the safeguards turned off (rolesDisabled), whether their latest login had the second factor (hasMfa), and, while the server moves to another login provider, whether they linked a login there (linked). - createUser: invites an email address: the role goes to the user who
has it now, else to a shadow user that their first login claims
(
docs/accounts.md§1; the same address again is the same invitation). With roleadmin: sensitive, as above. - updateUser
restoreRoles: turns the roles the safeguards turned off on again (server and studies). - deleteInvitation: withdraws an invitation (a user who hasn't logged in yet), with its roles. No body. Sensitive if the invitation is for the admin role.
- getUserDeletion: what deleting the user's account would do, as the
researcher API's
getAccountDeletionsays it for one's own:email(the address to type),studies(deleted with the account: the ones they own and nobody else has a role in),blocking(studies that keep the account:shared,last_admin) andlastAdmin(the server's only admin). 404 for an unknown user. - deleteUser: the same route as
deleteInvitation, for a user who has logged in: deletes their account (logins, sessions, roles, API keys, security log) and thestudiesofgetUserDeletion, as they would delete it themselves (docs/accounts.md§5). The body is{ confirm: <the user's email address> }(400confirmation_mismatch). 409account_has_studiesorlast_adminwhile something keeps the account; 409 for your own account (delete that with the researcher API'sdeleteAccount). Always sensitive. The admin log gets the address and the studies that went. - The long lists (
listUsers,listAdminStudies,listAdminLog;AdminListQuerySchema): pages as the lists (limit,after,next), of what matchesq.qfinds the text anywhere, as written (%and_are ordinary characters), whatever its case: users by email address or name, most recent logins first; studies by name, owner's email address, or id (12or#12), newest first; log entries by admin, action or target, newest first. The studies and the log read on fromaftereven when that item was deleted since. - updateAdminStudy:
suspended(the runtime is dropped, coders get 403study_suspended, and so do the study's researchers for every change; they can still read, delete coders' data and delete the study),owner(the email of a registered researcher on this server, whose limits the study then counts against; 400 otherwise). 404 for an unknown study.