Repository navigation
feat(portal): persona editor by surface, resource shares (#2257, #2258) - #2261
Merged
Merged
Conversation
Rebuilds the admin persona editor as one page grouped by surface, adds POST /api/v1/admin/personas/effective-access, makes DELETE /api/v1/admin/personas/{name} answer 409 while API keys or files still reference the persona, and adds resource shares (portal_shares.resource_id, migration 000217) with access requests, channel posting and uploads by external accounts.
Closes #2257
Closes #2258
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2261 +/- ##
==========================================
- Coverage 94.83% 94.77% -0.06%
==========================================
Files 1398 1406 +8
Lines 113176 113978 +802
==========================================
+ Hits 107332 108027 +695
- Misses 5826 5933 +107
Partials 18 18 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Description
Rebuilds Admin > Personas (
ui/src/pages/settings/PersonaEditor.tsx) as one page grouped by surface, addsPOST /api/v1/admin/personas/effective-access, makesDELETE /api/v1/admin/personas/{name}answer 409 while other records name the persona, and fixes the 22 defects #2257 lists. Adds file sharing (#2258):GET/POST /api/v1/resources/{id}/shares,DELETE /api/v1/resources/{id}/shares/{shareID},GET /api/v1/resources/shared-with-me,POST /api/v1/resources/{id}/channel-shares, and access requests for files under/api/v1/portal/resources/{id}/access-request(s). An External persona can now be allowed to upload files, and each upload is shared on arrival with the personas or people the persona names.#2257: persona access defects
The worst of the 22: the admin API admitted an External admin persona that
Registry.AdminRulerefuses, and scratch tables were reachable past both External and the portal levels.persona.ValidateAccountrefuses it on create and update, andloadPersonasrefuses it at startup. Every name-only admin check now goes throughAdminRule: the admin middleware,pkg/middleware/mcp.go(IsAdminnow means authorized and named), the prompt, script and notify layers (throughpc.IsAdmin; theirAdminPersonaconfig fields are removed), MCP resources, the stored-secret lookup (secretstore.WithAdmin),iam.Authorityand the webhook default library.tools_detail.gobuilds personas withdef.ToPersona(), so External is copied.resource.Claims.NoGlobal, set byresourcelevel).portal) beside the effective one (effective_portal,capped_by_external). The editor saves only the stored block, so saving an External persona no longer lowers its settings for good.calls.exclude_personasalso names the persona. Tool descriptions and agent instructions each have one textarea with an Add or Replace mode.personas.role_mappingare shown read-only under Roles. The server also warns about role overlap.scratch_tablesportal area (none,list,register; unset readsregister) is checked on/api/v1/tables*,/api/v1/table-connectionsand the resource and asset table routes. External caps it atnone, and the nav item follows it. The Resources level now gatesPOST /api/v1/resources/{id}/tables.trino_executeis callable is reporteddrop_via_sql: true. The editor shows it as "Can drop any registered table through SQL"./api/v1/resources/{id}/pdfincluded. The deadlast == "pdf"rule inportalpermis removed. Content Download buttons no longer follow this switch.persona-admin:<name>and administrators.?confirm=true, and the confirmation dialog lists them.#2258: file shares and external uploads
portal_shares.resource_id(ON DELETE CASCADE);num_nonnulls(asset_id, collection_id, prompt_id, resource_id) = 1;access_requeststarget check toresource.internal/portal/resourceshare):resource.Claims.Sharedadmits a recipient to read the file.CanEditResource): fields and new versions. Move and delete stay with modify.SharingAllowed.internal/httpserver/resourcesharewire/channel.go): a file posted to a channel gets a link share for signed-in internal people, or reuses existing access. There is no public file link.portal.uploads.share_personas,share_people). An upload lands in the uploader's own folder and is shared, as Viewer, with every recipient the persona names. An external uploader can also share their own upload with someone who shared with them.ui/package.jsonraises dompurify to^3.4.17for GHSA-c6gr-qvv4-5v3f, GHSA-cg2g-xh64-v4q7 and GHSA-mrv2-3pqr-j5jr, which osv-scanner reports against 3.4.16.New UI wording not in either ticket: "People who can already open it", "Upload and share...", "Can edit" / "Can view", "Nothing is shared with you.", "Assets they own", and the access summary row texts.
New import edges in
test/structure/testdata/allowed_internal_imports.txt:internal/admin/personaaccessandinternal/portal/resourceshareare new packages.internal/httpserver/personaaccesswireandinternal/httpserver/resourcesharewireassemble them from the platform's toolkits and stores.accessreqwirereads file shares.pdfhttpreads the caller's persona for PDF export.internal/httpservertoadminwireto keepinternal/httpserverunder its size budget.Type of Change
Related Issues
Closes #2257
Closes #2258
Readers of this state
GET /api/v1/admin/personas/{name}):portalis now the stored block, andeffective_portalandcapped_by_externalare new. Read by the persona editor hooks (usePersonaEditor), which edit and saveportalonly. TheTestIssue2257_ExternalKeepsTheStoredPortalacceptance test covers this.scratch_tablesanduploadsare new.ui/src/lib/portalAccess.tsand the sidebar nav (navItems.ts), which hides Scratch Tables when the area isnone.portalpermandresourcelevel.POST /api/v1/admin/personas/effective-access: new. Read by the editor's access summary and rule rows.DELETE /api/v1/admin/personas/{name}: now 409 with references. Read byPersonasPanel, which lists them and sends?confirm=true.ui/src/api/resources/shares.ts, the share dialog's file target, the file page and the file manager's Shared with me root.resource("shared the file"), links to/resources/{id}.make apidocs-openapi3-checkpasses.Testing
make devwith two replicas:build/2257/acceptance.md).build/2258/acceptance.md).make acceptance-checkpasses.editorSections.test.tsx), not by the acceptance run.internal/admin/personaaccess/refs_realdb_integration_test.go) and the resource share store.LinkShare, and the resources API claims extractor.npm run build, and Playwright interactive specs. Screenshots were regenerated for the persona editor states (summary, portal, external, delete, API routes, create) and the file share and Shared with me views, light and dark.make verify: passes.writing-managed-scripts.md(it coversscriptlayer.go). The page is unchanged because what it says, that administrators act on every script, still holds withpc.IsAdmin.