Repository navigation
feat(auth): account settings administrators can change on the owner's behalf - #170
Merged
Merged
Conversation
…s behalf
Administrators could disable accounts and end sessions, but not change a
user's settings: removing a stolen passkey or unlinking an identity took
SQL against production.
The settings an administrator may share with the owner now live in one
router, mounted at /account for the owner and at
/users/{user_id}/account on the admin listener. Handlers take a Subject,
the account and who acts, instead of a session, and run AccountService
operations that the `account` CLI command runs too. Administrators may
view, edit and remove, but never add a way to sign in or receive mail.
Every change on the admin mount needs a reason, stored with its events
as personal data and shown in the owner's history.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 5 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ccount The test revoked the actor's rights and granted the target's before the change started, so it still passed without the check under the account lock. Both now commit while the change waits for that lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… mount
The admin JSON API will be deleted once the dashboard moves into auth and
calls the services in-process, so it should not grow. The shared settings
stay as AccountService operations on a Subject, run by the owner's routes
and the `account` command, without the /users/{user_id}/account mount, its
reason header or the challenge it needed on ApiError.
The actors are sealed: only the extractor builds an owner's Subject, from
the session cookie, and only the admin API's authenticator builds an
Operator::Admin, whose AdminSession fields are private to the admin
module. The admin-side scenarios now call AccountService directly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A reading Subject carried no reason but was accepted by changes too, so an in-process caller could commit an administrator's change without one. Reads now take a Viewer, which needs no reason, and a Subject is built for an operator only with one, so such a change no longer compiles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also says in the docs that reads take a Viewer and changes a Subject. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Administrators could disable accounts and end sessions, but not change a user's settings. Removing a stolen passkey, unlinking an identity or removing an address took SQL against production. Part of #110. Its dashboard half comes with the in-process dashboard (PR 5 of the UI consolidation plan), so #110 stays open.
This is PR 1 of that plan. It is the service layer only: the dashboard will call it in-process, so it adds no admin API surface.
How
Operations on a
Subject.AccountServiceoperations (src/account), written next to their setting (passkey,federation,emails,sessions,history).Subject: the account, and who acts on it. That is the owner with their session, or anOperatorwith the reason it must give.Viewer, which needs no reason. An operator therefore cannot make a change without a reason: it doesn't compile./accountroutes run them, through one router built fromAccountOperation.auth-service account <user> …runs them as the operator at the terminal.What is shared. Administrators may view, edit and remove, but never add a way to sign in or receive the account's mail.
AdminService's)Sealed actors. These make "administrators never add a credential" enforceable once the dashboard calls the service in-process:
Subject's andViewer's fields are private. Only their extractors build an owner's, from the session cookie. Operators get theirs fromSubject::operator,ConfirmedSubject::operatorandViewer::operator.Operator::Adminholds anAdminSession. Its fields are private to the admin module, so only the admin API's token authenticator creates one.When an administrator or operator acts:
event_personal_data.reason(migration0015), so retention and purges delete it.Actor::AdminorActor::Cli. Reads are recorded asAccountViewed, likeuser show.Operator::lock, moved out ofAdminService, refuses it before waiting for the account lock and again under it.Subject::commitrechecks the administrator's rights, session and passkey confirmation before committing, asAdminService::finishdoes. The CLI may change administrators' accounts.RevocationReason::Admin.CLI.
account <user> passkeys|identities|emails|sessions|history …. Every change needs--reason.AccountOperationis declared with the same macro asAdminOperation. The owner's router and the CLI match it exhaustively, and the coverage test parses a command line for every operation of both lists.Tests
AccountService(account::tests, database):Actor::Adminand the reason, and the owner's history shows both.current: false, and is recorded asAccountViewedby them.account … sessions revoke-allrecords the operator with the reason.just db test(166),just test,just lint,just doc,just web check, prettier.Not in this PR
AccountServicereads, likeAdminService's, rely on the caller having authenticated them. Next PR: everyAdminServicemethod takes&Operatorand authorizes it, reads included.AccountServicereads will follow the same rule.published: true(feat(web): public profiles at sourceorigin.dev/@handle #101): neither exists yet.Note
Written by Claude Opus 5.5 in Claude Code and reviewed by GPT 6.1 Sol (via T3 Code)
🤖 Generated with Claude Code