[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M735MJ8ZMRZR20A57TMF7R9Q":3,"skill-same:01M735MJ8ZMRZR20A57TMF7R9Q":135},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":29,"commitSha":30,"skillDirectory":31,"forksCount":14,"repositoryHtmlUrl":32,"repositoryHomepageUrl":6,"ownerHtmlUrl":33,"ownerBlogUrl":34,"ownerDescription":35,"updatedAt":36,"install":37,"resources":50},"01M735MJ8ZMRZR20A57TMF7R9Q","thunder-authentication",null,"Apply when a component sits on the project's sign-in — a SPA whose users authenticate through the auth platform-resource dependency, or a protected backend those signed-in users call.","wso2\u002Flabs-agentic-engineer","wso2","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F533043?v=4","01M6CDAFS40T9Y86DYXWE0NJES","WSO2","01M735EE4N2PP2ZR56AX7DNPNP",24,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: thunder-authentication\ndescription: \"Apply when a component sits on the project's sign-in — a SPA whose users authenticate through the auth platform-resource dependency, or a protected backend those signed-in users call.\"\nmetadata:\n  aep:\n    kind: org\n    audience: [coding]\n---\n\n# Thunder Authentication\n\nEnd-user identity is delegated to Thunder, the platform's Identity Provider,\nwhich the API gateway is wired to as its external IDP. **What a caller may do is\nthe access token's `scope` — one authority, nothing else.**\n\n- **The protected backend** never sees a token: the gateway validates it,\n  enforces the scope each operation declares in `openapi.yaml`, and hands the\n  service a **gateway-signed assertion** carrying the same `sub` and `scope`.\n  See `api-management` for the gateway's side of that contract.\n- **The SPA** signs the user in with OIDC Authorization Code + PKCE, asking for\n  a **resource indicator** so the token is minted for this project, reads the\n  granted permissions from `user.scope`, and gates every screen on the scope of\n  the **operation that screen loads**.\n\n**Nothing reads the groups claim to decide anything** — not the SPA, not the\nservice, not for display. Permissions reach code as scopes. The invariants\nbehind every rule here are stated once in `authorization-model`; this skill is\nthe mechanics.\n\nThe OAuth client itself is **platform-owned**: you never create, compute, or\nhardcode any part of it.\n\n## Where permissions come from\n\n`specs\u002Fdesign\u002Fsecurity.json` is the project's permission catalog. Read it before\nwriting any authorization code:\n\n| Field | What you do with it |\n|---|---|\n| `permissions[].resource` + `actions[].handle` | joined by `:` these are the **scope handles** — `claims:read`, `reports:export`. This is the closed set. |\n| `roles[].grants` | which handles a role holds. Drives the SPA's header badge and the \"which role unlocks this\" wording; `src\u002Fauthz\u002Froles.gen.ts` is generated from it. |\n| `roles[].assignTo`, `groups[]` | provisioning only. **No application code reads these.** |\n\nTwo things are **not** in this file, on purpose. Which **rows** an operation\nreaches is the operation's path in `openapi.yaml`: under `\u002Fme\u002F` the caller's\n(or a relation's — `\u002Fme\u002Fteam\u002Fclaims`), anywhere else every row.\n`openapi-conventions` owns that rule; here it means a `\u002Fme\u002F…` handler resolves\nrows through the assertion's `sub`, and nothing else ever filters. And which\n**screens** a caller may open is the scope of the operation each screen\n**loads** — the one handle that operation already names in `openapi.yaml`. No\nscreen table exists anywhere; the generator projects every contract into\n`src\u002Fauthz\u002Foperations.gen.ts` and you bind each screen to its load operation\nonce, in `src\u002Fauthz\u002Fscreens.ts` (§5).\n\nThe platform creates the resource server, the roles and the test users when the\nuser clicks Build. Never write user-, group- or role-provisioning code, and\nnever seed a roster: an account you create is not one the platform can hand to\nthe validation agent. No code names a test user or gives one rows or a\nrelation.\n\n**Dev clusters** ship a default Thunder admin: `admin` \u002F `admin`, in the\n`Administrators` group. That group administers the PLATFORM — it is not one of\nyour app's roles, and the platform will not grant it your app's scopes.\n\n---\n\n# SPA sign-in and screen gating\n\n## Order of work\n\n`src\u002Fenv.ts` (add the four `\u003CDEP>_*` keys the SPA reads to the `react-webapp` shim) →\ncopy the `assets\u002Fapp\u002F` tree (below) → `scripts\u002Fgen-authz.mjs` wired into the\nbuild and run once, so the three generated files exist → the `USER_AUTH_`\nprefix in `src\u002Fauthz\u002Fsession.ts` → **`src\u002Fapi.ts` stripped of every\nauthorization rule of its own** (§4) → a **`\u002Fcallback` route** that calls\n`handleCallback()` once on mount → `src\u002Fauthz\u002Fscreens.ts` and the route guards\nin `src\u002FApp.tsx`. Verify with the `react-webapp` build check.\n\n## What you copy\n\nThe assets are laid out as the app is, so the install is **one command** and\nnothing is renamed on the way in. **Copy them; do not write your own.** The\nrules they carry were measured against this IdP and this gateway, and every one\nof them has already been got wrong by a real run.\n\n```bash\ncp -r \"$AEP_SKILLS_DIR\u002Fthunder-authentication\u002Fassets\u002Fapp\u002F.\" .\n```\n\nThat puts eight files in place, all verbatim:\n\n| Path in the app | What it is |\n|---|---|\n| `scripts\u002Fgen-authz.mjs` | the generator — run by `npm run gen`, emits the three `*.gen.ts` files |\n| `src\u002Fauthz\u002Fsession.ts` | sign-in, the session, `tokenIsValid()` — the ONE edit: the `USER_AUTH_` prefix becomes YOUR dependency's |\n| `src\u002Fauthz\u002Fcore.ts` | the pure rules, no imports — testable in plain node |\n| `src\u002Fauthz\u002Fgates.tsx` | `AuthzProvider`, `Can`, `RequireOperation`, `Forbidden`, `NoAccess` — restyle the markup with the pinned design system, keep the words and every export name |\n| `src\u002Fauthz\u002Fclient.ts` | the 401 rule and the `openapi-fetch` middleware |\n| `mock\u002Fauthz\u002Fsession.ts` | mock mode's substitute for `src\u002Fauthz\u002Fsession.ts` (`?role=`, `?auth=out`) |\n| `mock\u002Fauthz\u002Fgateway.ts`, `mock\u002Fauthz\u002Fcontract.ts` | mock mode's API gateway: the contract projected into a table, and the 401s |\n\nTwo more ship as **patterns** beside `app\u002F`, and are adapted rather than copied:\n\n| Asset | Becomes | How |\n|---|---|---|\n| `assets\u002Fscreens.example.ts` | `src\u002Fauthz\u002Fscreens.ts` | replace `SCREEN_ROUTES` with YOUR screens — key, label, path and the operation each **loads** — in rail order; keep the rest |\n| `assets\u002FApp.example.tsx` | `src\u002FApp.tsx` | replace `PAGE_BY_KEY` *and* `APP_NAME` with yours; the ROUTING STRUCTURE is prescribed |\n\nOne file is not copied and is not optional: **`src\u002Fapi.ts`, the per-service\nclient you already have.** Whatever it carried about authorization comes OUT —\nthe bearer it attached, any `WWW-Authenticate` read, and above all\n`if (res.status === 401) signIn()` — and it calls `src\u002Fauthz\u002Fclient.ts`'s\n`authorizationHeader()` and `classifyResponse()` instead (§4 has the\n`openapi-fetch` middleware to paste). Two modules that both decide what a 401\nmeans is the same bug as one module deciding it wrong, and on an app that\nalready exists this is the only edit the copy cannot make for you.\n\nThe two example files are written against the Expense Tracker — its\n`SCREEN_ROUTES`, `PAGE_BY_KEY` and `APP_NAME` all name ITS screens and ITS\noperations. They are a shape to follow, not a fixture to ship. If your app\nalready holds its name somewhere (the prototype manifest's `name`, usually\n`src\u002FappName.ts`), import it rather than declaring a second copy.\n\nIf `$AEP_SKILLS_DIR` is unset, copy from `assets\u002F` next to this skill's\n`SKILL.md`. The two `*.example.*` files and everything under `assets\u002F__tests__\u002F`\nare **not** copied into the app: the examples are patterns you adapt, and the\ntests are this skill's own regression suite. `react-webapp`'s mock harness\n(`mock\u002Fplugin.ts`, `mock\u002Fbrowser.ts`) is copied separately and imports the\n`mock\u002Fauthz\u002F` files above by those paths.\n\n## Constraints\n\n**Keys are derived from YOUR dependency name.** The platform emits every\nplatform-resource dependency's outputs into `window._env_` as\n`\u003CUPPER_SNAKE(depName)>_\u003CUPPER_SNAKE(outputName)>`. There is **no fixed prefix** —\nit is the UPPER_SNAKE of the dependency `name` the architect chose. The auth\nresource type outputs `client_id`, `issuer`, `jwks_url`, `scopes` and\n`resource`, so a dependency named `user-auth` yields:\n\n| Key (dep `user-auth`) | Generic form | Meaning |\n|---|---|---|\n| `USER_AUTH_CLIENT_ID` | `\u003CDEP>_CLIENT_ID` | this app's platform-owned OAuth client id |\n| `USER_AUTH_ISSUER` | `\u003CDEP>_ISSUER` | OIDC issuer \u002F authority for `oidc-client-ts` |\n| `USER_AUTH_JWKS_URL` | `\u003CDEP>_JWKS_URL` | JWKS endpoint. Emitted, and **not** in the SPA's `Env`: the browser never validates a token — the API gateway does — so no asset reads it. Leave it out of `src\u002Fenv.ts` and out of `mock\u002Fenv.ts` |\n| `USER_AUTH_SCOPES` | `\u003CDEP>_SCOPES` | space-separated scopes to request: the OIDC ones (`openid profile email group ou`) plus the project's catalog handles |\n| `USER_AUTH_RESOURCE` | `\u003CDEP>_RESOURCE` | the project's **resource-server identifier** — the RFC 8707 `resource` indicator, and the `aud` the gateway pins |\n\nHardcoding a fixed prefix — or any prefix other than YOUR dependency's name —\ngives `undefined` at module load and a redirect to `undefined\u002Foauth2\u002Fauthorize`.\n\nThe access token lives `86400` seconds by default: the `validityPeriod`\nparameter of the auth resource type, which no `workload.yaml` sets. Do not\nassume a shorter lifetime. A short value is only for a fixture app that tests\nthe silent renew.\n\n**Ask for the resource indicator on all three legs, or every API call 401s.**\nThe indicator is what makes the IdP mint an access token whose `aud` is this\nproject's resource server and whose `scope` is narrowed to what this user's\nroles grant there. Without it the token carries the IdP's default audience and\nthe gateway rejects it **before it reads a scope** — while sign-in itself looks\nperfectly healthy.\n\n`oidc-client-ts` 3.5.0 carries `resource` on exactly ONE of the three legs by\nitself. Measured against the library, not assumed:\n\n| Leg | Does `settings.resource` reach it? | What you set |\n|---|---|---|\n| `\u002Fauthorize` redirect | **yes** — appended to the authorize URL | `resource: env.\u003CDEP>_RESOURCE` in the `UserManager` settings |\n| code → token exchange | **no** — `_processCode` sends only its own fields plus `...extraTokenParams` | `extraTokenParams: { resource: env.\u003CDEP>_RESOURCE }` |\n| refresh \u002F silent renew | **no** — `signinSilent(args)` forwards `args` and never falls back to `this.settings` | pass `{ resource, extraTokenParams }` to **every** `signinSilent()` call |\n\n`src\u002Fauthz\u002Fsession.ts` sets all three. A run that copied a settings-only\nsnippet got a green build, a healthy-looking sign-in, and a wrong `aud` on every\ntoken.\n\nOn **this** IdP leg 3 is survivable: Thunder binds the refresh token to the\nresource server it was issued for, so an argument-less renew keeps the same\n`aud` (and asking for a *different* resource is refused with `invalid_target`).\nSet all three anyway — it is what makes the app portable to an IdP that\nre-derives the audience per request, where the omission silently downgrades\nevery renewed token one access-token lifetime after sign-in.\n\n**Two settings that do not exist in 3.5.0.** Both are type errors, and both look\nplausible enough that they get written:\n\n- **`useRefreshToken`** is a method on `OidcClient`, not a member of\n  `UserManagerSettings`. `automaticSilentRenew: true` plus a refresh token in\n  the response is what makes renewal use the refresh grant.\n- **`clockSkewInSeconds`** is not a member either. The settings that do exist\n  are `accessTokenExpiringNotificationTimeInSeconds` (default 60 — the lead time\n  the silent renew fires at) and `staleStateAgeInSeconds`. So the grace period\n  `tokenIsValid()` allows past `expires_at` is **ours**: `src\u002Fauthz\u002Fsession.ts`\n  holds a private `CLOCK_SKEW_SECONDS = 60`, the same width as that renew window.\n\n**`client_id` is platform-owned.** It is a platform-derived opaque identifier,\n**not** the dependency's `name`; the platform delivers it in\n`window._env_.\u003CDEP>_CLIENT_ID`. Same for the client secret and the registered\nredirect URIs. Never add Thunder client-provisioning code anywhere — the\nplatform's Thunder Application operator does it when the dependency provisions —\nand never write a `\u002Flogin` form that POSTs credentials to your own API.\n\n**Compute the redirect URI; there is no key for it.** The platform registers the\nSPA's served callback URL once its public URL resolves, and the SPA is served at\nits host root (see `react-webapp`), so that URL is `\u003Corigin>\u002Fcallback`.\nReconstruct exactly that in the browser: `window.location.origin + '\u002Fcallback'`,\nand serve the route at `\u002Fcallback`. Post-sign-in landing is\n`window.location.origin`. Neither is an env key.\n\n**That ONE registered URI serves BOTH legs, so the route must dispatch.**\n`silent_redirect_uri` defaults to `redirect_uri` in oidc-client-ts 3.5.0, so a\nsilent renew's hidden iframe lands on `\u002Fcallback` too — and a second, dedicated\nURI is not an option, because the platform registers only this one and the IdP\nanswers `invalid_request: Invalid redirect URI` for anything else. So the route\ncalls **`signinCallback()`**, which reads `request_type` off the stored state\nand dispatches (`si:r` → redirect, `si:s` → silent). `signinRedirectCallback()`\nfinishes only the redirect leg: on the silent leg it never calls the iframe\nnavigator's `callback()`, so the parent window is never notified and waits out\nthe full 10s `silentRequestTimeoutInSeconds` before the renew rejects. MEASURED\non a deployed app: **11.1s** from first paint to the sign-in page, on every\nsigned-out visit, 10.0s of it that timeout. `react-oidc-context`, which the\nplatform's own console is built on, calls the same dispatching function.\n\n**Token endpoint is cross-origin.** The browser posts straight to\n`\u003CDEP>_ISSUER\u002Foauth2\u002Ftoken`; discovery is\n`\u003CDEP>_ISSUER\u002F.well-known\u002Fopenid-configuration`. Nothing is proxied same-origin,\nwhich is why `react-webapp` does not proxy `\u002Foidc\u002F` — nginx only reverse-proxies\nsibling APIs under `\u002Fapi`.\n\n**Persist the session and renew silently.** The OAuth client is provisioned with\nthe `refresh_token` grant alongside `authorization_code` + PKCE, so an expiring\naccess token is renewed by posting the refresh token — no hidden iframe, no\nthird-party-cookie dependency. The session lives in `localStorage` (a\n`WebStorageStateStore`) with `automaticSilentRenew: true`. `sessionStorage` is\nper-tab and wiped on close, which forces a re-login on every visit; and without\npersistent web storage the PKCE verifier does not survive the redirect at all.\n\n**Renew what EXISTS; sign in when nothing does.** `signinSilent()` is for a\nstored session that has expired — it posts the refresh token and nobody sees it.\nWith no stored session there is nothing to refresh, so the library falls back to\na hidden iframe whose only possible answer is `login_required`, and the app\nwaits behind its splash for it: measured at 0.8s of actual round trip inside a\n10s wait, plus a second full boot of the SPA inside that iframe. That fork is\n`sessionAction` in `assets\u002Fapp\u002Fsrc\u002Fauthz\u002Fcore.ts` — `use` \u002F `renew` \u002F `none` —\nkept out of `session.ts` so it can be tested; `none` goes straight to `signIn()`.\n\nWhat it costs: a visitor holding an IdP session from a sibling app is signed in\nby a visible redirect rather than a hidden iframe. Same destination, one visible\nhop — and the iframe leg is cross-site (the app and the IdP are separate hosts),\nso a browser blocking third-party cookies answers `login_required` anyway.\n\n**A refresh narrows, never widens.** Permission scopes are re-evaluated on\nrenewal, so a grant REMOVED from a role disappears at the next silent renew —\nbut a grant ADDED never appears on a refresh at all (RFC 6749 §6: a refresh may\nnot exceed the original grant, and the narrowing sticks to the refresh token).\nA new permission needs a full sign-out and sign-in. Say that in the UI where a\nuser could plausibly wait for a grant to arrive.\n\n**There is no sign-out endpoint.** Thunder's discovery document advertises only\nissuer, authorize and token — no `end_session_endpoint` — so `signoutRedirect()`\nrejects. Sign-out drops the local session (`removeUser()`) and reloads;\n`src\u002Fauthz\u002Fsession.ts` already wraps it in that fallback.\n\n**Permissions ride in the access token's `scope`.** `oidc-client-ts` surfaces the\ntoken response's scope string as `user.scope`, and `src\u002Fauthz\u002Fgates.tsx` is the\nonly module that reads it. Never decode the access token, never hand-parse a JWT, and\n**never read `user.profile.groups`** — the groups claim is still issued and\nnothing in your app may consume it. There is no `getRoles()`, no role table of\nyour own, and no default role for a user who matches nothing: a caller whose\ntoken grants nothing sees `NoAccess`.\n\n**`userManager` is never exported.** Every other module reaches the session\nthrough `src\u002Fauthz\u002Fsession.ts`'s functions — `signIn`, `handleCallback`,\n`signOut`, `currentUser`, `accessToken`, `tokenIsValid`. That list is the\nmodule's whole surface, and it is what lets mock mode substitute the module\nwholesale with `mock\u002Fauthz\u002Fsession.ts` (`react-webapp`'s\n`references\u002Fmock-mode.md` owns the wiring). `userManager` is\n`oidc-client-ts`'s own object and has no mock substitute, so a single\n`export const userManager` compiles in production and breaks the app the moment\nanybody opens it without a cluster.\n\n## Implementation\n\n### 1 · The three generated files\n\n`scripts\u002Fgen-authz.mjs` reads `specs\u002Fdesign\u002Fsecurity.json` **and every contract\nunder `specs\u002Fdesign\u002Fcomponents\u002F`** (`*\u002Fopenapi.yaml` and\n`*\u002Fdependencies\u002F*.openapi.yaml`) and emits the files that carry the design into\nthe bundle. Wire it into `package.json`:\n\n```json\n\"scripts\": {\n  \"gen\":   \"node scripts\u002Fgen-authz.mjs\",\n  \"build\": \"npm run gen && tsc --noEmit && vite build\"\n}\n```\n\n**`gen` before `tsc` is not optional.** The whole point of a generated string\nliteral union is that a handle the design dropped, or an operation the contract\nrenamed, fails the type check — and a **stale** generated file type-checks\nperfectly green.\n\nRun `npm run gen` once by hand and **commit all three outputs**. The generator\nwalks UP from the app folder to find `specs\u002Fdesign\u002Fsecurity.json` (and reads\nthe contracts under that same `specs\u002F`), because how many levels up the\nproject's spec tree sits is a layout detail nothing may hardcode. Inside a\nper-component image build there is no such ancestor at all — the build context\nis the app folder alone — so when the specs are out of reach and all three\ncommitted outputs exist the generator **keeps them, says so on stdout and exits\n0**. Exiting 1 there would fail every image build the platform runs. With any\noutput missing and no specs it exits 1 and names which, which is the\nuncommitted-file case. The contract half imports `yaml` (a devDependency every\nweb app already carries for the mock plugin; `npm i` runs before `npm run\nbuild` in the image) — when `yaml` cannot be resolved the same fallback applies.\n\nThat fallback is the generator's ONLY quiet path. Everything else fails loudly,\nbecause each of these otherwise emits an empty table — an app where every\ncaller lands on `NoAccess`, type-checked green:\n\n| Situation | What it does |\n|---|---|\n| `--spec` \u002F `AEP_SECURITY_JSON` names a file that is not there | **exit 1** — a path the caller typed and misspelled is never a build context |\n| the document is not version 3 (a v1 or v2 file, `null`, an array) | **exit 1** naming the version; **only v3 is accepted** |\n| a version-3 document that still carries `screens[]` | **exit 1** naming the key — screens are not authored anywhere |\n| a version-3 document missing `permissions[]` or `roles[]` | **exit 1** naming the field |\n| an operation whose `security` names two scopes, two requirements or a reserved OIDC scope | **exit 1** naming the file, method and path |\n| an operation whose scope is not in the catalog | **exit 1** naming the handle |\n| an unknown flag, or a flag with no value | **exit 2** with the usage, and nothing written |\n\n`--help` prints the usage and exits 0 without writing. `--out-dir` (rarely\nneeded; the default is the app root) sets where the three files land. Two\ncontracts declaring the same `METHOD path`: the first wins, with a warning. A\ncontract that declares no `oauth2` scheme contributes every operation as\n`public`.\n\nWhat it emits, and what each export is for:\n\n| File | Export | Use |\n|---|---|---|\n| `src\u002Fauthz\u002Froles.gen.ts` | `Scope`, `SCOPES`, `isScope` | the catalog handles as a string-literal union |\n| | `Role`, `ROLES` | the user-kind roles (a service-kind role has no login and is not here) |\n| | `ROLE_GRANTS` | role → grants; `heldRoles()` projects the caller's scopes through it |\n| | `ROLE_ASSIGN_TO`, `ROLE_ASSIGNABLE_BY` | the group and role names `NoAccess` tells the user to ask for, and whom to ask |\n| `src\u002Fauthz\u002Foperations.gen.ts` | `OperationKey` | `\"\u003CMETHOD> \u003Cpath template>\"` as the contract spells it — `\"GET \u002Fme\u002Fclaims\"` — a string-literal union of every operation in every contract |\n| | `OPERATIONS`, `OperationRequirement`, `isOperationKey` | operation → `{ kind: \"public\" }` \\| `{ kind: \"signedIn\" }` \\| `{ kind: \"scope\", scope }`, the projection the gateway trait and the mock gateway make of the same block |\n| `mock\u002Fauthz\u002Froles.gen.ts` | `mockRoles` | the user-kind roles with their grants, in DECLARED order — the first is mock mode's default persona |\n\n### 2 · `src\u002Fauthz\u002Fsession.ts`\n\nAdd the four `\u003CDEP>_*` keys the SPA reads — `CLIENT_ID`, `ISSUER`, `SCOPES`,\n`RESOURCE`; not `JWKS_URL` — to the `Env` type in the `react-webapp` shim, and\nchange only the `USER_AUTH_` prefix in the copied file to YOUR dependency's. It\nis `env.ts` and this module that make the import graph browser-only: `env.ts`\nthrows at module load when `\u002Fenv-config.js` did not run, and the `UserManager`\nis constructed at module load.\n\nIts surface: `signIn`, `handleCallback` (`signinCallback()`, and `void` — see\nthe callback rule above), `signOut`, `currentUser` (renews an EXPIRED session\nsilently; `null` when there is no session, without asking the IdP),\n`accessToken`, and `tokenIsValid`.\n\n**Gate the app's first render on `currentUser()`**: a user → proceed; `null` →\n`signIn()`. Do **not** call `signIn()` merely because the access token expired —\nthat turns a silent refresh into a full-screen redirect on every visit.\n\n**There is no `username` claim in the ID token.** Measured: Thunder issues `sub`,\n`email`, `given_name`, `family_name`, `groups` and `ouId`\u002F`ouName`\u002F`ouHandle`,\nand no `username`, even when the application is registered with one in its\nattribute list. So \"signed in as …\" falls back `name` → `email` → `sub`, which\nis what `gates.tsx`'s `displayName()` does. Reading `profile.username` renders\n`undefined`; reading `sub` alone renders a UUID.\n\n### 3 · `src\u002Fauthz\u002Fcore.ts` and `src\u002Fauthz\u002Fgates.tsx` — the one authorization surface\n\nThe rules are **split** from the wiring, and the split is what makes them\ntestable. `src\u002Fenv.ts` throws at module load and `src\u002Fauthz\u002Fsession.ts`\nconstructs a `UserManager` at module load, so anything that imports\n`session.ts` drags a browser into the import graph and cannot be loaded by a\nunit test in a plain node environment. `core.ts` imports **nothing** — not even\nthe generated tables, which is why every function that needs them takes them as\nan argument — and `gates.tsx` re-exports what callers need, so the module\nsurface is unchanged.\n\n`core.ts`: `parseScopes`, `granted`, `canCall`, `heldRoles`, `rolesGranting`,\n`tokenIsValid`, `classifyApiFailure`, `createUnauthorizedHandler`.\n\n`gates.tsx` — the surface every screen decision goes through:\n\n| Export | Use |\n|---|---|\n| `\u003CAuthzProvider fallback={…}>` | resolves the session's scopes ONCE, above everything that gates |\n| `useScopes()`, `useAuthz()` | the caller's scopes \u002F the whole session state |\n| `granted()`, `can(op)` | the async form, for a route loader or a plain function outside React. `granted()` resolves to a `Set\u003Cstring>` — the token's scopes verbatim, the five OIDC ones included — so ask it with `can()`, never \"is the set non-empty\" |\n| `\u003CCan op={…}>` | show a nav item, a button, a column — hide it otherwise |\n| `\u003CRequireOperation op={…} screen={…} \u002F>` | route guard; a caller who may not call the operation lands on `\u002Fforbidden` |\n| `\u003CForbidden \u002F>` | route it at `\u002Fforbidden`, **inside** the app shell |\n| `\u003CNoAccess \u002F>` | **replaces** the shell when nothing at all is reachable |\n| `heldRoles()`, `useHeldRoles()` | the header badge |\n| `rolesGranting(scope)` | which roles unlock a scope — the Forbidden copy |\n\n**The prop is `op`, an `OperationKey`**: `\u003CRequireOperation op=\"GET \u002Fclaims\" \u002F>`,\n`\u003CCan op=\"POST \u002Fme\u002Fclaims\">`. Every gate answers\n`canCall(OPERATIONS[op], scopes, signedIn)`: a `public` operation is always\ncallable, a `signedIn` one by any session, a `scope` one when the token holds\nthat handle. No component takes a handle; a handle typed into JSX is the stale\ngate nothing can see (§5).\n\n**Scope comparison is a whole-string match, everywhere.** A token carrying\n`claims:read-all` does NOT satisfy `claims:read`: the gateway does not treat one\nas a superset of the other, so neither may the SPA. A role that needs both holds\nboth.\n\n**`heldRoles()` is derived from scopes against `ROLE_GRANTS`** — a role whose\nEVERY grant is held. It is a label for the badge and for the copy that tells a\nuser what to ask for; it is never an input to a gate, it never comes from a\ngroups claim, and there is no default role. The `NoAccess` copy names the groups\nand the granting roles from `ROLE_ASSIGN_TO` \u002F `ROLE_ASSIGNABLE_BY`: no role\nname, group name or administrator is ever hardcoded in that page.\n\n### 4 · `src\u002Fauthz\u002Fclient.ts` — the 401 rule\n\n**The gateway answers 401 for every failure, missing scope included, and sends\nno `WWW-Authenticate`** — `api-management`'s status matrix owns that and why no\nsetting changes it. What follows for the SPA: nothing on the wire tells an\nexpired token from a refused permission, so **do not add a `WWW-Authenticate`\nread — there is nothing to read.**\n\nSo the SPA absorbs it, in three places, and all three are already in the assets:\n\n1. **`gates.tsx` gates before it calls.** A screen whose load operation the\n   token does not unlock is never rendered, so that operation is never invoked.\n   That removes every routine case — and it is not sufficient alone: a typed\n   URL, a stale bundle or a race past a narrowed renew still reach the gateway.\n2. **`session.ts` exposes `tokenIsValid()`** — a pure, side-effect-free read of\n   the stored user's `expires_at` against the clock, with the 60 s grace. No\n   network, no renew, no sign-in, so the API client can call it on every\n   response without recursing into the thing it is deciding about. `expires_at`\n   is local and authoritative, and it is the only signal that tells the two\n   401s apart.\n3. **`client.ts` maps the answer**, through `classifyApiFailure`:\n\n| Answer | Outcome | Why |\n|---|---|---|\n| **401 + `tokenIsValid()`** | route to **Forbidden** | the session is fine, so the refusal is about scope — and the gateway cannot say so |\n| **401 + `!tokenIsValid()`** | **`signIn()`**, at most once per page load | the ordinary expired\u002Fabsent case |\n| **403** | **Forbidden, always** | no generated service answers 403 today, but an org API behind the same gateway may; signing in again cannot add a scope the caller's roles do not grant |\n\n`if (res.status === 401) signIn()` — what the previous revision of this skill\ntaught — is **DELETED**, and deleting it is the point of the file. It threw a\ncorrectly provisioned user who touched one operation their role does not grant\ninto an endless sign-in loop: sign in, succeed, call, 401, sign in.\n\n`signIn` is guarded to one call per page load: a screen firing several requests\nat once answers 401 several times over, and without the guard each answer starts\nits own redirect.\n\n**Wire the Forbidden route once, at the router root.** `client.ts` holds no\nrouter import; it takes the navigator. One component, rendered inside the router\nand above every route — `assets\u002FApp.example.tsx`'s `ForbiddenWiring`:\n\n```tsx\nconst navigate = useNavigate();\nuseEffect(() => setForbiddenNavigator(() => navigate(\"\u002Fforbidden\", { replace: true })), [navigate]);\n```\n\n`replace: true` keeps the refused URL out of the history, so Back does not walk\nthe user straight back into the same 403. Until that call lands, a refusal logs a\nnamed error rather than silently doing nothing — **this wiring is not optional**:\nwithout it every refusal the screen gate did not catch routes nowhere, which\nlooks exactly like a screen that renders nothing. Your per-service client — `src\u002Fapi.ts`, generated types and all — calls\n`apiFetch`\u002F`apiJson`, or, with an `openapi-fetch` client, `authorizationHeader()`\nand `classifyResponse()` from its middleware. It adds **nothing** of its own\nabout authorization.\n\n### 5 · `src\u002Fauthz\u002Fscreens.ts` — each screen names the operation it loads\n\n**A screen is gated on the operation it loads, and that operation is named\nonce, here.** The screen table is yours to write from the screens of\n`prototype.json`, in **rail order** (the order of the prototype's `AppShell`\n`nav`, then the screens it does not list). Each `label` is the screen's `name`,\nand the first reachable row is the landing screen:\n\n```ts\nexport const SCREEN_ROUTES: readonly ScreenRoute[] = [\n  { key: \"my-claims\", label: \"My claims\",    path: \"\u002Fclaims\u002Fmine\", loads: \"GET \u002Fme\u002Fclaims\" },\n  { key: \"submit\",    label: \"Submit claim\", path: \"\u002Fclaims\u002Fnew\",  loads: \"POST \u002Fme\u002Fclaims\" },\n  { key: \"approvals\", label: \"Approvals\",    path: \"\u002Fapprovals\",   loads: \"GET \u002Fclaims\" },\n];\n```\n\n`loads` is the operation the screen exists to perform, at the reach the screen\nshows: an every-row queue loads `GET \u002Fclaims`, a \"mine\" page loads\n`GET \u002Fme\u002Fclaims`. **A form that only writes names the operation its submit\nmakes** — it has no load call, but naming its one operation is what keeps the\nrail, the route guard and the button enabled from the same fact; leaving it\n`null` lets a caller reach a form whose only control they can never use.\n`loads: null` is reserved for a screen that needs no operation at all, which is\nrare. A screen the prototype draws on a bare `\u003CScreen>` root (Signed out, a\nlanding page) is `public: true` and is routed above the sign-in guard (§6). `reachableScreens(scopes, signedIn)` filters the table\nthrough `canCall`, and the rail, the landing redirect and `NoAccess` all read\nit.\n\n**Never retype a handle in JSX.** `scopes.has(\"claims:read\")` hand-written into\n`App.tsx` is a stale handle the moment the design moves, and nothing — not\n`tsc`, not the build gate, not the mock walk — can see that it went stale.\n`loads` is typed as `OperationKey`, the union the generator emits from the\ncontracts, so an operation the design renamed or dropped fails the type check\non the next `npm run gen`, which `build` runs first.\n\n**Fail loudly on a stale table.** The pattern checks every `loads` against\n`OPERATIONS` at module load and throws — in dev, in the walk and in the\ndeployed pod — so a committed table that outlived its contract cannot become a\nscreen nobody can reach and nobody notices. Do not soften that to a\n`console.warn` or a filter.\n\n### 6 · `src\u002FApp.tsx` — where each view sits is a routing rule\n\n| View | Where it goes | Why |\n|---|---|---|\n| `NoAccess` | **ABOVE** the shell route — returned *instead of* the shell | a caller who unlocks nothing gets no navbar and no empty sidebar. A rail with no items wrapped around \"you have no access\" tells the user less than the message alone |\n| `Forbidden` | **INSIDE** the shell, routed at `\u002Fforbidden` | the opposite case: the caller holds other scopes and has somewhere to go, so the rail stays |\n\nThis is a **routing-structure** rule, not styling. The natural thing to write —\nand what a real run wrote — is `NoAccess` inside `AppShell`'s `\u003COutlet \u002F>`; its\nown walk caught it. The test sits above the `\u003CRoutes>` that carry the shell:\n\n```tsx\nconst reachable = reachableScreens(scopes, true);\nif (reachable.length === 0) return \u003CNoAccess appName={APP_NAME} \u002F>;   \u002F\u002F no shell around it\nreturn \u003CRoutes>\u003CRoute element={\u003CAppShell \u002F>}>…\u003C\u002FRoute>\u003C\u002FRoutes>;\n```\n\nThe rest of the structure, from `assets\u002FApp.example.tsx`: `\u002Fcallback` is routed\n**outside** the provider (there is no session to read until the redirect has been\nprocessed); every route whose screen `loads` an operation is wrapped in\n`\u003CRequireOperation op={screen.loads} screen={screen.label}>`; the landing route\nredirects to the first **reachable** screen in `SCREEN_ROUTES` order.\n\n- `loads: \"\u003Coperation>\"` → `\u003CRequireOperation op={…}>` around the route and\n  `\u003CCan op={…}>` around its nav item.\n- `loads: null` → any signed-in caller; no guard. Rare — a form names its submit operation instead.\n- `public: true` (a screen on a bare `\u003CScreen>` root) → reachable before\n  sign-in; keep it outside the sign-in gate entirely. `App.example.tsx` routes\n  those screens **above** `SignedIn`, still inside `AuthzProvider` (so `\u003CCan>`\n  and `useScopes()` work on them) and outside `AppShell` — a visitor with no\n  session has no signed-in chrome to draw. A public screen routed inside the\n  guard is unreachable by the visitor it exists for, because the guard\n  redirects them to the IdP first.\n\n**The rail is ONE rail whose items are each wrapped in `Can`.** The prototype\ndraws the rail of one role at a time; a single gated rail reproduces every one\nof those pictures and also covers the case the prototype cannot draw —\nsomebody holding two roles, who sees the union.\n\n**A reachable screen with nothing in it shows its empty state**, not Forbidden,\nand a region whose operation the viewing role cannot call renders its own\nforbidden state rather than vanishing. The UI never turns away a user the API\nwould serve.\n\n**`\u002Fforbidden` and `NoAccess` are platform-prescribed views.** They appear in no\nprototype and they are the carve-out from \"no invented screens\"\n(`prototype`'s `references\u002Fimplementing.md` says the same); their absence is a\ndefect even though no prototype draws them.\n\n---\n\n# Backend authorization\n\n**The operation's scope is enforced at the gateway, and nowhere else.** Every\nprotected operation in `openapi.yaml` declares exactly one scope, or none; the\ngateway is rendered from that same contract and refuses a caller who lacks the\nhandle before your service is reached. A generated service therefore holds **no\noperation → scope table, in any stack**. `api-management` owns the argument.\n\nWhat a gateway cannot do is prove to your code that a request came through it.\nSo it mints a short-lived JWT of the caller it authenticated, signs it with the\nenvironment's own key, and puts it on the upstream request — and your service\nverifies that signature. That is the whole of backend authentication.\n\n## Verify the assertion: one copied asset, wired once\n\n| Stack | Asset | Wiring |\n|---|---|---|\n| Go | `$AEP_SKILLS_DIR\u002Fgo\u002Fassets\u002Fgateway_assertion.go` | `auth.NewVerifierFromEnv()` in `main` (fatal on error) + `r.Use(verifier.Middleware)` |\n| Ballerina | `$AEP_SKILLS_DIR\u002Fballerina\u002Fassets\u002Fgateway_assertion.bal` | `http:InterceptableService` + `createInterceptors() returns AssertionInterceptor` |\n\nBoth read the same three variables, which the platform sets on the container\nwhen the environment's gateway publishes a keypair:\n`GATEWAY_ASSERTION_CERTIFICATE`, `GATEWAY_ASSERTION_ISSUER`,\n`GATEWAY_ASSERTION_HEADER`. **A partial trio stops the service from starting**,\nin both stacks, on purpose: a service that starts on half of them cannot tell a\nreal caller from a forged one, and a half-configured assertion is a broken\ndeployment rather than an unconfigured one. All three **absent** is a separate\nand temporary case — an environment gateway provisioned before the backend-JWT\nkeypair existed sets none of them, and the asset then reads the caller without\nverifying any signature and warns on every boot. That fallback is tracked for\nremoval in issue #789; author nothing that relies on it.\n\n**You author no new check.** The asset verifies the signature, pins the issuer\nto the gateway (never the IdP), checks the expiry and puts the caller on the\nrequest context. A handler reads the caller from there and nothing else.\n\nThree outcomes, and the middle one is the point:\n\n```\nno assertion                 → continue with no caller    # a public operation has none\npresent but not verifiable   → 401, immediately           # never \"anonymous\"\nverified                     → continue with the caller\n```\n\nDowngrading an unverifiable assertion to an anonymous request would make forging\none strictly better for an attacker than sending none.\n\n**The SPA sees only 401s** — the gateway answers 401 for a missing scope exactly\nas for a dead token, so §4's `classifyResponse()` sends a 401 with a still-valid\ntoken to Forbidden. Nothing in the service answers 403.\n\n## Reach is the path, not a check in the handler\n\nA handler holds **no authorization logic**. Whether the operation may be called\nwas settled at the gateway from the contract; which rows it returns was settled\nby its path. So there are exactly two shapes of handler, and neither branches\non a scope:\n\n```\nGET \u002Fme\u002Fclaims        →  rows := claims.where(owner_id = caller.sub)\nGET \u002Fme\u002Fteam\u002Fclaims   →  rows := claims.where(owner_id in reports_of(caller.sub))\nGET \u002Fclaims           →  rows := claims.all()\nPOST \u002Fme\u002Fclaims       →  claim.owner_id = caller.sub   \u002F\u002F stamped, never read from the body\n```\n\n`hasScope` (Go: `auth.HasScope`; Ballerina: `hasScope(caller, …)`) exists for\nthe rare handler that needs a second fact about the caller for something other\nthan authorization — a header badge, an audit line. If you are reaching for it\nto decide which rows to return, the design has one operation where it needs\ntwo: report that, do not code around it.\n\n**A row that exists but is not the caller's is a 404, not a 403** — a caller who\nmay not see a row may not learn it exists (`api-management` owns that rule).\nUnder `\u002Fme\u002F…` that is not a special case: the row is simply not in the caller's\ncollection.\n\n## Identity is not authorization\n\n- **What may they do** was answered at the gateway, from the contract, and\n  **which rows** by the operation's path. Inside the service the assertion's\n  `scope` claim decides nothing. There is no group matching, no substring match\n  on a role name, no role column in your own table, and no cold-start default.\n- **Which rows are theirs** is the assertion's `sub` — an opaque IdP subject,\n  and the one key for rows this service creates. Stamp it on every row a\n  `\u002Fme\u002F…` operation creates, and resolve every `\u002Fme\u002F…` query through it.\n- **Directory attributes** (their unit, their own id in some other system) come\n  from the caller's directory record, resolved by their username. A username can\n  be renamed, so look the record UP by it and never store it as a row key. Never\n  match `sub` against a record id another system minted, and never parse an\n  attribute out of a group name. A username that resolves to no record is a\n  refusal. The directory's real endpoint, its username field, and the dependency\n  wiring are org-specific — `internal-services` owns them; do not hardcode a\n  roster.\n\n## The service's own per-caller rows\n\nRows this service creates for a caller — their claim, their draft, their\npreferences — are keyed on the assertion's `sub`, the one case where that is\nright, because the service stored the subject itself rather than matching it\nagainst ids another system minted. **Store no role column and no permission\ncolumn**: the token already answered that, and a second copy is a second\nauthority that drifts.\n\nExpress this in your stack's own idiom — where the verifier is wired, where the\nshared helper lives, and how a handler returns 401 — following the conventions\nthat skill already sets.\n\n---\n\n## Pitfalls\n\n| Symptom | Cause | Fix |\n|---|---|---|\n| The service will not start: `…must be set together or not at all` | Some of the three are set, not all | Set all three from a throwaway keypair locally; in a cell, the environment's gateway needs provisioning. |\n| Every request 401s right after a deploy | The environment's gateway was re-provisioned; this component still holds the previous certificate | Redeploy the component — the certificate rides its ReleaseBinding. |\n| A forged request is served as an anonymous caller | An unverifiable assertion was treated as \"no caller\" | A present-but-invalid assertion is always a 401. |\n| Signed-in user loops back to the login page forever, ~160 ms per cycle | `if (res.status === 401) signIn()` in the API client: the gateway answers 401 for a missing scope exactly as for a dead token | The 401 rule — 401 + `tokenIsValid()` ⇒ Forbidden; only an absent\u002Fexpired token signs in. Copy `src\u002Fauthz\u002Fclient.ts` from the assets. |\n| Sign-in succeeds, looks perfectly healthy, and EVERY `\u002Fapi` call 401s | The token's `aud` is not this project's resource server — `resource` missing from one of the three legs | Set all three: `settings.resource`, `extraTokenParams`, and the `signinSilent({ resource, … })` argument. |\n| `tsc` is green but a screen is gated on an operation the contract dropped, or a new handle reaches nothing | `operations.gen.ts` is stale, or a handle was retyped as a string literal in JSX | `build` is `npm run gen && tsc --noEmit && vite build`; gate on `loads` through `src\u002Fauthz\u002Fscreens.ts`, never from a literal. |\n| A role opens its own screen and the screen's list call answers 401, or the screen is hidden for the role it exists for | The role's `grants` lack the handle of the operation the screen **loads** — whole-string match, so `x:read-all` (`GET \u002Fx`) is not `x:read` (`GET \u002Fme\u002Fx`); or `loads` names the wrong reach for the screen | A design finding: report the role, the screen and the handle. Never widen `loads`, a mock or a guard to hide it. |\n| `TS2353: 'useRefreshToken' \u002F 'clockSkewInSeconds' does not exist in type 'UserManagerSettings'` | Neither is a member in oidc-client-ts 3.5.0 | Delete both. `automaticSilentRenew: true` drives the refresh grant; the expiry grace is the asset's own `CLOCK_SKEW_SECONDS`. |\n| The header badge is empty for a user who clearly has a role | Code read `user.profile.groups` | `heldRoles()` — the roles whose EVERY grant is in the token's `scope`. |\n| \"You have no access\" is drawn with a navbar and an empty sidebar around it | `NoAccess` was rendered through `AppShell`'s `\u003COutlet \u002F>` | Return it ABOVE the shell route; `Forbidden` is the one that stays inside. |\n| A role-scoped caller signs in but sees no rows | The SPA called `\u002Fme\u002F…` for a role whose screen lists every row, or the handler matched `sub` against a directory id | The screen calls the operation whose path is its reach (`\u002Fclaims` for an every-row queue); resolve directory records by username. |\n| A caller holding `claims:read-all` is refused `GET \u002Fme\u002Fclaims` | Scope comparison is an exact string match; `claims:read-all` guards `GET \u002Fclaims`, a different operation | The SPA calls the operation the role's handle guards. If the role genuinely needs both views, the design grants both handles — report it; do not special-case it in code. |\n| A public endpoint trusts an identity | A public operation has no policy, so every inbound header is the caller's own and no assertion is minted | A handler behind `security: []` reads no identity at all. |\n| A newly granted permission does not show up for a user who is already signed in | A refresh narrows but never widens — RFC 6749 §6 | Sign out and in again; a removed grant, by contrast, disappears at the next renew. |\n| Sign-in loops at the right path, or the user is sent to login on every visit \u002F new tab | No persistent `WebStorageStateStore` (the in-memory default loses the PKCE verifier across the redirect), session in `sessionStorage`, or the load path calls `signIn()` on a merely-expired token | `WebStorageStateStore({ store: localStorage })` + `automaticSilentRenew`; renew via `signinSilent()` and only `signIn()` when there is no session. |\n| The splash (\"Checking your session…\") sits ~10 s on every signed-out visit before the IdP appears | `\u002Fcallback` calls `signinRedirectCallback()`, so the silent renew's hidden iframe never reports back and the parent waits out `silentRequestTimeoutInSeconds` — and a signed-out visitor was sent into that renew at all | `handleCallback()` → `signinCallback()`; `currentUser()` renews only what `sessionAction` calls `renew`. Both are in the assets. |\n| After login, \"invalid redirect URI\" | `redirect_uri` doesn't match the `\u003Corigin>\u002Fcallback` the platform registered | Compute `window.location.origin + '\u002Fcallback'`. |\n| Logout button does nothing | `signOut()` calls only `signoutRedirect()`, which rejects (no `end_session_endpoint`), and the handler swallows it | Wrap it in the try\u002Fcatch fallback to `removeUser()` + reload. |\n","# Thunder Authentication\n\nEnd-user identity is delegated to Thunder, the platform's Identity Provider,\nwhich the API gateway is wired to as its external IDP. **What a caller may do is\nthe access token's `scope` — one authority, nothing else.**\n\n- **The protected backend** never sees a token: the gateway validates it,\n  enforces the scope each operation declares in `openapi.yaml`, and hands the\n  service a **gateway-signed assertion** carrying the same `sub` and `scope`.\n  See `api-management` for the gateway's side of that contract.\n- **The SPA** signs the user in with OIDC Authorization Code + PKCE, asking for\n  a **resource indicator** so the token is minted for this project, reads the\n  granted permissions from `user.scope`, and gates every screen on the scope of\n  the **operation that screen loads**.\n\n**Nothing reads the groups claim to decide anything** — not the SPA, not the\nservice, not for display. Permissions reach code as scopes. The invariants\nbehind every rule here are stated once in `authorization-model`; this skill is\nthe mechanics.\n\nThe OAuth client itself is **platform-owned**: you never create, compute, or\nhardcode any part of it.\n\n## Where permissions come from\n\n`specs\u002Fdesign\u002Fsecurity.json` is the project's permission catalog. Read it before\nwriting any authorization code:\n\n| Field | What you do with it |\n|---|---|\n| `permissions[].resource` + `actions[].handle` | joined by `:` these are the **scope handles** — `claims:read`, `reports:export`. This is the closed set. |\n| `roles[].grants` | which handles a role holds. Drives the SPA's header badge and the \"which role unlocks this\" wording; `src\u002Fauthz\u002Froles.gen.ts` is generated from it. |\n| `roles[].assignTo`, `groups[]` | provisioning only. **No application code reads these.** |\n\nTwo things are **not** in this file, on purpose. Which **rows** an operation\nreaches is the operation's path in `openapi.yaml`: under `\u002Fme\u002F` the caller's\n(or a relation's — `\u002Fme\u002Fteam\u002Fclaims`), anywhere else every row.\n`openapi-conventions` owns that rule; here it means a `\u002Fme\u002F…` handler resolves\nrows through the assertion's `sub`, and nothing else ever filters. And which\n**screens** a caller may open is the scope of the operation each screen\n**loads** — the one handle that operation already names in `openapi.yaml`. No\nscreen table exists anywhere; the generator projects every contract into\n`src\u002Fauthz\u002Foperations.gen.ts` and you bind each screen to its load operation\nonce, in `src\u002Fauthz\u002Fscreens.ts` (§5).\n\nThe platform creates the resource server, the roles and the test users when the\nuser clicks Build. Never write user-, group- or role-provisioning code, and\nnever seed a roster: an account you create is not one the platform can hand to\nthe validation agent. No code names a test user or gives one rows or a\nrelation.\n\n**Dev clusters** ship a default Thunder admin: `admin` \u002F `admin`, in the\n`Administrators` group. That group administers the PLATFORM — it is not one of\nyour app's roles, and the platform will not grant it your app's scopes.\n\n---\n\n# SPA sign-in and screen gating\n\n## Order of work\n\n`src\u002Fenv.ts` (add the four `\u003CDEP>_*` keys the SPA reads to the `react-webapp` shim) →\ncopy the `assets\u002Fapp\u002F` tree (below) → `scripts\u002Fgen-authz.mjs` wired into the\nbuild and run once, so the three generated files exist → the `USER_AUTH_`\nprefix in `src\u002Fauthz\u002Fsession.ts` → **`src\u002Fapi.ts` stripped of every\nauthorization rule of its own** (§4) → a **`\u002Fcallback` route** that calls\n`handleCallback()` once on mount → `src\u002Fauthz\u002Fscreens.ts` and the route guards\nin `src\u002FApp.tsx`. Verify with the `react-webapp` build check.\n\n## What you copy\n\nThe assets are laid out as the app is, so the install is **one command** and\nnothing is renamed on the way in. **Copy them; do not write your own.** The\nrules they carry were measured against this IdP and this gateway, and every one\nof them has already been got wrong by a real run.\n\n```bash\ncp -r \"$AEP_SKILLS_DIR\u002Fthunder-authentication\u002Fassets\u002Fapp\u002F.\" .\n```\n\nThat puts eight files in place, all verbatim:\n\n| Path in the app | What it is |\n|---|---|\n| `scripts\u002Fgen-authz.mjs` | the generator — run by `npm run gen`, emits the three `*.gen.ts` files |\n| `src\u002Fauthz\u002Fsession.ts` | sign-in, the session, `tokenIsValid()` — the ONE edit: the `USER_AUTH_` prefix becomes YOUR dependency's |\n| `src\u002Fauthz\u002Fcore.ts` | the pure rules, no imports — testable in plain node |\n| `src\u002Fauthz\u002Fgates.tsx` | `AuthzProvider`, `Can`, `RequireOperation`, `Forbidden`, `NoAccess` — restyle the markup with the pinned design system, keep the words and every export name |\n| `src\u002Fauthz\u002Fclient.ts` | the 401 rule and the `openapi-fetch` middleware |\n| `mock\u002Fauthz\u002Fsession.ts` | mock mode's substitute for `src\u002Fauthz\u002Fsession.ts` (`?role=`, `?auth=out`) |\n| `mock\u002Fauthz\u002Fgateway.ts`, `mock\u002Fauthz\u002Fcontract.ts` | mock mode's API gateway: the contract projected into a table, and the 401s |\n\nTwo more ship as **patterns** beside `app\u002F`, and are adapted rather than copied:\n\n| Asset | Becomes | How |\n|---|---|---|\n| `assets\u002Fscreens.example.ts` | `src\u002Fauthz\u002Fscreens.ts` | replace `SCREEN_ROUTES` with YOUR screens — key, label, path and the operation each **loads** — in rail order; keep the rest |\n| `assets\u002FApp.example.tsx` | `src\u002FApp.tsx` | replace `PAGE_BY_KEY` *and* `APP_NAME` with yours; the ROUTING STRUCTURE is prescribed |\n\nOne file is not copied and is not optional: **`src\u002Fapi.ts`, the per-service\nclient you already have.** Whatever it carried about authorization comes OUT —\nthe bearer it attached, any `WWW-Authenticate` read, and above all\n`if (res.status === 401) signIn()` — and it calls `src\u002Fauthz\u002Fclient.ts`'s\n`authorizationHeader()` and `classifyResponse()` instead (§4 has the\n`openapi-fetch` middleware to paste). Two modules that both decide what a 401\nmeans is the same bug as one module deciding it wrong, and on an app that\nalready exists this is the only edit the copy cannot make for you.\n\nThe two example files are written against the Expense Tracker — its\n`SCREEN_ROUTES`, `PAGE_BY_KEY` and `APP_NAME` all name ITS screens and ITS\noperations. They are a shape to follow, not a fixture to ship. If your app\nalready holds its name somewhere (the prototype manifest's `name`, usually\n`src\u002FappName.ts`), import it rather than declaring a second copy.\n\nIf `$AEP_SKILLS_DIR` is unset, copy from `assets\u002F` next to this skill's\n`SKILL.md`. The two `*.example.*` files and everything under `assets\u002F__tests__\u002F`\nare **not** copied into the app: the examples are patterns you adapt, and the\ntests are this skill's own regression suite. `react-webapp`'s mock harness\n(`mock\u002Fplugin.ts`, `mock\u002Fbrowser.ts`) is copied separately and imports the\n`mock\u002Fauthz\u002F` files above by those paths.\n\n## Constraints\n\n**Keys are derived from YOUR dependency name.** The platform emits every\nplatform-resource dependency's outputs into `window._env_` as\n`\u003CUPPER_SNAKE(depName)>_\u003CUPPER_SNAKE(outputName)>`. There is **no fixed prefix** —\nit is the UPPER_SNAKE of the dependency `name` the architect chose. The auth\nresource type outputs `client_id`, `issuer`, `jwks_url`, `scopes` and\n`resource`, so a dependency named `user-auth` yields:\n\n| Key (dep `user-auth`) | Generic form | Meaning |\n|---|---|---|\n| `USER_AUTH_CLIENT_ID` | `\u003CDEP>_CLIENT_ID` | this app's platform-owned OAuth client id |\n| `USER_AUTH_ISSUER` | `\u003CDEP>_ISSUER` | OIDC issuer \u002F authority for `oidc-client-ts` |\n| `USER_AUTH_JWKS_URL` | `\u003CDEP>_JWKS_URL` | JWKS endpoint. Emitted, and **not** in the SPA's `Env`: the browser never validates a token — the API gateway does — so no asset reads it. Leave it out of `src\u002Fenv.ts` and out of `mock\u002Fenv.ts` |\n| `USER_AUTH_SCOPES` | `\u003CDEP>_SCOPES` | space-separated scopes to request: the OIDC ones (`openid profile email group ou`) plus the project's catalog handles |\n| `USER_AUTH_RESOURCE` | `\u003CDEP>_RESOURCE` | the project's **resource-server identifier** — the RFC 8707 `resource` indicator, and the `aud` the gateway pins |\n\nHardcoding a fixed prefix — or any prefix other than YOUR dependency's name —\ngives `undefined` at module load and a redirect to `undefined\u002Foauth2\u002Fauthorize`.\n\nThe access token lives `86400` seconds by default: the `validityPeriod`\nparameter of the auth resource type, which no `workload.yaml` sets. Do not\nassume a shorter lifetime. A short value is only for a fixture app that tests\nthe silent renew.\n\n**Ask for the resource indicator on all three legs, or every API call 401s.**\nThe indicator is what makes the IdP mint an access token whose `aud` is this\nproject's resource server and whose `scope` is narrowed to what this user's\nroles grant there. Without it the token carries the IdP's default audience and\nthe gateway rejects it **before it reads a scope** — while sign-in itself looks\nperfectly healthy.\n\n`oidc-client-ts` 3.5.0 carries `resource` on exactly ONE of the three legs by\nitself. Measured against the library, not assumed:\n\n| Leg | Does `settings.resource` reach it? | What you set |\n|---|---|---|\n| `\u002Fauthorize` redirect | **yes** — appended to the authorize URL | `resource: env.\u003CDEP>_RESOURCE` in the `UserManager` settings |\n| code → token exchange | **no** — `_processCode` sends only its own fields plus `...extraTokenParams` | `extraTokenParams: { resource: env.\u003CDEP>_RESOURCE }` |\n| refresh \u002F silent renew | **no** — `signinSilent(args)` forwards `args` and never falls back to `this.settings` | pass `{ resource, extraTokenParams }` to **every** `signinSilent()` call |\n\n`src\u002Fauthz\u002Fsession.ts` sets all three. A run that copied a settings-only\nsnippet got a green build, a healthy-looking sign-in, and a wrong `aud` on every\ntoken.\n\nOn **this** IdP leg 3 is survivable: Thunder binds the refresh token to the\nresource server it was issued for, so an argument-less renew keeps the same\n`aud` (and asking for a *different* resource is refused with `invalid_target`).\nSet all three anyway — it is what makes the app portable to an IdP that\nre-derives the audience per request, where the omission silently downgrades\nevery renewed token one access-token lifetime after sign-in.\n\n**Two settings that do not exist in 3.5.0.** Both are type errors, and both look\nplausible enough that they get written:\n\n- **`useRefreshToken`** is a method on `OidcClient`, not a member of\n  `UserManagerSettings`. `automaticSilentRenew: true` plus a refresh token in\n  the response is what makes renewal use the refresh grant.\n- **`clockSkewInSeconds`** is not a member either. The settings that do exist\n  are `accessTokenExpiringNotificationTimeInSeconds` (default 60 — the lead time\n  the silent renew fires at) and `staleStateAgeInSeconds`. So the grace period\n  `tokenIsValid()` allows past `expires_at` is **ours**: `src\u002Fauthz\u002Fsession.ts`\n  holds a private `CLOCK_SKEW_SECONDS = 60`, the same width as that renew window.\n\n**`client_id` is platform-owned.** It is a platform-derived opaque identifier,\n**not** the dependency's `name`; the platform delivers it in\n`window._env_.\u003CDEP>_CLIENT_ID`. Same for the client secret and the registered\nredirect URIs. Never add Thunder client-provisioning code anywhere — the\nplatform's Thunder Application operator does it when the dependency provisions —\nand never write a `\u002Flogin` form that POSTs credentials to your own API.\n\n**Compute the redirect URI; there is no key for it.** The platform registers the\nSPA's served callback URL once its public URL resolves, and the SPA is served at\nits host root (see `react-webapp`), so that URL is `\u003Corigin>\u002Fcallback`.\nReconstruct exactly that in the browser: `window.location.origin + '\u002Fcallback'`,\nand serve the route at `\u002Fcallback`. Post-sign-in landing is\n`window.location.origin`. Neither is an env key.\n\n**That ONE registered URI serves BOTH legs, so the route must dispatch.**\n`silent_redirect_uri` defaults to `redirect_uri` in oidc-client-ts 3.5.0, so a\nsilent renew's hidden iframe lands on `\u002Fcallback` too — and a second, dedicated\nURI is not an option, because the platform registers only this one and the IdP\nanswers `invalid_request: Invalid redirect URI` for anything else. So the route\ncalls **`signinCallback()`**, which reads `request_type` off the stored state\nand dispatches (`si:r` → redirect, `si:s` → silent). `signinRedirectCallback()`\nfinishes only the redirect leg: on the silent leg it never calls the iframe\nnavigator's `callback()`, so the parent window is never notified and waits out\nthe full 10s `silentRequestTimeoutInSeconds` before the renew rejects. MEASURED\non a deployed app: **11.1s** from first paint to the sign-in page, on every\nsigned-out visit, 10.0s of it that timeout. `react-oidc-context`, which the\nplatform's own console is built on, calls the same dispatching function.\n\n**Token endpoint is cross-origin.** The browser posts straight to\n`\u003CDEP>_ISSUER\u002Foauth2\u002Ftoken`; discovery is\n`\u003CDEP>_ISSUER\u002F.well-known\u002Fopenid-configuration`. Nothing is proxied same-origin,\nwhich is why `react-webapp` does not proxy `\u002Foidc\u002F` — nginx only reverse-proxies\nsibling APIs under `\u002Fapi`.\n\n**Persist the session and renew silently.** The OAuth client is provisioned with\nthe `refresh_token` grant alongside `authorization_code` + PKCE, so an expiring\naccess token is renewed by posting the refresh token — no hidden iframe, no\nthird-party-cookie dependency. The session lives in `localStorage` (a\n`WebStorageStateStore`) with `automaticSilentRenew: true`. `sessionStorage` is\nper-tab and wiped on close, which forces a re-login on every visit; and without\npersistent web storage the PKCE verifier does not survive the redirect at all.\n\n**Renew what EXISTS; sign in when nothing does.** `signinSilent()` is for a\nstored session that has expired — it posts the refresh token and nobody sees it.\nWith no stored session there is nothing to refresh, so the library falls back to\na hidden iframe whose only possible answer is `login_required`, and the app\nwaits behind its splash for it: measured at 0.8s of actual round trip inside a\n10s wait, plus a second full boot of the SPA inside that iframe. That fork is\n`sessionAction` in `assets\u002Fapp\u002Fsrc\u002Fauthz\u002Fcore.ts` — `use` \u002F `renew` \u002F `none` —\nkept out of `session.ts` so it can be tested; `none` goes straight to `signIn()`.\n\nWhat it costs: a visitor holding an IdP session from a sibling app is signed in\nby a visible redirect rather than a hidden iframe. Same destination, one visible\nhop — and the iframe leg is cross-site (the app and the IdP are separate hosts),\nso a browser blocking third-party cookies answers `login_required` anyway.\n\n**A refresh narrows, never widens.** Permission scopes are re-evaluated on\nrenewal, so a grant REMOVED from a role disappears at the next silent renew —\nbut a grant ADDED never appears on a refresh at all (RFC 6749 §6: a refresh may\nnot exceed the original grant, and the narrowing sticks to the refresh token).\nA new permission needs a full sign-out and sign-in. Say that in the UI where a\nuser could plausibly wait for a grant to arrive.\n\n**There is no sign-out endpoint.** Thunder's discovery document advertises only\nissuer, authorize and token — no `end_session_endpoint` — so `signoutRedirect()`\nrejects. Sign-out drops the local session (`removeUser()`) and reloads;\n`src\u002Fauthz\u002Fsession.ts` already wraps it in that fallback.\n\n**Permissions ride in the access token's `scope`.** `oidc-client-ts` surfaces the\ntoken response's scope string as `user.scope`, and `src\u002Fauthz\u002Fgates.tsx` is the\nonly module that reads it. Never decode the access token, never hand-parse a JWT, and\n**never read `user.profile.groups`** — the groups claim is still issued and\nnothing in your app may consume it. There is no `getRoles()`, no role table of\nyour own, and no default role for a user who matches nothing: a caller whose\ntoken grants nothing sees `NoAccess`.\n\n**`userManager` is never exported.** Every other module reaches the session\nthrough `src\u002Fauthz\u002Fsession.ts`'s functions — `signIn`, `handleCallback`,\n`signOut`, `currentUser`, `accessToken`, `tokenIsValid`. That list is the\nmodule's whole surface, and it is what lets mock mode substitute the module\nwholesale with `mock\u002Fauthz\u002Fsession.ts` (`react-webapp`'s\n`references\u002Fmock-mode.md` owns the wiring). `userManager` is\n`oidc-client-ts`'s own object and has no mock substitute, so a single\n`export const userManager` compiles in production and breaks the app the moment\nanybody opens it without a cluster.\n\n## Implementation\n\n### 1 · The three generated files\n\n`scripts\u002Fgen-authz.mjs` reads `specs\u002Fdesign\u002Fsecurity.json` **and every contract\nunder `specs\u002Fdesign\u002Fcomponents\u002F`** (`*\u002Fopenapi.yaml` and\n`*\u002Fdependencies\u002F*.openapi.yaml`) and emits the files that carry the design into\nthe bundle. Wire it into `package.json`:\n\n```json\n\"scripts\": {\n  \"gen\":   \"node scripts\u002Fgen-authz.mjs\",\n  \"build\": \"npm run gen && tsc --noEmit && vite build\"\n}\n```\n\n**`gen` before `tsc` is not optional.** The whole point of a generated string\nliteral union is that a handle the design dropped, or an operation the contract\nrenamed, fails the type check — and a **stale** generated file type-checks\nperfectly green.\n\nRun `npm run gen` once by hand and **commit all three outputs**. The generator\nwalks UP from the app folder to find `specs\u002Fdesign\u002Fsecurity.json` (and reads\nthe contracts under that same `specs\u002F`), because how many levels up the\nproject's spec tree sits is a layout detail nothing may hardcode. Inside a\nper-component image build there is no such ancestor at all — the build context\nis the app folder alone — so when the specs are out of reach and all three\ncommitted outputs exist the generator **keeps them, says so on stdout and exits\n0**. Exiting 1 there would fail every image build the platform runs. With any\noutput missing and no specs it exits 1 and names which, which is the\nuncommitted-file case. The contract half imports `yaml` (a devDependency every\nweb app already carries for the mock plugin; `npm i` runs before `npm run\nbuild` in the image) — when `yaml` cannot be resolved the same fallback applies.\n\nThat fallback is the generator's ONLY quiet path. Everything else fails loudly,\nbecause each of these otherwise emits an empty table — an app where every\ncaller lands on `NoAccess`, type-checked green:\n\n| Situation | What it does |\n|---|---|\n| `--spec` \u002F `AEP_SECURITY_JSON` names a file that is not there | **exit 1** — a path the caller typed and misspelled is never a build context |\n| the document is not version 3 (a v1 or v2 file, `null`, an array) | **exit 1** naming the version; **only v3 is accepted** |\n| a version-3 document that still carries `screens[]` | **exit 1** naming the key — screens are not authored anywhere |\n| a version-3 document missing `permissions[]` or `roles[]` | **exit 1** naming the field |\n| an operation whose `security` names two scopes, two requirements or a reserved OIDC scope | **exit 1** naming the file, method and path |\n| an operation whose scope is not in the catalog | **exit 1** naming the handle |\n| an unknown flag, or a flag with no value | **exit 2** with the usage, and nothing written |\n\n`--help` prints the usage and exits 0 without writing. `--out-dir` (rarely\nneeded; the default is the app root) sets where the three files land. Two\ncontracts declaring the same `METHOD path`: the first wins, with a warning. A\ncontract that declares no `oauth2` scheme contributes every operation as\n`public`.\n\nWhat it emits, and what each export is for:\n\n| File | Export | Use |\n|---|---|---|\n| `src\u002Fauthz\u002Froles.gen.ts` | `Scope`, `SCOPES`, `isScope` | the catalog handles as a string-literal union |\n| | `Role`, `ROLES` | the user-kind roles (a service-kind role has no login and is not here) |\n| | `ROLE_GRANTS` | role → grants; `heldRoles()` projects the caller's scopes through it |\n| | `ROLE_ASSIGN_TO`, `ROLE_ASSIGNABLE_BY` | the group and role names `NoAccess` tells the user to ask for, and whom to ask |\n| `src\u002Fauthz\u002Foperations.gen.ts` | `OperationKey` | `\"\u003CMETHOD> \u003Cpath template>\"` as the contract spells it — `\"GET \u002Fme\u002Fclaims\"` — a string-literal union of every operation in every contract |\n| | `OPERATIONS`, `OperationRequirement`, `isOperationKey` | operation → `{ kind: \"public\" }` \\| `{ kind: \"signedIn\" }` \\| `{ kind: \"scope\", scope }`, the projection the gateway trait and the mock gateway make of the same block |\n| `mock\u002Fauthz\u002Froles.gen.ts` | `mockRoles` | the user-kind roles with their grants, in DECLARED order — the first is mock mode's default persona |\n\n### 2 · `src\u002Fauthz\u002Fsession.ts`\n\nAdd the four `\u003CDEP>_*` keys the SPA reads — `CLIENT_ID`, `ISSUER`, `SCOPES`,\n`RESOURCE`; not `JWKS_URL` — to the `Env` type in the `react-webapp` shim, and\nchange only the `USER_AUTH_` prefix in the copied file to YOUR dependency's. It\nis `env.ts` and this module that make the import graph browser-only: `env.ts`\nthrows at module load when `\u002Fenv-config.js` did not run, and the `UserManager`\nis constructed at module load.\n\nIts surface: `signIn`, `handleCallback` (`signinCallback()`, and `void` — see\nthe callback rule above), `signOut`, `currentUser` (renews an EXPIRED session\nsilently; `null` when there is no session, without asking the IdP),\n`accessToken`, and `tokenIsValid`.\n\n**Gate the app's first render on `currentUser()`**: a user → proceed; `null` →\n`signIn()`. Do **not** call `signIn()` merely because the access token expired —\nthat turns a silent refresh into a full-screen redirect on every visit.\n\n**There is no `username` claim in the ID token.** Measured: Thunder issues `sub`,\n`email`, `given_name`, `family_name`, `groups` and `ouId`\u002F`ouName`\u002F`ouHandle`,\nand no `username`, even when the application is registered with one in its\nattribute list. So \"signed in as …\" falls back `name` → `email` → `sub`, which\nis what `gates.tsx`'s `displayName()` does. Reading `profile.username` renders\n`undefined`; reading `sub` alone renders a UUID.\n\n### 3 · `src\u002Fauthz\u002Fcore.ts` and `src\u002Fauthz\u002Fgates.tsx` — the one authorization surface\n\nThe rules are **split** from the wiring, and the split is what makes them\ntestable. `src\u002Fenv.ts` throws at module load and `src\u002Fauthz\u002Fsession.ts`\nconstructs a `UserManager` at module load, so anything that imports\n`session.ts` drags a browser into the import graph and cannot be loaded by a\nunit test in a plain node environment. `core.ts` imports **nothing** — not even\nthe generated tables, which is why every function that needs them takes them as\nan argument — and `gates.tsx` re-exports what callers need, so the module\nsurface is unchanged.\n\n`core.ts`: `parseScopes`, `granted`, `canCall`, `heldRoles`, `rolesGranting`,\n`tokenIsValid`, `classifyApiFailure`, `createUnauthorizedHandler`.\n\n`gates.tsx` — the surface every screen decision goes through:\n\n| Export | Use |\n|---|---|\n| `\u003CAuthzProvider fallback={…}>` | resolves the session's scopes ONCE, above everything that gates |\n| `useScopes()`, `useAuthz()` | the caller's scopes \u002F the whole session state |\n| `granted()`, `can(op)` | the async form, for a route loader or a plain function outside React. `granted()` resolves to a `Set\u003Cstring>` — the token's scopes verbatim, the five OIDC ones included — so ask it with `can()`, never \"is the set non-empty\" |\n| `\u003CCan op={…}>` | show a nav item, a button, a column — hide it otherwise |\n| `\u003CRequireOperation op={…} screen={…} \u002F>` | route guard; a caller who may not call the operation lands on `\u002Fforbidden` |\n| `\u003CForbidden \u002F>` | route it at `\u002Fforbidden`, **inside** the app shell |\n| `\u003CNoAccess \u002F>` | **replaces** the shell when nothing at all is reachable |\n| `heldRoles()`, `useHeldRoles()` | the header badge |\n| `rolesGranting(scope)` | which roles unlock a scope — the Forbidden copy |\n\n**The prop is `op`, an `OperationKey`**: `\u003CRequireOperation op=\"GET \u002Fclaims\" \u002F>`,\n`\u003CCan op=\"POST \u002Fme\u002Fclaims\">`. Every gate answers\n`canCall(OPERATIONS[op], scopes, signedIn)`: a `public` operation is always\ncallable, a `signedIn` one by any session, a `scope` one when the token holds\nthat handle. No component takes a handle; a handle typed into JSX is the stale\ngate nothing can see (§5).\n\n**Scope comparison is a whole-string match, everywhere.** A token carrying\n`claims:read-all` does NOT satisfy `claims:read`: the gateway does not treat one\nas a superset of the other, so neither may the SPA. A role that needs both holds\nboth.\n\n**`heldRoles()` is derived from scopes against `ROLE_GRANTS`** — a role whose\nEVERY grant is held. It is a label for the badge and for the copy that tells a\nuser what to ask for; it is never an input to a gate, it never comes from a\ngroups claim, and there is no default role. The `NoAccess` copy names the groups\nand the granting roles from `ROLE_ASSIGN_TO` \u002F `ROLE_ASSIGNABLE_BY`: no role\nname, group name or administrator is ever hardcoded in that page.\n\n### 4 · `src\u002Fauthz\u002Fclient.ts` — the 401 rule\n\n**The gateway answers 401 for every failure, missing scope included, and sends\nno `WWW-Authenticate`** — `api-management`'s status matrix owns that and why no\nsetting changes it. What follows for the SPA: nothing on the wire tells an\nexpired token from a refused permission, so **do not add a `WWW-Authenticate`\nread — there is nothing to read.**\n\nSo the SPA absorbs it, in three places, and all three are already in the assets:\n\n1. **`gates.tsx` gates before it calls.** A screen whose load operation the\n   token does not unlock is never rendered, so that operation is never invoked.\n   That removes every routine case — and it is not sufficient alone: a typed\n   URL, a stale bundle or a race past a narrowed renew still reach the gateway.\n2. **`session.ts` exposes `tokenIsValid()`** — a pure, side-effect-free read of\n   the stored user's `expires_at` against the clock, with the 60 s grace. No\n   network, no renew, no sign-in, so the API client can call it on every\n   response without recursing into the thing it is deciding about. `expires_at`\n   is local and authoritative, and it is the only signal that tells the two\n   401s apart.\n3. **`client.ts` maps the answer**, through `classifyApiFailure`:\n\n| Answer | Outcome | Why |\n|---|---|---|\n| **401 + `tokenIsValid()`** | route to **Forbidden** | the session is fine, so the refusal is about scope — and the gateway cannot say so |\n| **401 + `!tokenIsValid()`** | **`signIn()`**, at most once per page load | the ordinary expired\u002Fabsent case |\n| **403** | **Forbidden, always** | no generated service answers 403 today, but an org API behind the same gateway may; signing in again cannot add a scope the caller's roles do not grant |\n\n`if (res.status === 401) signIn()` — what the previous revision of this skill\ntaught — is **DELETED**, and deleting it is the point of the file. It threw a\ncorrectly provisioned user who touched one operation their role does not grant\ninto an endless sign-in loop: sign in, succeed, call, 401, sign in.\n\n`signIn` is guarded to one call per page load: a screen firing several requests\nat once answers 401 several times over, and without the guard each answer starts\nits own redirect.\n\n**Wire the Forbidden route once, at the router root.** `client.ts` holds no\nrouter import; it takes the navigator. One component, rendered inside the router\nand above every route — `assets\u002FApp.example.tsx`'s `ForbiddenWiring`:\n\n```tsx\nconst navigate = useNavigate();\nuseEffect(() => setForbiddenNavigator(() => navigate(\"\u002Fforbidden\", { replace: true })), [navigate]);\n```\n\n`replace: true` keeps the refused URL out of the history, so Back does not walk\nthe user straight back into the same 403. Until that call lands, a refusal logs a\nnamed error rather than silently doing nothing — **this wiring is not optional**:\nwithout it every refusal the screen gate did not catch routes nowhere, which\nlooks exactly like a screen that renders nothing. Your per-service client — `src\u002Fapi.ts`, generated types and all — calls\n`apiFetch`\u002F`apiJson`, or, with an `openapi-fetch` client, `authorizationHeader()`\nand `classifyResponse()` from its middleware. It adds **nothing** of its own\nabout authorization.\n\n### 5 · `src\u002Fauthz\u002Fscreens.ts` — each screen names the operation it loads\n\n**A screen is gated on the operation it loads, and that operation is named\nonce, here.** The screen table is yours to write from the screens of\n`prototype.json`, in **rail order** (the order of the prototype's `AppShell`\n`nav`, then the screens it does not list). Each `label` is the screen's `name`,\nand the first reachable row is the landing screen:\n\n```ts\nexport const SCREEN_ROUTES: readonly ScreenRoute[] = [\n  { key: \"my-claims\", label: \"My claims\",    path: \"\u002Fclaims\u002Fmine\", loads: \"GET \u002Fme\u002Fclaims\" },\n  { key: \"submit\",    label: \"Submit claim\", path: \"\u002Fclaims\u002Fnew\",  loads: \"POST \u002Fme\u002Fclaims\" },\n  { key: \"approvals\", label: \"Approvals\",    path: \"\u002Fapprovals\",   loads: \"GET \u002Fclaims\" },\n];\n```\n\n`loads` is the operation the screen exists to perform, at the reach the screen\nshows: an every-row queue loads `GET \u002Fclaims`, a \"mine\" page loads\n`GET \u002Fme\u002Fclaims`. **A form that only writes names the operation its submit\nmakes** — it has no load call, but naming its one operation is what keeps the\nrail, the route guard and the button enabled from the same fact; leaving it\n`null` lets a caller reach a form whose only control they can never use.\n`loads: null` is reserved for a screen that needs no operation at all, which is\nrare. A screen the prototype draws on a bare `\u003CScreen>` root (Signed out, a\nlanding page) is `public: true` and is routed above the sign-in guard (§6). `reachableScreens(scopes, signedIn)` filters the table\nthrough `canCall`, and the rail, the landing redirect and `NoAccess` all read\nit.\n\n**Never retype a handle in JSX.** `scopes.has(\"claims:read\")` hand-written into\n`App.tsx` is a stale handle the moment the design moves, and nothing — not\n`tsc`, not the build gate, not the mock walk — can see that it went stale.\n`loads` is typed as `OperationKey`, the union the generator emits from the\ncontracts, so an operation the design renamed or dropped fails the type check\non the next `npm run gen`, which `build` runs first.\n\n**Fail loudly on a stale table.** The pattern checks every `loads` against\n`OPERATIONS` at module load and throws — in dev, in the walk and in the\ndeployed pod — so a committed table that outlived its contract cannot become a\nscreen nobody can reach and nobody notices. Do not soften that to a\n`console.warn` or a filter.\n\n### 6 · `src\u002FApp.tsx` — where each view sits is a routing rule\n\n| View | Where it goes | Why |\n|---|---|---|\n| `NoAccess` | **ABOVE** the shell route — returned *instead of* the shell | a caller who unlocks nothing gets no navbar and no empty sidebar. A rail with no items wrapped around \"you have no access\" tells the user less than the message alone |\n| `Forbidden` | **INSIDE** the shell, routed at `\u002Fforbidden` | the opposite case: the caller holds other scopes and has somewhere to go, so the rail stays |\n\nThis is a **routing-structure** rule, not styling. The natural thing to write —\nand what a real run wrote — is `NoAccess` inside `AppShell`'s `\u003COutlet \u002F>`; its\nown walk caught it. The test sits above the `\u003CRoutes>` that carry the shell:\n\n```tsx\nconst reachable = reachableScreens(scopes, true);\nif (reachable.length === 0) return \u003CNoAccess appName={APP_NAME} \u002F>;   \u002F\u002F no shell around it\nreturn \u003CRoutes>\u003CRoute element={\u003CAppShell \u002F>}>…\u003C\u002FRoute>\u003C\u002FRoutes>;\n```\n\nThe rest of the structure, from `assets\u002FApp.example.tsx`: `\u002Fcallback` is routed\n**outside** the provider (there is no session to read until the redirect has been\nprocessed); every route whose screen `loads` an operation is wrapped in\n`\u003CRequireOperation op={screen.loads} screen={screen.label}>`; the landing route\nredirects to the first **reachable** screen in `SCREEN_ROUTES` order.\n\n- `loads: \"\u003Coperation>\"` → `\u003CRequireOperation op={…}>` around the route and\n  `\u003CCan op={…}>` around its nav item.\n- `loads: null` → any signed-in caller; no guard. Rare — a form names its submit operation instead.\n- `public: true` (a screen on a bare `\u003CScreen>` root) → reachable before\n  sign-in; keep it outside the sign-in gate entirely. `App.example.tsx` routes\n  those screens **above** `SignedIn`, still inside `AuthzProvider` (so `\u003CCan>`\n  and `useScopes()` work on them) and outside `AppShell` — a visitor with no\n  session has no signed-in chrome to draw. A public screen routed inside the\n  guard is unreachable by the visitor it exists for, because the guard\n  redirects them to the IdP first.\n\n**The rail is ONE rail whose items are each wrapped in `Can`.** The prototype\ndraws the rail of one role at a time; a single gated rail reproduces every one\nof those pictures and also covers the case the prototype cannot draw —\nsomebody holding two roles, who sees the union.\n\n**A reachable screen with nothing in it shows its empty state**, not Forbidden,\nand a region whose operation the viewing role cannot call renders its own\nforbidden state rather than vanishing. The UI never turns away a user the API\nwould serve.\n\n**`\u002Fforbidden` and `NoAccess` are platform-prescribed views.** They appear in no\nprototype and they are the carve-out from \"no invented screens\"\n(`prototype`'s `references\u002Fimplementing.md` says the same); their absence is a\ndefect even though no prototype draws them.\n\n---\n\n# Backend authorization\n\n**The operation's scope is enforced at the gateway, and nowhere else.** Every\nprotected operation in `openapi.yaml` declares exactly one scope, or none; the\ngateway is rendered from that same contract and refuses a caller who lacks the\nhandle before your service is reached. A generated service therefore holds **no\noperation → scope table, in any stack**. `api-management` owns the argument.\n\nWhat a gateway cannot do is prove to your code that a request came through it.\nSo it mints a short-lived JWT of the caller it authenticated, signs it with the\nenvironment's own key, and puts it on the upstream request — and your service\nverifies that signature. That is the whole of backend authentication.\n\n## Verify the assertion: one copied asset, wired once\n\n| Stack | Asset | Wiring |\n|---|---|---|\n| Go | `$AEP_SKILLS_DIR\u002Fgo\u002Fassets\u002Fgateway_assertion.go` | `auth.NewVerifierFromEnv()` in `main` (fatal on error) + `r.Use(verifier.Middleware)` |\n| Ballerina | `$AEP_SKILLS_DIR\u002Fballerina\u002Fassets\u002Fgateway_assertion.bal` | `http:InterceptableService` + `createInterceptors() returns AssertionInterceptor` |\n\nBoth read the same three variables, which the platform sets on the container\nwhen the environment's gateway publishes a keypair:\n`GATEWAY_ASSERTION_CERTIFICATE`, `GATEWAY_ASSERTION_ISSUER`,\n`GATEWAY_ASSERTION_HEADER`. **A partial trio stops the service from starting**,\nin both stacks, on purpose: a service that starts on half of them cannot tell a\nreal caller from a forged one, and a half-configured assertion is a broken\ndeployment rather than an unconfigured one. All three **absent** is a separate\nand temporary case — an environment gateway provisioned before the backend-JWT\nkeypair existed sets none of them, and the asset then reads the caller without\nverifying any signature and warns on every boot. That fallback is tracked for\nremoval in issue #789; author nothing that relies on it.\n\n**You author no new check.** The asset verifies the signature, pins the issuer\nto the gateway (never the IdP), checks the expiry and puts the caller on the\nrequest context. A handler reads the caller from there and nothing else.\n\nThree outcomes, and the middle one is the point:\n\n```\nno assertion                 → continue with no caller    # a public operation has none\npresent but not verifiable   → 401, immediately           # never \"anonymous\"\nverified                     → continue with the caller\n```\n\nDowngrading an unverifiable assertion to an anonymous request would make forging\none strictly better for an attacker than sending none.\n\n**The SPA sees only 401s** — the gateway answers 401 for a missing scope exactly\nas for a dead token, so §4's `classifyResponse()` sends a 401 with a still-valid\ntoken to Forbidden. Nothing in the service answers 403.\n\n## Reach is the path, not a check in the handler\n\nA handler holds **no authorization logic**. Whether the operation may be called\nwas settled at the gateway from the contract; which rows it returns was settled\nby its path. So there are exactly two shapes of handler, and neither branches\non a scope:\n\n```\nGET \u002Fme\u002Fclaims        →  rows := claims.where(owner_id = caller.sub)\nGET \u002Fme\u002Fteam\u002Fclaims   →  rows := claims.where(owner_id in reports_of(caller.sub))\nGET \u002Fclaims           →  rows := claims.all()\nPOST \u002Fme\u002Fclaims       →  claim.owner_id = caller.sub   \u002F\u002F stamped, never read from the body\n```\n\n`hasScope` (Go: `auth.HasScope`; Ballerina: `hasScope(caller, …)`) exists for\nthe rare handler that needs a second fact about the caller for something other\nthan authorization — a header badge, an audit line. If you are reaching for it\nto decide which rows to return, the design has one operation where it needs\ntwo: report that, do not code around it.\n\n**A row that exists but is not the caller's is a 404, not a 403** — a caller who\nmay not see a row may not learn it exists (`api-management` owns that rule).\nUnder `\u002Fme\u002F…` that is not a special case: the row is simply not in the caller's\ncollection.\n\n## Identity is not authorization\n\n- **What may they do** was answered at the gateway, from the contract, and\n  **which rows** by the operation's path. Inside the service the assertion's\n  `scope` claim decides nothing. There is no group matching, no substring match\n  on a role name, no role column in your own table, and no cold-start default.\n- **Which rows are theirs** is the assertion's `sub` — an opaque IdP subject,\n  and the one key for rows this service creates. Stamp it on every row a\n  `\u002Fme\u002F…` operation creates, and resolve every `\u002Fme\u002F…` query through it.\n- **Directory attributes** (their unit, their own id in some other system) come\n  from the caller's directory record, resolved by their username. A username can\n  be renamed, so look the record UP by it and never store it as a row key. Never\n  match `sub` against a record id another system minted, and never parse an\n  attribute out of a group name. A username that resolves to no record is a\n  refusal. The directory's real endpoint, its username field, and the dependency\n  wiring are org-specific — `internal-services` owns them; do not hardcode a\n  roster.\n\n## The service's own per-caller rows\n\nRows this service creates for a caller — their claim, their draft, their\npreferences — are keyed on the assertion's `sub`, the one case where that is\nright, because the service stored the subject itself rather than matching it\nagainst ids another system minted. **Store no role column and no permission\ncolumn**: the token already answered that, and a second copy is a second\nauthority that drifts.\n\nExpress this in your stack's own idiom — where the verifier is wired, where the\nshared helper lives, and how a handler returns 401 — following the conventions\nthat skill already sets.\n\n---\n\n## Pitfalls\n\n| Symptom | Cause | Fix |\n|---|---|---|\n| The service will not start: `…must be set together or not at all` | Some of the three are set, not all | Set all three from a throwaway keypair locally; in a cell, the environment's gateway needs provisioning. |\n| Every request 401s right after a deploy | The environment's gateway was re-provisioned; this component still holds the previous certificate | Redeploy the component — the certificate rides its ReleaseBinding. |\n| A forged request is served as an anonymous caller | An unverifiable assertion was treated as \"no caller\" | A present-but-invalid assertion is always a 401. |\n| Signed-in user loops back to the login page forever, ~160 ms per cycle | `if (res.status === 401) signIn()` in the API client: the gateway answers 401 for a missing scope exactly as for a dead token | The 401 rule — 401 + `tokenIsValid()` ⇒ Forbidden; only an absent\u002Fexpired token signs in. Copy `src\u002Fauthz\u002Fclient.ts` from the assets. |\n| Sign-in succeeds, looks perfectly healthy, and EVERY `\u002Fapi` call 401s | The token's `aud` is not this project's resource server — `resource` missing from one of the three legs | Set all three: `settings.resource`, `extraTokenParams`, and the `signinSilent({ resource, … })` argument. |\n| `tsc` is green but a screen is gated on an operation the contract dropped, or a new handle reaches nothing | `operations.gen.ts` is stale, or a handle was retyped as a string literal in JSX | `build` is `npm run gen && tsc --noEmit && vite build`; gate on `loads` through `src\u002Fauthz\u002Fscreens.ts`, never from a literal. |\n| A role opens its own screen and the screen's list call answers 401, or the screen is hidden for the role it exists for | The role's `grants` lack the handle of the operation the screen **loads** — whole-string match, so `x:read-all` (`GET \u002Fx`) is not `x:read` (`GET \u002Fme\u002Fx`); or `loads` names the wrong reach for the screen | A design finding: report the role, the screen and the handle. Never widen `loads`, a mock or a guard to hide it. |\n| `TS2353: 'useRefreshToken' \u002F 'clockSkewInSeconds' does not exist in type 'UserManagerSettings'` | Neither is a member in oidc-client-ts 3.5.0 | Delete both. `automaticSilentRenew: true` drives the refresh grant; the expiry grace is the asset's own `CLOCK_SKEW_SECONDS`. |\n| The header badge is empty for a user who clearly has a role | Code read `user.profile.groups` | `heldRoles()` — the roles whose EVERY grant is in the token's `scope`. |\n| \"You have no access\" is drawn with a navbar and an empty sidebar around it | `NoAccess` was rendered through `AppShell`'s `\u003COutlet \u002F>` | Return it ABOVE the shell route; `Forbidden` is the one that stays inside. |\n| A role-scoped caller signs in but sees no rows | The SPA called `\u002Fme\u002F…` for a role whose screen lists every row, or the handler matched `sub` against a directory id | The screen calls the operation whose path is its reach (`\u002Fclaims` for an every-row queue); resolve directory records by username. |\n| A caller holding `claims:read-all` is refused `GET \u002Fme\u002Fclaims` | Scope comparison is an exact string match; `claims:read-all` guards `GET \u002Fclaims`, a different operation | The SPA calls the operation the role's handle guards. If the role genuinely needs both views, the design grants both handles — report it; do not special-case it in code. |\n| A public endpoint trusts an identity | A public operation has no policy, so every inbound header is the caller's own and no assertion is minted | A handler behind `security: []` reads no identity at all. |\n| A newly granted permission does not show up for a user who is already signed in | A refresh narrows but never widens — RFC 6749 §6 | Sign out and in again; a removed grant, by contrast, disappears at the next renew. |\n| Sign-in loops at the right path, or the user is sent to login on every visit \u002F new tab | No persistent `WebStorageStateStore` (the in-memory default loses the PKCE verifier across the redirect), session in `sessionStorage`, or the load path calls `signIn()` on a merely-expired token | `WebStorageStateStore({ store: localStorage })` + `automaticSilentRenew`; renew via `signinSilent()` and only `signIn()` when there is no session. |\n| The splash (\"Checking your session…\") sits ~10 s on every signed-out visit before the IdP appears | `\u002Fcallback` calls `signinRedirectCallback()`, so the silent renew's hidden iframe never reports back and the parent waits out `silentRequestTimeoutInSeconds` — and a signed-out visitor was sent into that renew at all | `handleCallback()` → `signinCallback()`; `currentUser()` renews only what `sessionAction` calls `renew`. Both are in the assets. |\n| After login, \"invalid redirect URI\" | `redirect_uri` doesn't match the `\u003Corigin>\u002Fcallback` the platform registered | Compute `window.location.origin + '\u002Fcallback'`. |\n| Logout button does nothing | `signOut()` calls only `signoutRedirect()`, which rejects (no `end_session_endpoint`), and the handler swallows it | Wrap it in the try\u002Fcatch fallback to `removeUser()` + reload. |\n",{"name":5,"metadata":24,"description":7},{"aep":25},{"kind":26,"audience":27},"org",[28],"coding","main","e3b5fc8668f26761380b2d4965719f2d8f2eb246","skills\u002Fthunder-authentication","https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer","https:\u002F\u002Fgithub.com\u002Fwso2","https:\u002F\u002Fwso2.com","Welcome to the WSO2 source code! For info on working with the WSO2 repositories and contributing code, click the link below.","2026-11-11 15:36:27",{"source":8,"skillName":5,"commands":38,"prompt":48,"zipAvailable":49},[39,42,45],{"tool":40,"command":41},"npx","npx skills add wso2\u002Flabs-agentic-engineer --skill thunder-authentication",{"tool":43,"command":44},"bunx","bunx skills add wso2\u002Flabs-agentic-engineer --skill thunder-authentication",{"tool":46,"command":47},"pnpm","pnpm dlx skills add wso2\u002Flabs-agentic-engineer --skill thunder-authentication","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002FSKILL.md",true,[51,57,61,67,71,75,79,83,87,91,95,99,103,107,111,115,119,123,127,131],{"path":52,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":55,"sourceHtmlUrl":56},"assets\u002F__tests__\u002Fcore.cases.mjs","SCRIPT","脚本",12052,"https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002Fassets\u002F__tests__\u002Fcore.cases.mjs",{"path":58,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":59,"sourceHtmlUrl":60},"assets\u002F__tests__\u002Fcore.test.mjs",2540,"https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002Fassets\u002F__tests__\u002Fcore.test.mjs",{"path":62,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":65,"sourceHtmlUrl":66},"assets\u002F__tests__\u002Fexpense-tracker.mock-roles.gen.txt","ASSET","资产文件",711,"https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002Fassets\u002F__tests__\u002Fexpense-tracker.mock-roles.gen.txt",{"path":68,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":69,"sourceHtmlUrl":70},"assets\u002F__tests__\u002Fexpense-tracker.operations.gen.txt",1979,"https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002Fassets\u002F__tests__\u002Fexpense-tracker.operations.gen.txt",{"path":72,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":73,"sourceHtmlUrl":74},"assets\u002F__tests__\u002Fexpense-tracker.roles.gen.txt",1680,"https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002Fassets\u002F__tests__\u002Fexpense-tracker.roles.gen.txt",{"path":76,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":77,"sourceHtmlUrl":78},"assets\u002F__tests__\u002Fgen-authz.test.mjs",28437,"https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002Fassets\u002F__tests__\u002Fgen-authz.test.mjs",{"path":80,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":81,"sourceHtmlUrl":82},"assets\u002F__tests__\u002Fmock-contract.cases.mjs",6760,"https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002Fassets\u002F__tests__\u002Fmock-contract.cases.mjs",{"path":84,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":85,"sourceHtmlUrl":86},"assets\u002F__tests__\u002Fmock-contract.test.mjs",2650,"https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002Fassets\u002F__tests__\u002Fmock-contract.test.mjs",{"path":88,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":89,"sourceHtmlUrl":90},"assets\u002F__tests__\u002Fscreens.cases.mjs",7005,"https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002Fassets\u002F__tests__\u002Fscreens.cases.mjs",{"path":92,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":93,"sourceHtmlUrl":94},"assets\u002F__tests__\u002Fscreens.test.mjs",2048,"https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002Fassets\u002F__tests__\u002Fscreens.test.mjs",{"path":96,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":97,"sourceHtmlUrl":98},"assets\u002FApp.example.tsx",7952,"https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002Fassets\u002FApp.example.tsx",{"path":100,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":101,"sourceHtmlUrl":102},"assets\u002Fapp\u002Fmock\u002Fauthz\u002Fcontract.ts",7879,"https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002Fassets\u002Fapp\u002Fmock\u002Fauthz\u002Fcontract.ts",{"path":104,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":105,"sourceHtmlUrl":106},"assets\u002Fapp\u002Fmock\u002Fauthz\u002Fgateway.ts",8303,"https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002Fassets\u002Fapp\u002Fmock\u002Fauthz\u002Fgateway.ts",{"path":108,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":109,"sourceHtmlUrl":110},"assets\u002Fapp\u002Fmock\u002Fauthz\u002Fsession.ts",9384,"https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002Fassets\u002Fapp\u002Fmock\u002Fauthz\u002Fsession.ts",{"path":112,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":113,"sourceHtmlUrl":114},"assets\u002Fapp\u002Fscripts\u002Fgen-authz.mjs",24351,"https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002Fassets\u002Fapp\u002Fscripts\u002Fgen-authz.mjs",{"path":116,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":117,"sourceHtmlUrl":118},"assets\u002Fapp\u002Fsrc\u002Fauthz\u002Fclient.ts",6922,"https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002Fassets\u002Fapp\u002Fsrc\u002Fauthz\u002Fclient.ts",{"path":120,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":121,"sourceHtmlUrl":122},"assets\u002Fapp\u002Fsrc\u002Fauthz\u002Fcore.ts",10402,"https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002Fassets\u002Fapp\u002Fsrc\u002Fauthz\u002Fcore.ts",{"path":124,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":125,"sourceHtmlUrl":126},"assets\u002Fapp\u002Fsrc\u002Fauthz\u002Fgates.tsx",11781,"https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002Fassets\u002Fapp\u002Fsrc\u002Fauthz\u002Fgates.tsx",{"path":128,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":129,"sourceHtmlUrl":130},"assets\u002Fapp\u002Fsrc\u002Fauthz\u002Fsession.ts",8989,"https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002Fassets\u002Fapp\u002Fsrc\u002Fauthz\u002Fsession.ts",{"path":132,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":133,"sourceHtmlUrl":134},"assets\u002Fscreens.example.ts",7064,"https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fthunder-authentication\u002Fassets\u002Fscreens.example.ts",[136,143,150,157,164,171],{"skillNo":137,"name":138,"nameZh":6,"description":139,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":140,"categories":141,"keywords":142,"publishedAt":19},"01M735MP9NFFRPS260G9D16JQX","validation-task","Load when working a VALIDATION task dispatched by WSO2 Labs Agentic Engineer — judging a deployed version against its acceptance criteria.","https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fvalidation-task\u002FSKILL.md",[],[],{"skillNo":144,"name":145,"nameZh":6,"description":146,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":147,"categories":148,"keywords":149,"publishedAt":19},"01M735MFQMY8DY1EM7JKS784D3","task-planning","Use when planning a version's build from a design — the plan turn that writes the build's checklist with planBuild, one item per feature the version carries in build order, after a Foundation item when the version needs one.","https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Ftask-planning\u002FSKILL.md",[],[],{"skillNo":151,"name":152,"nameZh":6,"description":153,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":154,"categories":155,"keywords":156,"publishedAt":19},"01M735MCJQ4EVH7G4ZFMC682Y4","start","Use when kicking off a project from its idea — the product pass that agrees the feature list and writes the product page, the product-wide page and a stub per feature — or re-running \u002Fstart on a project that already has requirements.","https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fstart\u002FSKILL.md",[],[],{"skillNo":158,"name":159,"nameZh":6,"description":160,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":161,"categories":162,"keywords":163,"publishedAt":19},"01M735M9R050KT3H34PVXN2MKK","security-design","Write specs\u002Fdesign\u002Fsecurity.json when a design has sign-in, permissions, roles or test users — the permission catalog every API operation is gated on.","https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fsecurity-design\u002FSKILL.md",[],[],{"skillNo":165,"name":166,"nameZh":6,"description":167,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":168,"categories":169,"keywords":170,"publishedAt":19},"01M735M60CTW4S7XMS6XCX9A7Y","resolve-dependency","Use for taking one external dependency from open to resolved — `\u002Fresolve-dependency \u003Cname> [answer]` names it and may carry the provider the user chose; `\u002Fresolve-dependencies` walks every open one in turn. Ask which provider (their suggestions as options; never choose for them), get its interface on disk (found, uploaded from the card, or assumed under the authorization the card records), then derive the config keys.","https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fresolve-dependency\u002FSKILL.md",[],[],{"skillNo":172,"name":173,"nameZh":6,"description":174,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":175,"categories":176,"keywords":177,"publishedAt":19},"01M735M3Z74SVFNVXZB7R64NQB","register-external-resource","Use when registering a Registered External resource from Marketplace chat (`\u002Fregister-external-resource`).","https:\u002F\u002Fgithub.com\u002Fwso2\u002Flabs-agentic-engineer\u002Fblob\u002Fmain\u002Fskills\u002Fregister-external-resource\u002FSKILL.md",[],[]]