Repository navigation
feat(frontends): close Phase 1+2 backend-frontend capability gaps - #379
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4a35b12996
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
PR 评审:阻碍合入项清单基于当前 head 1. [CI 门禁失败]
|
4a35b12 to
a9ae181
Compare
…F-03) Passkey login (T1.1): a 'Sign in with a passkey' entry on the login page drives POST /oauth2/webauthn/authenticate/begin (session-carried cookies) -> navigator.credentials.get() -> /finish with the WebAuthnAssertionCredential contract shape. Conversions live in the new webauthnService.ts as pure functions (vitest-pinned round-trips); the finish response establishes the browser session, so a plain portal login completes through the SPA's own authorize round-trip (buildOwnAuthorizeUrl + PKCE stash) and an in-flight authorize request resumes through the existing rebuild. Every server failure surfaces as the generic AUTH_INVALID_CREDENTIALS copy (anti-enumeration); browser DOMExceptions (no axios response) get local copy instead of the network-fallback misreport. Passkey delete (T1.2): each registered credential row gains a delete action behind the shared confirm dialog; deleting the last passkey is allowed (P0-7), the anti-enumeration 404 renders the generic not-found copy. Also aligns the register/finish e2e mock with the real #142 contract — the old mock still demanded the retired credential_id/public_key fields and answered every real-shaped POST with 400 (mock drift, plan risk R3). New endpoints consumed: /oauth2/webauthn/authenticate/{begin,finish}, DELETE /api/me/webauthn/credentials/{credentialId}. i18n: en/zh-CN parity. Covers UF-01 (P1) and UF-03 (P1) of the 2026-11-16 frontend gap plan.
Edit modal on the applications page driving PATCH
/api/me/applications/{clientId} with ONLY the dirty fields — absent keys
stay unchanged per contract (minProperties 1); a name-only edit sends
exactly {name} (e2e-asserted). redirect_uris validate like the backend
(https-only, loopback exempt) before anything is sent; allowed_grant_types
render as checkboxes over the server's value domain (authorization_code,
refresh_token, client_credentials CONFIDENTIAL-only, device_code) and
cannot be emptied. scopes/logo_uri are absent from the list response, so
they are send-only-when-typed (blank keeps the stored value) and logo_uri
has an explicit clear checkbox (empty string is the contract's clear
sentinel). A suspended application disables its edit entry with a frozen
tooltip; a raced 403 renders the catalog copy.
Covers UF-04a (P1) of the 2026-11-16 frontend gap plan.
…frontend half) The console used to admit an account only when userinfo listed the literal admin role, so the delegated roles the backend's P1-8 permission model allows (a helpdesk role holding users:read, say) were thrown out at sign-in no matter what the server would have let them do. The gate is now what the account can actually read. The admin role keeps a fast path with no extra requests and no behaviour change. Any other account probes each console domain right after the session is established (landing page and on reload): a GET on the domain's list endpoint decides whether its menu entry renders, and for the users domain a validation-first POST /api/admin/users with an empty object decides whether the write actions are enabled (400 = reached the handler, 403 = scope gate refused; nothing is written or audited on either path). Sections with nothing left disappear; the breadcrumb root and the logo stop pointing at a dashboard the account cannot read; a delegate lands on its first readable domain. An account that can read nothing is refused exactly as before. Write gating covers the users domain only (list page and detail page); other domains hide when unreadable and otherwise leave their write buttons to the backend's 403. Sign-in now requests the nine P1-8 resource scopes alongside admin. /oauth2/login evaluates scopes one by one and drops the ones the client allowlist or the account's permissions do not cover, so this is a no-op where they are not allowed. It matters because a delegated account is only issued the resource scopes it asks for, and the probes can only see what the token carries. Known limit, not addressed here: the shipped fulla-admin-console client allows only openid/profile/admin, so under the shipped config a delegated account still signs in with no admin-class scope and is refused. End-to-end delegated sign-in needs that client's allowlist widened server-side (and, on existing deployments, the scope rows added, since the seeder never touches a client row it already created). That is an operator decision and is left out of this change. Tests: unit tests pin the store's decisions per account shape; a new e2e spec covers the delegated shapes against mocked 403s; the existing non-admin denial spec now models the backend's refusal of the admin surface, which it had never needed while the gate was role-based. The mocked POST /api/admin/users now rejects a body without username/password with 400, as the real handler does.
…BE-01) The handler (TokenManagementService::listTokens) has always read page, per_page, client_id and user_id, and the admin console already sends them to filter and paginate, but the spec recorded none of them. Anyone taking the spec as the source of truth would conclude the parameters are unused. Adds the four optional query parameters in the style the users list already uses, and spells out what the handler actually does: active tokens only (not expired, not revoked), newest first, filters combined with AND, per_page capped at 100 with 50 as the default. No behaviour change and nothing breaking: the parameters were already accepted. apps/server/docs/api/openapi.json is untouched because it is produced from the C++ document registry, which this change does not touch. Regenerates the committed client SDKs, as the drift gate requires after any spec change. Note for Go callers: Client.GetApiAdminTokens gains a *GetApiAdminTokensParams argument before the request editors, so existing calls need a nil or a params value passed through.
…their flows The specs added with UF-01/UF-03 and UF-04a had not been run before they were committed. Run, four of them failed, and each failure was in the spec rather than in the feature: - The applications mock was registered on '**/api/me/applications*'. A single star does not cross '/', so the per-application PATCH never reached the handler and fell through to the network. The glob is now '**' and covers sub-paths. - The WebAuthn stub closed over a parameter of the helper that built it. page.addInitScript re-evaluates the function's source in the page, where that free variable does not exist, so the stub was never installed and the real browser API ran. The stub is now self-contained. - The successful-login spec only asserted that the page was no longer /login, and its userHandle check looked under response instead of at the credential's top level, so neither proved much. It now waits for the portal root and checks that the exchange persisted a refresh token, and asserts userHandle is a base64url string. One product change came out of it: the edit confirmation named the application by its previous name after a rename; it now uses the submitted one.
… gate The admin error catalogs are supposed to mirror every entry of the user catalogs. Nothing checked that. The test named for it, crossAppConsistency.property.test.ts, tries to import the admin entry at runtime, but test files must never import across apps (.claude/rules/frontend-contract.md), and the import does not resolve: it falls back to comparing the user catalog with itself and passes. Verified by mutation: breaking an admin message left all of its cases green, so a code added to the user app and forgotten in the admin app shipped as 'unknown error' there, which is how the three UF-08 codes went missing. scripts/check-ui-sync.mjs now has a second section. It reads the four catalog files and requires every user entry to be in the admin catalog with the identical literal, per locale. Entries are compared as written, line by line, and a line it cannot read fails the gate instead of being skipped, so the check cannot shrink quietly. Admin-only codes are listed but not judged. The same mutation that passed the vitest property fails here with exit 1. The step's place in the workflow is unchanged; only its name and comment are, to say what it now covers. The frontend-i18n doc and the rule file said the property test asserted cross-app equality; they now point at the gate.
…-08) Three codes the backend can answer a portal user had no catalog entry, so they rendered as 'An unexpected error occurred': - AUTH_SOCIAL_ACCOUNT_NOT_LINKED: signing in with a provider identity that has no local account. - WEBAUTHN_INVALID_ATTESTATION and WEBAUTHN_CHALLENGE_MISMATCH: a passkey registration the server refuses. Added to both apps and both locales with identical copy. The social callback pages now also offer the way forward for the not-linked case: a link to the security page, where the account can be linked. With the catalog complete for portal users, the property test's list of backend codes is replaced by the full set (32) and a check is added that each of them resolves to real copy rather than the unknown-code fallback, in both locales. The earlier 18-code list predated most of the codes added since; removing a code from the catalog did not fail anything. The codes deliberately left out are listed with their reason. Verified by mutation: removing one of the new codes fails the new check by name.
With auth.require_email_verification on (the shipped production config), an account whose address is not verified is refused at sign-in with 403 AUTHZ_ACCESS_DENIED. The page showed the catalog's bare 'Access denied' and nothing else, so the user was locked out with no way to help themselves, even though the backend has an anonymous resend-by-email endpoint built for exactly this. A refused sign-in now shows a panel that asks for the address and requests a new link through POST /api/verify-email/resend-by-email. The sign-in field takes a username as well, so the typed value is carried over only when it is an address. The confirmation is the server's own wording and is shown whatever the address: unknown, already-verified and mailed addresses answer identically, and the page keeps that property rather than guessing. A rate-limited request (429) shows the catalog copy. The code alone is the discriminator. /oauth2/login answers that one case with AUTHZ_ACCESS_DENIED and nothing else on the path does (the organization gate answers VALIDATION_INVALID_INPUT or AUTH_MFA_REQUIRED), and the frontend keeps only the code, never the server's message, so there is no text coupling.
An invitation could be created but never seen again: there was no list and
no revoke, so an address typed wrong kept its seat for the whole 72-hour
window and the one-time token, missed once, could only be replaced by
inviting again.
The members panel now shows the organization's pending invitations for
its owner and admin (email, role, expiry) through GET
/api/me/organizations/{slug}/invitations, each with a revoke behind the
shared confirm dialog (DELETE .../invitations/{id}). The list loads with
the panel, and refreshes after an invite or a revoke. A plain member's
panel never asks for it.
The expiry is shown as the server reports it, cut to date and minutes.
expires_at is a server-local timestamp with no time zone, so the page
cannot know when it really lapses and does not pretend to: no countdown,
no expired flag. The list also includes invitations that have already
lapsed, since the server only filters out accepted ones. Both would need
the backend to send an offset or an epoch value.
The one-time token is now labelled as such: it was described only as
something to hand to the invitee.
…ater (UF-04b, UF-04c)
An application was always created under the personal account, with the
server's default grant types, and could never move: the create form sent
neither org_slug nor allowed_grant_types, and nothing called the transfer
endpoint. An application built for a team stayed personal for good.
The create form now has an owner (the account itself, or an organization
where the caller is owner/admin — the only anchors the server accepts) and
grant-type checkboxes that send what they show. authorization_code is the
initial state, matching the server's default. client_credentials needs a
secret a PUBLIC client cannot hold, so it is not offered for that type and
is dropped when the type changes. At least one type stays selected, since
the server rejects an empty list.
Each application can then be transferred through POST
/api/me/applications/{clientId}/transfer. The dialog pre-selects the
current owner and keeps its submit disabled until another one is chosen, so
confirming without choosing cannot move anything. Moving back to personal
sends org_slug: null, with the key present as the contract requires. A
suspended application is frozen for transfer like for every other
management write.
The cards now say who manages each application. The list carries only an
organization id, so the name is looked up in the caller's organizations,
which are loaded once per page; that request is quiet on failure because
the names are decoration, and the actions that need the list report it.
With no managed organization, the transfer dialog says so instead of
offering a single, already-selected option.
…password change (AF-02, AF-03) Three gaps on the user management page: - The role filter and the role hints named exactly admin and user, so a custom role could not be filtered for, and both the create form and the assignment dialog took role names as free text. A typo was only caught by the server, after submit. All three now read GET /api/admin/roles. The dialog checks the roles the user already holds (the list rows carry them) and sends what ends up checked; the create form sends nothing when no role is checked, so the server's default still applies. - A role the user holds that the catalog does not list — a stale catalog, or one a delegated account cannot read — is shown checked and locked and is sent back unchanged. Dropping it silently would have taken it away. Only the admin role may read the catalog under the shipped rules; without it the filter falls back to the two built-in names and the dialogs say the list is unavailable. - The create form had no must_change_password option, so an account created on someone's behalf could not be made to replace its password at first sign-in, although the server has that whole flow. The flag is sent only when checked. The assignment specs are rewritten for checkboxes. The one for a refused role keeps its point with the way it can still happen: a catalog that went stale between loading and saving. The mocked user rows now carry roles, as the real list does. Not covered end to end here: an account created with the flag actually landing on the forced-change screen at sign-in. The API-mocked suites assert the flag on the wire, and the sign-in side is covered by the forced-password-change specs; the link between them needs a running backend.
A member who filed an authorization request for the wrong application could
only wait for a manager to reject it, although the backend has let the
requester withdraw their own pending request since v1.6.
Two places, because that is as far as the frontend can see:
- Right after filing. The request dialog used to close on success. It now
stays on a filed state with the server's message, a Withdraw button and
Done, and calls DELETE
/api/me/organizations/{slug}/consent-requests/{id}.
- In the approval queue, for a manager: a row the signed-in user filed
themselves gets a Withdraw button next to approve and reject.
What this does not solve: a plain member who closes the dialog has no way
to find the request again. Listing requests is for managers only, so the
filing response is the one time a member is told the id. That needs a list
of the member's own requests on the backend; nothing client-side can
recover it after a reload.
Rows are recognised as the user's by requester_username against the
profile, the only identifier the two share (usernames are unique). The
server still decides: anyone else's id answers the same 404 as an unknown
one.
The export button always sent a time window — the filled-in one, or the last 24 hours when the inputs were empty. An audit of everything meant widening the window by hand. The server has accepted all=true for a full export since P1-6. A 'Whole log' checkbox sends all=true instead of from/to. The other filters still ride along, and the row cap still applies: the hint says so, and an over-cap export is refused with the catalog's message as before. The file is named audit-export-all.csv so it cannot be mistaken for a windowed one.
An unused catch binding in the permissions store, and a variable captured but never asserted in a users spec.
…ation The gate failed on this branch: user.main 171.7KB against a 170.7KB cap and admin.total 503.6KB against 501.6KB. Measured against master built in the same place (user 428.3/162.5KB, admin 495.5/168.1KB — the same numbers CI reports for master), this branch adds user +30.3KB total and +9.2KB main, admin +8.1KB total and +3.4KB main. The per-chunk comparison accounts for all of it in feature code and message text: the application page (+11.5KB: edit, owner, transfer, create form), the entry chunks (+9.4KB user: bilingual strings for every feature), the login page (+4.0KB), the organizations page (+2.4KB). No dependency was added and no chunk changed shape. Nothing in it is waste to trim, so the baseline moves, with the numbers written into the script as the previous re-baselines did. All four bases go to the measured sizes so the next change starts from the current one rather than from a headroom this work has already spent.
…or in claim-mappings OrganizationsPage loads /api/me inside toggleConsents rather than on mount, so awaiting /api/me before clicking Org authorizations timed out. Also scope the created-row check in claim-mappings.spec.ts to <tr> so it does not collide with the success toast under Playwright strict mode.
Cross-app error catalog mirroring is enforced by scripts/check-ui-sync.mjs; remove the unreachable dynamic import and self-comparison fallback while keeping determinism, non-empty, and catalog completeness assertions.
…es/logs Update the leftover !OAuth2Admin/src/pages/logs/ exception to !frontends/admin/src/pages/logs/ so new source files under that page directory are not silently ignored by **/logs/.
a9ae181 to
5dcca87
Compare
…ign-in (#386) The AF-01 frontend half (Phase 1+2, #379) requests the nine V045 resource scopes at console sign-in, but the shipped fulla-admin-console client only allowed openid/profile/admin: /oauth2/login dropped every resource scope at the client-allowlist tier, leaving delegated accounts with no admin-class scope and refusing the sign-in end to end. - Widen allowed_scopes to the twelve login scopes in all five server configs and mirror the list in dev_admin_console_client.sql. Existing Postgres deployments backfill the new oauth2_client_scopes rows idempotently at server restart via ClientSeeder (verified locally: a 3-row pre-change DB converged to 12 rows on boot; afterClientRow runs on ON CONFLICT DO NOTHING). - config.dev.json: add the /api/admin/users.* permissions rbac_rules entry, aligning dev with config.json so delegated tokens pass AuthorizationFilter out of the box. ci/prod/bench stay operator opt-in (ci is memory-storage, where delegated accounts cannot exist). - auth.ts: refresh the CONSOLE_LOGIN_SCOPE comment; the shipped allowlist now covers all twelve names, entitlements alone decide the issued set. - AdminRbacEnforcementHttpTest: exercise the red line through the SHIPPED client - a users:read-only helpdesk account gets exactly openid/profile/users:read (read users OK, everything else 403); an unprivileged account obtains no admin-class scope; the admin role's own sign-in carries all twelve scopes and still passes the family gate. Fixes #375
Summary
Closes the Phase 1 + Phase 2 backend-to-frontend capability gaps across
frontends/userandfrontends/admin, alignsapps/server/openapi.yaml(and regenerated Python/Go/TS SDKs) forGET /api/admin/tokens, and enforces user→admin error catalog mirroring in CI.Highlights
frontends/user)198a7abc,13de5a1d): Passkey sign-in flow (POST /oauth2/webauthn/authenticate/{begin,finish}, wired into existingauthorizeResume) and per-credential deletion (DELETE /api/me/webauthn/credentials/{credentialId}).fb626add,13de5a1d): Self-registered application editing via partialPATCH /api/me/applications/{clientId}(sends dirty fields only; surfaces suspended-app guard).bed4880f): Organization owner selector &allowed_grant_typesselection at application creation; personal ↔ organization transfer (POST .../transfer).2142d7d5): Pending organization invitations list (GET .../invitations) and row-level revocation (DELETE .../invitations/{invitationId}) for owners/admins.94f2d06c): Self-service resend-verification panel (POST /api/verify-email/resend-by-email) when password sign-in is blocked by unverified email (403 AUTHZ_ACCESS_DENIED).440fc0c1,a54989c3): Organization consent-request withdrawal (DELETE .../consent-requests/{id}) right after filing and from the manager approval queue for one's own request.d5b1eb26,56514f87): Localized copy forAUTH_SOCIAL_ACCOUNT_NOT_LINKED(with link-account guidance),WEBAUTHN_INVALID_ATTESTATION, andWEBAUTHN_CHALLENGE_MISMATCH.frontends/admin)ad16075e,5f92e53a): Permission-aware console for delegated accounts — requests resource scopes at login, probes readable domains to converge navigation and landing route, and gatesuserswrite actions onusers:write. Server-sidefulla-admin-consoleallowed_scopeswidening is tracked separately in config(authz): widen fulla-admin-console allowed_scopes for delegated admin sign-in (AF-01) #375.aafdae3b): Role catalog drives the users role filter, create-user role checkboxes, and role assignment checkboxes (preserving out-of-catalog roles read-only); addsmust_change_passwordoption to user creation.e9d453d2): Full audit log CSV export opt-in (all=true).362a38c2): Documentspage,per_page,client_id, anduser_idquery parameters onGET /api/admin/tokensinapps/server/openapi.yamland regenerates the Python/Go/TypeScript SDKs.d5b1eb26,ba1ce747): Extendsscripts/check-ui-sync.mjsto enforce verbatim user→admin error catalog mirroring (replacing the non-functional cross-app dynamic import fallback incrossAppConsistency.property.test.ts).0c672355): Re-baselines the four frontend size limits to measured values after verifying every chunk delta is feature code/copy..gitignorefixes (a54989c3,4a35b129): Fixes/api/mewait order inopen-platform.spec.ts, strict-mode row locator inclaim-mappings.spec.ts, and updates the stale!OAuth2Admin/src/pages/logs/.gitignoreexception to!frontends/admin/src/pages/logs/.Notes for reviewers & consumers
GET /api/admin/tokensOpenAPI parameters adds aparams *GetApiAdminTokensParamsargument toClient.GetApiAdminTokensinclients/go. No in-repo callers exist; external Go SDK consumers callingGetApiAdminTokenswill need to passnilor a&GetApiAdminTokensParams{...}struct.fulla-admin-console.allowed_scopesin server configs (and deciding per-environmentrbac_rules); tracked in config(authz): widen fulla-admin-console allowed_scopes for delegated admin sign-in (AF-01) #375.must_change_passwordcreation (AF-03) asserts the request payload while the sign-in side is covered by the existingforced-password-changespec; UF-07 covers immediate post-filing and manager-queue withdrawal (plain members cannot recover a request ID after reload without a backend "my requests" endpoint); T2.1 rendersexpires_atverbatim viashortDateTime()(server-local timestamp without timezone).Local verification
frontends/user:npm run test:unit(14 files / 67 passed),npm run test:e2e(190 passed / 2 skipped),npm run lint(0 errors),npm run build(OK)frontends/admin:npm run test:unit(3 files / 19 passed),npm run test:e2e(231 passed / 6 skipped),npm run lint(0 errors),npm run build(OK)node scripts/check-ui-sync.mjs(13 UI components + 106 error catalog entries in sync),node scripts/check-frontend-size.mjs(OK)Type of change
Client.GetApiAdminTokenssignature addsparams(regenerated from documented OpenAPI query params)Checklist
General:
CHANGELOG.mdentry added (user-visible changes)website/i18n/zh-CNmirrors whendocs/content changed) —docs/contribute/frontend-i18n.mdand.claude/rules/frontend-contract.mdupdated; zh-CN mirror sync can follow if requiredIf this touches the API surface (skip otherwise):
apps/server/openapi.yamland its mirror points) —GET /api/admin/tokensquery params documented; Swagger UI C++ registration unchangedcheck-ui-sync.mjsapi-diffandoasdiffgates addressed (additive optional query parameters only)Breaking changessection ofCHANGELOG.md