Repository navigation
fix(teams): read-only key use names the key, and Team settings flags keys whose minter is no longer an admin - #116
Merged
Conversation
A key belongs to its team and keeps working after the admin who minted it is demoted or leaves, so team_read_key_used no longer names that admin. authority_events takes an actor_key_id in place of actor_user_id for it; mint and revoke keep their admin. cast audit prints the key as the actor. Codecast-Session: https://codecast.sh/conversation/jx79zb6wppynmd2h8ryahc3vrh8jswyy
The key list says, for each key, whether the admin who minted it is still an admin of the team. Team settings shows a live key whose minter was demoted or left as "by <name>, no longer an admin", beside Revoke. Codecast-Session: https://codecast.sh/conversation/jx79zb6wppynmd2h8ryahc3vrh8jswyy
The flag reads "no longer a team admin" as its own item, so it wraps instead of being cut off at phone width, and only an explicit false from the server sets it, so a row cached before the field existed is not flagged. The list looks up the minters of live keys only, which the live-key cap bounds. The audit test checks actor_user_id and actor_key_id separately. Codecast-Session: https://codecast.sh/conversation/jx79zb6wppynmd2h8ryahc3vrh8jswyy
Contributor
|
Merged, thanks. This is backend (Convex) code, so it goes live with the next Convex deploy. |
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.
From Tushar's coding agent. Follow-ups to #105: the use event's actor, and the flag in Team settings.
When a read-only key is used,
cast auditnow names the key as the actor, not the admin who minted it. Team settings flags a live key whose minter was demoted or left the team ("no longer a team admin"), next to its Revoke button.The real app against a local Convex backend, at
eded5ec1. Ada is an admin. While the section is open she demotes Christopher Hernandez, and his key's flag appears without a reload. Metrics export is already flagged, because its minter, Mo, left the team:flag-appears-after-demotion.mp4
Desktop, light. Ada's own key has no flag:
More detail from Coding agent
The key as the actor
authority_events.actor_user_idis now optional. A new optionalactor_key_id(an id inteam_read_keys) sits beside it.team_id, and its event is filed underteam:<id>, so every member still reads it.team_read_key_useduses a key actor. Minting and revoking still name the admin who did them.cast auditprintsby key <id>.--jsonoutput hasactor_key_idand noactor_user_id.authorityEvents.listfinds key events through the team workspace, as before.Alternatives considered:
user:<id>orkey:<id>: every existing row would need a backfill.detail: a former admin would still show as acting.The flag
teamReadKeys.listreturnscreated_by_still_adminfor each live key. It isfalsewhen the minter's membership is gone or its role is not admin.null, because the list looks up only the minters of live keys. The live-key cap bounds those reads at ten.false, so a row cached before this change is not flagged.Tests
teamReadKeys.test.ts:actor_user_idandactor_key_idseparately. A use event has noactor_user_id.teams.setMemberRoleandteams.removeFromTeam. It then revokes a key and expectsnullfor it.cast auditline has no unit test, because the command has none. The live run below covers it.Checks
bun testpassed 80 tests and failed 0 across 13 files:teamReadKeys,authorityEvents,authorityEvents.guard,conversations.shareLink,staff,publicShareandteams.*. This was after merging main.cast check convex,cast check cliandcast check webreport 0 errors each.GET /cli/v1/team/sessionswith a 200.cast auditshowedteam_read_key_used by key rn8enb0r.