feat(36-01): add EN/PL scope picker phrasebook copy, regenerate OpenAPI/TS schema, and update docs
This commit is contained in:
@@ -244,6 +244,9 @@
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"group": {
|
||||
"type": "string"
|
||||
},
|
||||
"known": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -253,15 +256,20 @@
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"plugin_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"read_only": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"description",
|
||||
"group",
|
||||
"known",
|
||||
"label",
|
||||
"name",
|
||||
"plugin_id",
|
||||
"read_only"
|
||||
],
|
||||
"type": "object"
|
||||
|
||||
2
admin/src/api/schema.d.ts
vendored
2
admin/src/api/schema.d.ts
vendored
@@ -6349,9 +6349,11 @@ export interface components {
|
||||
};
|
||||
"cabana.AdminAPITokenScope": {
|
||||
description: string;
|
||||
group: string;
|
||||
known: boolean;
|
||||
label: string;
|
||||
name: string;
|
||||
plugin_id: string;
|
||||
read_only: boolean;
|
||||
};
|
||||
"cabana.AdminAccountRequest": {
|
||||
|
||||
@@ -96,7 +96,7 @@ Each token holds one or more scopes chosen at creation. The framework registers
|
||||
| `*` | every method | Acts as the owner with no further scope limit. |
|
||||
| `admin:read` | GET, HEAD | Acts as the owner on read methods only. |
|
||||
|
||||
Plugins declare more scopes with `pact.HasTokenScopes`. Boot fails on a duplicate name, a reserved name (`*`, `admin`, `admin:…`), an invalid name, empty permissions or methods, an unknown method, a method list without GET, an unknown permission pattern, or a label or description phrase key that does not resolve:
|
||||
Plugins declare more scopes with `pact.HasTokenScopes`. Boot fails on a duplicate name, a reserved name (`*`, `admin`, `admin:…`), an invalid name, empty permissions or methods, an unknown method, a method list without GET, an unknown permission pattern, or a label, description or optional `Group` phrase key (containing `::`) that does not resolve. Each advertised `cabana.AdminAPITokenScope` also carries always-present `plugin_id` and `group` strings: framework scopes (`*`, `admin:read`) and unknown stored scopes emit empty strings, while plugin scopes resolve `group` from `Group`, else `<pluginID>::lang.plugin.name`, else the unanimous non-empty `Tab` of matched permissions, else the raw plugin ID:
|
||||
|
||||
```go src=docs/examples/blog/token_scopes.go#Plugin.TokenScopes
|
||||
// TokenScopes registers personal API token scopes for the blog plugin.
|
||||
|
||||
@@ -118,6 +118,7 @@ What pier does with it at boot:
|
||||
- **Routes.** `Method` and `Path` name one of the plugin's own routes exactly as registered, `{id}` segments included. A route no plugin registers fails boot. The call runs the route's full compiled chain: throttles, the guard, scope and permission middleware, body limits and the handler, the same code path as an HTTP request.
|
||||
- **Guards.** A tool runs as exactly one guard: `user` (the frontend user, when a user plugin publishes that provider) or `backend` (the administrator, built in). When `Guard` is empty the route must carry the guard's token-accepting middleware (for example `user.api_token` or cabana's `backend`); a tool whose route authenticates inside its handler names its guard explicitly, as `create_post` does. A cookie-only or public route cannot become a tool by accident.
|
||||
- **Permissions.** The route's middleware implies requirements the guard provider parses (scopes, permission codes); `Permissions` adds codes that filter the listing on top. The route still enforces on every call; the declaration only decides who sees the tool.
|
||||
- **Token scopes.** Backend write tools (non-`GET`/`HEAD` routes behind the `backend` guard) should be covered by a plugin's `pact.HasTokenScopes` declarations so scoped personal API tokens and administrator MCP OAuth grants can call them without `*`. After compiling the catalog, `pier.Mount` checks each backend write tool via `cabana.TokenScopeCovers` and logs one structured warning per plugin with uncovered tools without failing boot.
|
||||
- **Input.** `Input` is the zero value of a struct. A `path:"id"` field fills the `{id}` segment, a `query:"q"` field goes to the query string, every other field forms the JSON body; a `jsonschema:"..."` tag is the field's description and a field without `omitempty` is required. pier reflects the input schema from the struct, validates every call's arguments against it, and forwards the body as the agent sent it minus the path and query keys, so an update route that checks key presence sees exactly what the agent set. A `GET` or `DELETE` tool may carry only path and query fields, and an embedded struct on one fails boot (its promoted fields would be body fields). A `path:` field must be required: one with `omitempty` or `omitzero` fails boot. At call time pier passes a route only path values the HTTP mux could produce: a missing value, an empty, `.` or `..` segment, or a `/` inside a single-segment value is a tool error before the route runs. Numbers keep their literal digits in path and query values, so integer ids above 2^53 stay exact. `Output`, when set, is the struct the 2xx body matches and becomes the output schema.
|
||||
- **Annotations.** `GET` is read-only and idempotent, `PUT` idempotent, `DELETE` destructive; `ReadOnly`, `Destructive`, `Idempotent` and `OpenWorld` override. The read-only hint also decides what a read-only grant sees (below).
|
||||
- **Results.** A 2xx body is returned as text plus structured content (an object as is, any other JSON wrapped as `{"data": …}`); a 4xx or 5xx is a tool error carrying the route's own body, so the agent reads the real validation errors. A failure of the guard provider itself (for example a database error while resolving the principal) is the fixed tool error `pier: the tool could not be run for this caller`, logged server-side. The dispatched request carries the MCP request's `Host`, `X-Forwarded-Proto` and `X-Forwarded-Host`, so a route that builds absolute links builds them as over HTTP.
|
||||
|
||||
@@ -91,7 +91,7 @@ Guarded routes run surf's `locale.from-principal` after the backend guard: an in
|
||||
| POST and DELETE `/account/avatar` | Upload the signed-in administrator's avatar (one multipart `file_data` part: a jpg, jpeg, png, gif or webp image of at most 2 MiB; anything else is a 422 on `avatar`, a body over the cap a 413) replacing the previous one, or remove it (also 200 when there is none). Both answer the `cabana.AdminProfile`. Interactive session only. |
|
||||
| GET `/account/tokens`, POST `/account/tokens` | List the caller's personal API tokens (newest first; revoked only with `?revoked=1`) and create one (`cabana.AdminAPITokenRequest`: `name`, `expires`, `scopes`). Create answers 201 with `cabana.AdminAPITokenCreated` (plaintext `token` once). Interactive session only. |
|
||||
| DELETE `/account/tokens/{id}` | Soft-revoke one of the caller's own active tokens (`cabana.AdminAPIToken`); 404 otherwise. Interactive session only. |
|
||||
| GET `/account/tokens/scopes` | Scopes the caller may assign (`cabana.AdminAPITokenScope`), including `*`, `admin:read` and overlapping plugin scopes. Interactive session only. |
|
||||
| GET `/account/tokens/scopes` | Scopes the caller may assign (`cabana.AdminAPITokenScope`, including always-present `plugin_id` and `group` strings resolved from `pact.TokenScope` `Group`, else `<pluginID>::lang.plugin.name`, else unanimous matched permission `Tab`, else raw plugin ID; empty for framework and unknown scopes), including `*`, `admin:read` and overlapping plugin scopes. Interactive session only. |
|
||||
| GET `/account/contributions` | The sections plugins contribute to My account (`cabana.AccountContributionView`): translated label, description and status for the signed-in administrator, and the actions (`cabana.AccountContributionActionView`) they hold the permissions for and whose `Applies` reports true. A section whose status or one of whose actions' `Applies` failed carries `error: true`. An empty list when no plugin contributes. Interactive session only. |
|
||||
| GET `/mcp/consent/{request}` | A pending MCP authorization request of an administrator-only grant (`cabana.MCPConsentView`), resolved by the published `pact.MCPAdminConsent` for the signed-in administrator: the client (`cabana.MCPConsentClientView`, with the redirect URI's host), the administrator (`cabana.MCPConsentAdminView`: login, name, email), the requested scopes the administrator can grant in catalog order (`cabana.AdminAPITokenScope`; scopes outside the catalog or without an owned permission are hidden, as in the token picker), `offline_access` (requested), `consent_required` and `expires_at`. 404 `request_not_found` when no provider is published or the request is unknown. Interactive session only. |
|
||||
| POST `/mcp/consent/{request}` | Allow or deny that request (`cabana.MCPConsentDecisionRequest`: `decision` `allow` or `deny`, `scopes`, `offline_access`; at most 16 KiB, unknown fields 400). An allow keeps the submitted scopes that were requested and can be granted (others are dropped), normalises them like token creation (`*` collapses to `["*"]`), answers 422 `no_grantable_scopes` when nothing is left and grants offline access only when it was requested and asked for; the answer is `cabana.MCPConsentDecisionView` (`redirect_uri`). Both decisions load the request first, and a redirect the provider answers that does not go back to the request's redirect URI (same scheme, host and path) is refused with 500. cabana opens no transaction: the provider owns it. Interactive session only, AJAX header required. |
|
||||
@@ -285,10 +285,11 @@ func (p *BlogPlugin) AdminFS() fs.FS { return os.DirFS("testdata/docs") }
|
||||
| `cabana.ScopeLimitFor` | Filters stored scope names by one HTTP method into the `bouncer.ScopeLimit` the guard would set for a request with that method, with the known and method-allowed counts. |
|
||||
| `cabana.TokenScopeNames` | The personal-token scope catalog names in catalog order (`*`, `admin:read`, then the plugins' `TokenScopes`), compiled from the activated plugins, so it works at plugin Boot before `cabana.Activate`. |
|
||||
| `cabana.TokenScopeLabels` | The translated label of each catalog scope name, the name itself for an unknown one, in input order. |
|
||||
| `cabana.TokenScopeCovers` | Reports whether at least one non-`*` personal API token scope allows the given HTTP method and covers every required permission code (uses the activated catalog on the application when available, else compiles from the passed plugins). |
|
||||
| `cabana.MCPConsentView` / `cabana.MCPConsentClientView` / `cabana.MCPConsentAdminView` / `cabana.MCPConsentDecisionRequest` / `cabana.MCPConsentDecisionView` | JSON shapes of the MCP consent routes. `cabana.AdminMCPConsentShow` and `cabana.AdminMCPConsentDecide` carry their swag annotations. |
|
||||
| `cabana.BackendAccessRevokedEvent` | Fired inside the transaction of an admin save that ends an administrator's access (`AdminIDs`, `Reason`, `Tx`); a listener error rolls the save back. Reasons: `cabana.BackendAccessDeleted`, `cabana.BackendAccessDeactivated`, `cabana.BackendAccessPasswordChanged`, `cabana.BackendAccessPasswordSet`, `cabana.BackendAccessPasswordReset`, `cabana.BackendAccessPermissions`. |
|
||||
| `cabana.BackendPrincipal` | Loads an admin principal by id through the backend users provider (grants, superuser flag, backend kind set); nil, nil for a missing or deactivated admin. |
|
||||
| `cabana.AdminAPIToken` / `cabana.AdminAPITokenScope` / `cabana.AdminAPITokenCreated` / `cabana.AdminAPITokenRequest` | JSON shapes of the account token API. |
|
||||
| `cabana.AdminAPIToken` / `cabana.AdminAPITokenScope` / `cabana.AdminAPITokenCreated` / `cabana.AdminAPITokenRequest` | JSON shapes of the account token API. `cabana.AdminAPITokenScope` carries always-present `plugin_id` (`PluginID`) and `group` (`Group`) fields alongside `name`, `label`, `description`, `read_only` and `known`. |
|
||||
| `cabana.AccountItemView` | One row of a contributed section on `cabana.AccountContributionView.Items` (null for a section without `Items`, next to `cabana.AccountContributionView.ItemActions` and `cabana.AccountContributionView.ItemsEmpty`). `cabana.AdminAccountContributionItemAction` carries the item action route's swag annotation. |
|
||||
| `cabana.AccountContributionView` / `cabana.AccountContributionActionView` / `cabana.AccountActionResultView` | JSON shapes of the My account contribution routes: a contributed section with its status and offered actions, one action, and an action's answer (message and optional URL). |
|
||||
| `cabana.CompileList` / `cabana.CompileForm` | Compile a controller's list and form YAML into cached schemas. |
|
||||
|
||||
@@ -110,7 +110,7 @@ func (p *BlogPlugin) Schedule() []pact.ScheduledCommand {
|
||||
| `pact.HasMailPartials` | Ships mail partials, named `<plugin>::mail.partials.<name>` and loaded from `views/mail/partials/<name>.htm`. Independent of `pact.HasMailTemplates`. |
|
||||
| `pact.Permission` | One backend permission entry (code, tab, label, roles). |
|
||||
| `pact.HasPermissions` | Declares backend permissions. |
|
||||
| `pact.TokenScope` | One personal API token scope: name, label, description, permission patterns and HTTP methods. |
|
||||
| `pact.TokenScope` | One personal API token scope: name, label, description, optional `Group` (phrase key containing `::` or literal text, matching `pact.Permission`), permission patterns and HTTP methods. |
|
||||
| `pact.HasTokenScopes` | Declares personal API token scopes compiled at admin boot. |
|
||||
| `pact.FrontendTokenScope` | One member personal API token scope: `Name` (what a route's `user.scope:<name>` middleware checks), `Label`, `Description` and `Implies` (`""`, `read` or `write`; empty means not implied). The route middleware enforces the scope; `Implies` is data for a later OAuth MCP check and is not an expansion by itself. |
|
||||
| `pact.HasFrontendTokenScopes` | Declares member token scopes, the frontend counterpart of `pact.HasTokenScopes`; compiled by the plugin that owns member tokens, never by the admin token catalog. |
|
||||
|
||||
@@ -348,12 +348,63 @@ api_tokens:
|
||||
unknown_scope: ':name (unknown)'
|
||||
unknown_scope_hint: This scope is no longer registered and grants nothing.
|
||||
hint: Token ending in :last4
|
||||
access_level: Access level
|
||||
tier_full: Full (*)
|
||||
tier_read_only: Read-only
|
||||
tier_custom: Custom
|
||||
scope_customize: Customize scopes…
|
||||
scope_more: "+:count more"
|
||||
scope_count:
|
||||
one: ":count scope"
|
||||
other: ":count scopes"
|
||||
scope_write_count:
|
||||
one: ":count write scope"
|
||||
other: ":count write scopes"
|
||||
scope_plugin_count:
|
||||
one: ":count plugin"
|
||||
other: ":count plugins"
|
||||
scope_summary_line: ":scopes across :plugins"
|
||||
scope_summary_admin_read_only: Read-only across the whole admin
|
||||
scope_summary_admin_read_plus: "All read-only + :scopes across :plugins"
|
||||
scope_summary_empty: No scopes selected yet. Choose Customize scopes to pick access.
|
||||
scope_picker_title: Customize scopes
|
||||
scope_picker_description: Choose which scopes this token may use.
|
||||
scope_picker_apply: Apply scopes
|
||||
scope_picker_discard: Discard changes
|
||||
scope_picker_back: Back to token
|
||||
scope_picker_selected: ":scopes selected"
|
||||
scope_picker_selected_admin_read: "All read-only + :scopes"
|
||||
scope_picker_none_selected: Choose at least one scope to apply.
|
||||
scope_search_label: Search scopes
|
||||
scope_search_placeholder: Search plugins, groups, or scopes…
|
||||
scope_search_clear: Clear search
|
||||
scope_filter_label: Filter scopes
|
||||
scope_filter_all: "All (:count)"
|
||||
scope_filter_selected: "Selected (:count)"
|
||||
scope_filter_read_only: "Read-only (:count)"
|
||||
scope_filter_reset: Show all scopes
|
||||
scope_also_admin_read: Also allow reading all other plugins
|
||||
scope_also_admin_read_hint: Locks every read-only scope below. Leave unticked to block reading specific resources.
|
||||
via_admin_read: "via admin:read"
|
||||
group_select_read: Read
|
||||
group_select_all: All
|
||||
group_clear: Clear
|
||||
group_select_read_named: "Select read-only scopes in :group"
|
||||
group_select_all_named: "Select all scopes in :group"
|
||||
group_clear_named: "Clear selected scopes in :group"
|
||||
scope_empty_search_title: No matching scopes
|
||||
scope_empty_search_body: "No plugins, groups, or scopes match “:query”. Clear the search or try another term."
|
||||
scope_empty_selected_title: No scopes selected yet
|
||||
scope_empty_selected_body: Switch to All scopes to pick what this grant may access.
|
||||
scope_empty_readonly_title: No read-only scopes in this list
|
||||
scope_empty_readonly_body: Switch to All scopes to view the available write scopes.
|
||||
mcp_connect:
|
||||
request_not_found: This connection request has expired or does not exist.
|
||||
no_grantable_scopes: Choose at least one scope you can use.
|
||||
page_title: Connect an agent
|
||||
heading: Allow :client to use the admin as you?
|
||||
subline: The agent gets your permissions, limited to the scopes you tick. It never gets more access than your own account.
|
||||
subline: The agent gets your permissions, limited to the access you choose. It never gets more access than your own account.
|
||||
scope_picker_description: Choose which scopes :client may use on your behalf.
|
||||
signed_in_as: Signed in as
|
||||
admin_with_email: ":name (:email)"
|
||||
switch_account: Use another account
|
||||
|
||||
@@ -370,12 +370,69 @@ api_tokens:
|
||||
unknown_scope: ':name (nieznany)'
|
||||
unknown_scope_hint: Ten zakres nie jest już zarejestrowany i nic nie przyznaje.
|
||||
hint: Token kończący się na :last4
|
||||
access_level: Poziom dostępu
|
||||
tier_full: Pełny (*)
|
||||
tier_read_only: Tylko odczyt
|
||||
tier_custom: Własny
|
||||
scope_customize: Dostosuj zakresy…
|
||||
scope_more: "+:count więcej"
|
||||
scope_count:
|
||||
one: ":count zakres"
|
||||
few: ":count zakresy"
|
||||
many: ":count zakresów"
|
||||
other: ":count zakresu"
|
||||
scope_write_count:
|
||||
one: ":count zakres zapisu"
|
||||
few: ":count zakresy zapisu"
|
||||
many: ":count zakresów zapisu"
|
||||
other: ":count zakresu zapisu"
|
||||
scope_plugin_count:
|
||||
one: ":count wtyczce"
|
||||
few: ":count wtyczkach"
|
||||
many: ":count wtyczkach"
|
||||
other: ":count wtyczki"
|
||||
scope_summary_line: ":scopes w :plugins"
|
||||
scope_summary_admin_read_only: Tylko odczyt w całym panelu
|
||||
scope_summary_admin_read_plus: "Cały odczyt + :scopes w :plugins"
|
||||
scope_summary_empty: Nie wybrano jeszcze żadnych zakresów. Kliknij Dostosuj zakresy, aby określić dostęp.
|
||||
scope_picker_title: Dostosuj zakresy
|
||||
scope_picker_description: Wybierz zakresy, których może używać ten token.
|
||||
scope_picker_apply: Zastosuj zakresy
|
||||
scope_picker_discard: Odrzuć zmiany
|
||||
scope_picker_back: Wróć do tokenu
|
||||
scope_picker_selected: "Wybrano: :scopes"
|
||||
scope_picker_selected_admin_read: "Cały odczyt + :scopes"
|
||||
scope_picker_none_selected: Wybierz co najmniej jeden zakres, aby zastosować.
|
||||
scope_search_label: Szukaj zakresów
|
||||
scope_search_placeholder: Szukaj wtyczek, grup lub zakresów…
|
||||
scope_search_clear: Wyczyść wyszukiwanie
|
||||
scope_filter_label: Filtruj zakresy
|
||||
scope_filter_all: "Wszystkie (:count)"
|
||||
scope_filter_selected: "Wybrane (:count)"
|
||||
scope_filter_read_only: "Tylko odczyt (:count)"
|
||||
scope_filter_reset: Pokaż wszystkie zakresy
|
||||
scope_also_admin_read: Zezwól także na odczyt ze wszystkich pozostałych wtyczek
|
||||
scope_also_admin_read_hint: Blokuje jako zaznaczone wszystkie poniższe zakresy tylko do odczytu. Pozostaw odznaczone, aby wykluczyć odczyt wybranych zasobów.
|
||||
via_admin_read: "przez admin:read"
|
||||
group_select_read: Odczyt
|
||||
group_select_all: Wszystkie
|
||||
group_clear: Wyczyść
|
||||
group_select_read_named: "Zaznacz zakresy tylko do odczytu w grupie :group"
|
||||
group_select_all_named: "Zaznacz wszystkie zakresy w grupie :group"
|
||||
group_clear_named: "Wyczyść wybrane zakresy w grupie :group"
|
||||
scope_empty_search_title: Brak pasujących zakresów
|
||||
scope_empty_search_body: "Żadne wtyczki, grupy ani zakresy nie pasują do „:query”. Wyczyść wyszukiwanie lub wpisz inne słowo."
|
||||
scope_empty_selected_title: Nie wybrano jeszcze żadnych zakresów
|
||||
scope_empty_selected_body: Przełącz na Wszystkie zakresy, aby wybrać uprawnienia.
|
||||
scope_empty_readonly_title: Brak zakresów tylko do odczytu na tej liście
|
||||
scope_empty_readonly_body: Przełącz na Wszystkie zakresy, aby zobaczyć dostępne zakresy zapisu.
|
||||
mcp_connect:
|
||||
request_not_found: To żądanie połączenia wygasło albo nie istnieje.
|
||||
no_grantable_scopes: Wybierz co najmniej jeden zakres, którego możesz użyć.
|
||||
page_title: Połącz agenta
|
||||
heading: Pozwolić aplikacji :client korzystać z panelu w Twoim imieniu?
|
||||
subline: Agent otrzyma Twoje uprawnienia w granicach zaznaczonych zakresów. Nigdy nie dostanie szerszego dostępu niż Twoje konto.
|
||||
subline: Agent otrzyma Twoje uprawnienia w granicach wybranego dostępu. Nigdy nie dostanie szerszego dostępu niż Twoje konto.
|
||||
scope_picker_description: Wybierz zakresy, których aplikacja :client może używać w Twoim imieniu.
|
||||
signed_in_as: Zalogowano jako
|
||||
admin_with_email: ":name (:email)"
|
||||
switch_account: Użyj innego konta
|
||||
|
||||
@@ -138,7 +138,7 @@ An MCP client then connects to `https://example.com/mcp` with an OAuth access to
|
||||
|
||||
| Identifier | Description |
|
||||
|------------|-------------|
|
||||
| `pier.Mount` | Reads the `mcp.*` keys and, with `mcp.enabled` true, compiles every plugin's declaration, registers the built-in backend guard provider and mounts POST, GET and DELETE at `mcp.path` through the host's streaming route kind behind `throttle:<mcp.throttle>`; a bad declaration or a route already at the path fails with an error naming the plugin. Called by surf's tagged mount hook. |
|
||||
| `pier.Mount` | Reads the `mcp.*` keys and, with `mcp.enabled` true, compiles every plugin's declaration, checks backend non-`GET`/`HEAD` tools against non-`*` token scopes via `cabana.TokenScopeCovers` (emitting one structured warning per plugin with uncovered write tools without failing boot), registers the built-in backend guard provider and mounts POST, GET and DELETE at `mcp.path` through the host's streaming route kind behind `throttle:<mcp.throttle>`; a bad declaration or a route already at the path fails with an error naming the plugin. Called by surf's tagged mount hook. |
|
||||
| `pier.Host` | What pier needs from the router: `Routes`, `Handler` (the compiled chain of one route, resolved lazily), `MountStream`, `MountJSON` and `Owner`. surf passes an adapter. |
|
||||
| `pier.RouteInfo` | One registered route: method, pattern, plugin id and middleware names. |
|
||||
| `pier.PluginID` | `summercms.pier`, the pseudo-plugin id of pier's routes in the route table. |
|
||||
|
||||
Reference in New Issue
Block a user