From f9391a884689564d888e5f819caed76a1440b493 Mon Sep 17 00:00:00 2001 From: Algis Dumbris Date: Mon, 23 Nov 2026 14:06:07 +0200 Subject: [PATCH] docs(spec): consent contract after review of the consent slice (spec 132) previous_logins per client, invalid_replace_grant, client_not_found, and format characters stripped from reported and observed names. Related #1971 --- ROADMAP.md | 2 +- .../contracts/rest-admin.md | 9 +++++---- specs/132-client-oauth-login/tasks.md | 16 ++++++++-------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 1a04f86f7..c89cbfeb4 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1445,4 +1445,4 @@ Legend: `shipped` ≥95% checked · `in-flight` 1–94% · `drafted` 0% · `—` | [129-per-user-upstream-credentials](./specs/129-per-user-upstream-credentials/) | — | — | | [130-skills-review-ux](./specs/130-skills-review-ux/) | `shipped` | 9/9 (100%) | | [131-skills-card-ux](./specs/131-skills-card-ux/) | `shipped` | 7/7 (100%) | -| [132-client-oauth-login](./specs/132-client-oauth-login/) | `drafted` | 0/72 (0%) | +| [132-client-oauth-login](./specs/132-client-oauth-login/) | `in-flight` | 8/72 (11%) | diff --git a/specs/132-client-oauth-login/contracts/rest-admin.md b/specs/132-client-oauth-login/contracts/rest-admin.md index 51c31e6fd..0fb74228a 100644 --- a/specs/132-client-oauth-login/contracts/rest-admin.md +++ b/specs/132-client-oauth-login/contracts/rest-admin.md @@ -29,14 +29,15 @@ Pending requests, newest first: `[{id, client_label, created_at, expires_at}]`. "suggested_client": { "id": "cursor", "matched": "display_name" }, // generic only; present when the reported name equals exactly one entry of existing_clients (matched: id | display_name | known_name); absent otherwise "profiles": [ { "name": "dev-readonly" } ], "profile_required": true, // profiles exist and the client has no binding - "previous_login": { "grant_id": "…", "approved_at": "…" }, // same registration signed in before + "previous_login": { "grant_id": "…", "client_id": "cursor", "approved_at": "…" }, // same registration signed in before: its newest live login + "previous_logins": [ { "grant_id": "…", "client_id": "cursor", "approved_at": "…" } ], // newest live login of this registration under each client (a per-client address lists only that client) "guard": null // only when the address fixes a client that has a binding; else absent, use preview } ``` `404` for an unknown, expired, decided or cancelled id (one uniform answer). -`suggested_client` is advice for the page only. It is computed on read from the sanitised reported name (trimmed, compared without regard to case) against each entry of `existing_clients`: its id, its display name and, for a connect-registry client, its known client names. The whole name is tried and, when it ends with a parenthesised suffix, also the part before it. Matches are collected over all fields and counted by distinct client id; exactly one distinct client → present, none or several → absent. `matched` names the first field that matched in the order `id`, `display_name`, `known_name`. Preview and approve take the client from their own body and never fall back to the suggestion: on the generic address, preview without a client answers `200 {"complete": false}` with no `access` and no `guard`, and approve without a client answers `422 client_required`. +`suggested_client` is advice for the page only. It is computed on read from the sanitised reported name (trimmed, compared without regard to case) against each entry of `existing_clients`: its id, its display name and, for a connect-registry client, its known client names. The whole name is tried and, when it ends with a parenthesised suffix, also the part before it. Matches are collected over all fields and counted by distinct client id; exactly one distinct client → present, none or several → absent. `matched` names the first field that matched in the order `id`, `display_name`, `known_name`. The reported name and a new client's display name are stored without Unicode format characters (category Cf: bidi controls, zero-width characters), and so is the name observed at `initialize`; the page shows every such name in an isolated element. Preview and approve take the client from their own body and never fall back to the suggestion: on the generic address, preview without a client answers `200 {"complete": false}` with no `access` and no `guard`, and approve without a client answers `422 client_required`. ### `POST /oauth/authorizations/{id}/preview` @@ -61,7 +62,7 @@ Records the decision and issues the code. The login itself is stored when the cl "profile": "dev-readonly", // "" = All servers; ignored when the client has a binding "mode": "locked", "binding_revision": "b1f3…", // required when the client has a binding - "replace_grant": "…" // optional: the previous_login grant id + "replace_grant": "…" // optional: the grant id of the previous login under the chosen client (previous_logins) } ``` @@ -69,7 +70,7 @@ Records the decision and issues the code. The login itself is stored when the cl - `409 already_decided`. - `409 binding_changed`: the binding differs from `binding_revision`; reload. - `409 binding_bypassable_without_auth`: body as the existing guard refusal. -- `422 client_required` (generic address, no client in the body), `422 profile_required`, `422 client_fixed` (a client other than the one in the address), `422 identity_exists` / `reserved_identity` for a new client id, `404 profile_not_found`. +- `422 client_required` (generic address, no client in the body), `422 profile_required`, `422 client_fixed` (a client other than the one in the address), `422 identity_exists` / `reserved_identity` for a new client id, `422 invalid_replace_grant` (a live login of this registration that belongs to another client; a grant of another registration is ignored), `404 profile_not_found`, `404 client_not_found` (the chosen client no longer exists; the request itself is still pending). ### `POST /oauth/authorizations/{id}/deny` diff --git a/specs/132-client-oauth-login/tasks.md b/specs/132-client-oauth-login/tasks.md index b2eb6f79e..d016ef599 100644 --- a/specs/132-client-oauth-login/tasks.md +++ b/specs/132-client-oauth-login/tasks.md @@ -92,14 +92,14 @@ Tasks are grouped by the three delivery PRs. Each PR is merged before the next s ### Phase 9: Consent page (US2, US5, US4) -- [ ] T047 [P] [US2] Add API methods and types for authorizations and client credentials in `frontend/src/services/api.ts` and `frontend/src/types/` -- [ ] T048 [US2] Vitest `frontend/tests/unit/authorize-request.spec.ts`: fixed client view, unverified-name label, access sentence, profile shown not asked when bound, Approve disabled until a profile is chosen when `profile_required`, replace-login checkbox only with `previous_login`, guard verdict fetched through the preview call whenever the selection is complete or changes, refusal with fixes shown and Approve disabled until it is clean, `already_decided` and `binding_changed` handling, navigation to `redirect_url` -- [ ] T049 [US2] Implement `frontend/src/views/AuthorizeRequest.vue` and the `/authorize` route in `frontend/src/router/index.ts`, reusing `GuardRefusal.vue`, `ProfileChip.vue` -- [ ] T049a [US5] Tests then code: `suggested_client` on the sign-in request payload (`internal/runtime/oauth_login_consent.go`, `internal/httpapi/oauth_login.go`, `internal/contracts`, `make swagger`): exactly one case-insensitive match on id, display name or known client name → present with `matched`; none or several → absent; one client matching on several fields is one match (`matched` precedence `id`, `display_name`, `known_name`); a name equal to one client's id and another's display name → absent; a trailing parenthesised suffix is also tried without it; never on a per-client address; with a suggestion present, preview without a client answers `200 {complete:false}` with no access and no guard, and approve without a client answers `422 client_required` and writes nothing -- [ ] T050 [US5] Vitest in `frontend/tests/unit/authorize-request.spec.ts` for the generic address: "New client" selected when there is no `suggested_client`, the suggested client selected with the unverified-name notice when there is one, changing the selection sends the changed client, "New client" with editable id and name, existing-client choice shows the access sentence, `identity_exists` / `reserved_identity` errors -- [ ] T051 [US5] Implement the generic-address branch in `frontend/src/views/AuthorizeRequest.vue` -- [ ] T052 [US4] Vitest then code: with no API key in storage `AuthorizeRequest.vue` shows only "Open from the tray or paste the API key", makes no request-detail call, and continues after a pasted key (`frontend/tests/unit/authorize-request-nokey.spec.ts`) -- [ ] T053 [US4] Test then code: `frame-ancestors 'none'` (and `X-Frame-Options: DENY`) on `/ui/authorize` in `internal/server/server.go` (`internal/server/oauth_login_http_test.go`) +- [x] T047 [P] [US2] Add API methods and types for authorizations and client credentials in `frontend/src/services/api.ts` and `frontend/src/types/` +- [x] T048 [US2] Vitest `frontend/tests/unit/authorize-request.spec.ts`: fixed client view, unverified-name label, access sentence, profile shown not asked when bound, Approve disabled until a profile is chosen when `profile_required`, replace-login checkbox only with `previous_login`, guard verdict fetched through the preview call whenever the selection is complete or changes, refusal with fixes shown and Approve disabled until it is clean, `already_decided` and `binding_changed` handling, navigation to `redirect_url` +- [x] T049 [US2] Implement `frontend/src/views/AuthorizeRequest.vue` and the `/authorize` route in `frontend/src/router/index.ts`, reusing `GuardRefusal.vue`, `ProfileChip.vue` +- [x] T049a [US5] Tests then code: `suggested_client` on the sign-in request payload (`internal/runtime/oauth_login_consent.go`, `internal/httpapi/oauth_login.go`, `internal/contracts`, `make swagger`): exactly one case-insensitive match on id, display name or known client name → present with `matched`; none or several → absent; one client matching on several fields is one match (`matched` precedence `id`, `display_name`, `known_name`); a name equal to one client's id and another's display name → absent; a trailing parenthesised suffix is also tried without it; never on a per-client address; with a suggestion present, preview without a client answers `200 {complete:false}` with no access and no guard, and approve without a client answers `422 client_required` and writes nothing +- [x] T050 [US5] Vitest in `frontend/tests/unit/authorize-request.spec.ts` for the generic address: "New client" selected when there is no `suggested_client`, the suggested client selected with the unverified-name notice when there is one, changing the selection sends the changed client, "New client" with editable id and name, existing-client choice shows the access sentence, `identity_exists` / `reserved_identity` errors +- [x] T051 [US5] Implement the generic-address branch in `frontend/src/views/AuthorizeRequest.vue` +- [x] T052 [US4] Vitest then code: with no API key in storage `AuthorizeRequest.vue` shows only "Open from the tray or paste the API key", makes no request-detail call, and continues after a pasted key (`frontend/tests/unit/authorize-request-nokey.spec.ts`) +- [x] T053 [US4] Test then code: `frame-ancestors 'none'` (and `X-Frame-Options: DENY`) on `/ui/authorize` in `internal/server/server.go` (`internal/server/oauth_login_http_test.go`) ### Phase 10: Tray (US4)