Repository navigation
Admins can star any project, and admin rights reach the client live - #8
Merged
Merged
Conversation
The session fetch hook now sets isAdmin from the database next to canManageAgents. The client read it only from the sealed cookie, so an admin granted after sign-in saw no admin menu and no "Add people" in projects they were not in until they signed in again, while the server already allowed it; a demoted admin kept the controls. Starring was refused (403) for an admin who is not a member. It is now open to everyone who can see the project. A star still counts only while the caller is a member or an admin, so a removal or a demotion drops it without touching project_stars.
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.
What
Two ways an instance admin was treated as a regular user in the browser.
Admin rights granted after sign-in did not reach the client.
isAdminis written into the sealed session cookie at sign-in and the client reads only that copy (useUserSession), while the server reads it fresh inrequireActiveSession. An admin made after signing in saw no admin menu and no "Add people" in projects they were not a member of, until they signed in again; a demoted admin kept the controls the server then refused.server/plugins/session-capabilities.tsalready refreshedcanManageAgentson every/api/_auth/sessionfetch for this reason; it now setsisAdminfrom the database too. Every client check (auth.globalfor/admin, admin menu,ProjectMembers,useKanban,useViewData, agents) reads that field. Reported as CF-1322.Admins could not star a project they are not a member of (
PUT /api/projects/:id/staranswered 403, and both star buttons were hidden forrole: 'admin'). Starring is now open to everyone who can see the project. The star is still re-checked on every read, against membership or admin rights, so leaving a project or losing admin drops it without touchingproject_stars.Changed: session hook,
star.put.ts, starred inprojects/index.get.tsandprojects/[id].get.ts, the star buttons on All Projects and the project page, schema comment, OpenAPI, CHANGELOG.Tests
pnpm lint,pnpm typecheck,pnpm test: 133 files, 2021 passed, 8 skipped.auth/session-admin.test.ts:/api/_auth/sessionfollows a promotion and a demotion without a new sign-in.projects/star.test.ts: the 403 test is replaced by "an admin who is not a member can star and unstar", plus "an admin keeps the star after leaving the project" and "a star stops counting once its owner can no longer see the project" (removed and demoted).🤖 Generated with Claude Code