This is an automated email from the ASF dual-hosted git repository.

lahirujayathilake pushed a commit to branch signer-connector
in repository https://gitbox.apache.org/repos/asf/airavata-custos.git

commit dbef982104d6cbda703da2b045fac9d38bc7f678
Author: lahiruj <[email protected]>
AuthorDate: Sun Nov 8 16:48:17 2026 -0500

    Route the certificate page through the signer connector
---
 web/.env.example                                   |  3 --
 web/playwright.signer.config.ts                    |  1 -
 .../certificates/CertificateListContainer.tsx      | 18 ++++---
 .../app/api/v1/[...path]/__tests__/route.test.ts   | 59 +++++++---------------
 web/src/app/api/v1/[...path]/route.ts              | 27 ++--------
 .../core/signer/__tests__/CertificateList.test.tsx | 45 ++++++++++-------
 web/src/features/core/signer/__tests__/api.test.ts | 16 +++---
 .../features/core/signer/__tests__/queries.test.ts |  2 +-
 .../features/core/signer/__tests__/schemas.test.ts |  8 ++-
 web/src/features/core/signer/api.ts                | 10 ++--
 .../core/signer/components/CertificateList.tsx     | 59 +++++++++++++++-------
 web/src/features/core/signer/schemas.ts            |  6 +--
 web/src/features/core/signer/types.ts              | 14 +++--
 web/src/lib/env.ts                                 |  1 -
 web/src/mocks/handlers/signer.ts                   | 16 +++---
 web/tests/fixtures/signer-api.ts                   | 15 +++---
 web/tests/signer-certificates.e2e.ts               | 11 ++--
 17 files changed, 154 insertions(+), 157 deletions(-)

diff --git a/web/.env.example b/web/.env.example
index b41ce111e..dc66bda23 100644
--- a/web/.env.example
+++ b/web/.env.example
@@ -26,9 +26,6 @@ NEXTAUTH_URL=http://localhost:3000
 # Custos backend
 CUSTOS_CORE_API_BASE_URL=http://localhost:8080
 
-# Custos SSH Certificate Signer
-CUSTOS_SIGNER_API_BASE_URL=http://localhost:8084
-
 # OIDC (required).
 #
 # Defaults point at the bundled Keycloak from dev-ops/compose; users seeded
diff --git a/web/playwright.signer.config.ts b/web/playwright.signer.config.ts
index 147c59827..670403e87 100644
--- a/web/playwright.signer.config.ts
+++ b/web/playwright.signer.config.ts
@@ -50,7 +50,6 @@ export default defineConfig({
     env: {
       PORT: String(port),
       NEXT_PUBLIC_PORTAL_USE_MSW: "false",
-      CUSTOS_E2E_FAIL_ON_SIGNER_PROXY_REQUEST: "true",
       NEXTAUTH_SECRET: sharedSecret,
       NEXTAUTH_URL: baseURL,
       OIDC_ISSUER_URL: "http://localhost:8081/realms/custos";,
diff --git 
a/web/src/app/(portal)/admin/signer/certificates/CertificateListContainer.tsx 
b/web/src/app/(portal)/admin/signer/certificates/CertificateListContainer.tsx
index 6dde163dd..53092a6a4 100644
--- 
a/web/src/app/(portal)/admin/signer/certificates/CertificateListContainer.tsx
+++ 
b/web/src/app/(portal)/admin/signer/certificates/CertificateListContainer.tsx
@@ -35,7 +35,8 @@ function statusFilterFromUrl(raw: string | null): 
CertificateStatus | "all" {
 
 export function CertificateListContainer() {
   const searchParams = useShallowSearchParams();
-  const [page, setPage] = React.useState(1);
+  // The cursor of each page after the first, so Previous can walk back.
+  const [cursors, setCursors] = React.useState<string[]>([]);
   const [pageSize, setPageSize] = React.useState(20);
 
   const search = searchParams.get("q") ?? "";
@@ -51,9 +52,9 @@ export function CertificateListContainer() {
     [searchParams],
   );
 
-  const query = useCertificates({ limit: pageSize, offset: (page - 1) * 
pageSize });
+  const query = useCertificates({ limit: pageSize, cursor: cursors.at(-1) });
   const rows = query.data?.certificates ?? [];
-  const total = query.data?.total ?? 0;
+  const nextCursor = query.data?.next_cursor;
 
   return (
     <CertificateList
@@ -65,13 +66,14 @@ export function CertificateListContainer() {
       onSearchChange={(next) => updateParam("q", next)}
       statusFilter={statusFilter}
       onStatusFilterChange={(next) => updateParam("status", next === "all" ? 
null : next)}
-      pagination={{
-        page,
+      paging={{
+        page: cursors.length + 1,
         pageSize,
-        total,
-        onPageChange: setPage,
+        hasNext: Boolean(nextCursor),
+        onNext: () => nextCursor && setCursors((prev) => [...prev, 
nextCursor]),
+        onPrevious: () => setCursors((prev) => prev.slice(0, -1)),
         onPageSizeChange: (next) => {
-          setPage(1);
+          setCursors([]);
           setPageSize(next);
         },
       }}
diff --git a/web/src/app/api/v1/[...path]/__tests__/route.test.ts 
b/web/src/app/api/v1/[...path]/__tests__/route.test.ts
index ef31cd741..ddf11b5ea 100644
--- a/web/src/app/api/v1/[...path]/__tests__/route.test.ts
+++ b/web/src/app/api/v1/[...path]/__tests__/route.test.ts
@@ -24,7 +24,6 @@ import { pickBackendBearer } from "@/shared/auth/session";
 vi.mock("@/lib/env", () => ({
   serverEnv: {
     CUSTOS_CORE_API_BASE_URL: "https://core.example.org";,
-    CUSTOS_SIGNER_API_BASE_URL: "https://signer.example.org";,
   },
 }));
 
@@ -58,27 +57,27 @@ describe("responseBodyForStatus", () => {
 });
 
 describe("api v1 proxy route", () => {
-  it("routes the signer namespace to the signer API without changing Core 
routing", async () => {
+  it("forwards the path, query, bearer and trace id to core", async () => {
     fetchMock.mockResolvedValueOnce(
       new Response(JSON.stringify({ certificates: [] }), {
         status: 200,
-        headers: { "content-type": "application/json", "x-trace-id": 
"trace-signer-1" },
+        headers: { "content-type": "application/json", "x-trace-id": "trace-1" 
},
       }),
     );
 
     const response = await GET(
-      new 
NextRequest("http://localhost:3000/api/v1/signer/admin/certificates?limit=20";),
-      { params: Promise.resolve({ path: ["signer", "admin", "certificates"] }) 
},
+      new 
NextRequest("http://localhost:3000/api/v1/connectors/signer/certificates?limit=20";),
+      { params: Promise.resolve({ path: ["connectors", "signer", 
"certificates"] }) },
     );
 
     expect(response.status).toBe(200);
     const [url, init] = fetchMock.mock.calls[0] ?? [];
-    
expect(String(url)).toBe("https://signer.example.org/api/v1/admin/certificates?limit=20";);
+    
expect(String(url)).toBe("https://core.example.org/connectors/signer/certificates?limit=20";);
     expect(new Headers(init?.headers).get("authorization")).toBe("Bearer 
access-token-abc");
-    expect(response.headers.get("x-trace-id")).toBe("trace-signer-1");
+    expect(response.headers.get("x-trace-id")).toBe("trace-1");
   });
 
-  it("forwards signer request bodies and query parameters", async () => {
+  it("forwards request bodies and content type", async () => {
     fetchMock.mockResolvedValueOnce(
       new Response(JSON.stringify({ success: true }), {
         status: 200,
@@ -87,18 +86,16 @@ describe("api v1 proxy route", () => {
     );
 
     await POST(
-      new 
NextRequest("http://localhost:3000/api/v1/signer/admin/certificates/42/revoke?audit=true";,
 {
+      new 
NextRequest("http://localhost:3000/api/v1/connectors/signer/certificates/42/revoke";,
 {
         method: "POST",
         body: JSON.stringify({ reason: "compromised" }),
         headers: { "content-type": "application/json", accept: 
"application/json" },
       }),
-      { params: Promise.resolve({ path: ["signer", "admin", "certificates", 
"42", "revoke"] }) },
+      { params: Promise.resolve({ path: ["connectors", "signer", 
"certificates", "42", "revoke"] }) },
     );
 
     const [url, init] = fetchMock.mock.calls[0] ?? [];
-    expect(String(url)).toBe(
-      
"https://signer.example.org/api/v1/admin/certificates/42/revoke?audit=true";,
-    );
+    
expect(String(url)).toBe("https://core.example.org/connectors/signer/certificates/42/revoke";);
     expect(init?.body).toBe(JSON.stringify({ reason: "compromised" }));
     expect(new 
Headers(init?.headers).get("content-type")).toBe("application/json");
   });
@@ -126,8 +123,8 @@ describe("api v1 proxy route", () => {
     vi.mocked(pickBackendBearer).mockReturnValueOnce(null);
 
     const response = await GET(
-      new 
NextRequest("http://localhost:3000/api/v1/signer/admin/certificates";),
-      { params: Promise.resolve({ path: ["signer", "admin", "certificates"] }) 
},
+      new NextRequest("http://localhost:3000/api/v1/roles/role-1/privileges";),
+      ctx,
     );
 
     expect(response.status).toBe(401);
@@ -138,13 +135,13 @@ describe("api v1 proxy route", () => {
     expect(fetchMock).not.toHaveBeenCalled();
   });
 
-  it("returns a sanitized 503 when the selected upstream is unavailable", 
async () => {
+  it("returns a sanitized 503 when core is unavailable", async () => {
     const consoleError = vi.spyOn(console, "error").mockImplementation(() => 
undefined);
     fetchMock.mockRejectedValueOnce(new TypeError("fetch failed for secret 
upstream URL"));
 
     const response = await GET(
-      new 
NextRequest("http://localhost:3000/api/v1/signer/admin/certificates?limit=20";),
-      { params: Promise.resolve({ path: ["signer", "admin", "certificates"] }) 
},
+      new 
NextRequest("http://localhost:3000/api/v1/roles/role-1/privileges?limit=20";),
+      ctx,
     );
 
     expect(response.status).toBe(503);
@@ -153,33 +150,11 @@ describe("api v1 proxy route", () => {
       message: "Backend service is unavailable",
     });
     expect(consoleError).toHaveBeenCalledWith("API proxy upstream 
unavailable", {
-      service: "signer",
       method: "GET",
-      path: "/api/v1/admin/certificates",
+      path: "/roles/role-1/privileges",
     });
     
expect(JSON.stringify(consoleError.mock.calls)).not.toContain("access-token-abc");
-    
expect(JSON.stringify(consoleError.mock.calls)).not.toContain("signer.example.org");
+    
expect(JSON.stringify(consoleError.mock.calls)).not.toContain("core.example.org");
     expect(JSON.stringify(consoleError.mock.calls)).not.toContain("secret 
upstream URL");
   });
-
-  it("fails explicitly if a hermetic signer E2E request reaches the proxy", 
async () => {
-    vi.stubEnv("CUSTOS_E2E_FAIL_ON_SIGNER_PROXY_REQUEST", "true");
-    const consoleError = vi.spyOn(console, "error").mockImplementation(() => 
undefined);
-
-    const response = await GET(
-      new 
NextRequest("http://localhost:3000/api/v1/signer/admin/certificates";),
-      { params: Promise.resolve({ path: ["signer", "admin", "certificates"] }) 
},
-    );
-
-    expect(response.status).toBe(500);
-    expect(await response.json()).toEqual({
-      code: "unexpected_signer_proxy_request",
-      message: "Signer E2E request escaped its Playwright route",
-    });
-    expect(fetchMock).not.toHaveBeenCalled();
-    expect(consoleError).toHaveBeenCalledWith(
-      "Unexpected signer proxy request during hermetic E2E",
-      { method: "GET", path: "/api/v1/signer/admin/certificates" },
-    );
-  });
 });
diff --git a/web/src/app/api/v1/[...path]/route.ts 
b/web/src/app/api/v1/[...path]/route.ts
index f68188679..c940b2eaf 100644
--- a/web/src/app/api/v1/[...path]/route.ts
+++ b/web/src/app/api/v1/[...path]/route.ts
@@ -26,25 +26,8 @@ type Context = { params: Promise<{ path: string[] }> };
 
 async function proxy(request: NextRequest, ctx: Context) {
   const { path } = await ctx.params;
-  const isSigner = path[0] === "signer";
-  if (isSigner && process.env["CUSTOS_E2E_FAIL_ON_SIGNER_PROXY_REQUEST"] === 
"true") {
-    console.error("Unexpected signer proxy request during hermetic E2E", {
-      method: request.method,
-      path: request.nextUrl.pathname,
-    });
-    return NextResponse.json(
-      {
-        code: "unexpected_signer_proxy_request",
-        message: "Signer E2E request escaped its Playwright route",
-      },
-      { status: 500 },
-    );
-  }
-  const upstreamBase = isSigner
-    ? serverEnv.CUSTOS_SIGNER_API_BASE_URL
-    : serverEnv.CUSTOS_CORE_API_BASE_URL;
-  const upstreamPath = isSigner ? `/api/v1/${path.slice(1).join("/")}` : 
`/${path.join("/")}`;
-  const upstreamUrl = new URL(upstreamPath, upstreamBase);
+  const upstreamPath = `/${path.join("/")}`;
+  const upstreamUrl = new URL(upstreamPath, 
serverEnv.CUSTOS_CORE_API_BASE_URL);
   upstreamUrl.search = request.nextUrl.search;
 
   const session = await getPortalSession();
@@ -75,11 +58,7 @@ async function proxy(request: NextRequest, ctx: Context) {
       cache: "no-store",
     });
   } catch {
-    console.error("API proxy upstream unavailable", {
-      service: isSigner ? "signer" : "core",
-      method,
-      path: upstreamPath,
-    });
+    console.error("API proxy upstream unavailable", { method, path: 
upstreamPath });
     return NextResponse.json(
       { code: "upstream_unavailable", message: "Backend service is 
unavailable" },
       { status: 503 },
diff --git a/web/src/features/core/signer/__tests__/CertificateList.test.tsx 
b/web/src/features/core/signer/__tests__/CertificateList.test.tsx
index fd4c38160..da06e84d0 100644
--- a/web/src/features/core/signer/__tests__/CertificateList.test.tsx
+++ b/web/src/features/core/signer/__tests__/CertificateList.test.tsx
@@ -71,10 +71,7 @@ describe("<CertificateList />", () => {
   });
 
   it("distinguishes no matches on a loaded page from no certificates", () => {
-    renderList({
-      rows: [],
-      pagination: { page: 1, pageSize: 20, total: 25, onPageChange: vi.fn() },
-    });
+    renderList({ rows: [active], search: "not-present" });
     expect(screen.getByRole("heading", { name: /no matches on this page/i 
})).toBeInTheDocument();
   });
 
@@ -112,19 +109,33 @@ describe("<CertificateList />", () => {
     expect(props.onStatusFilterChange).toHaveBeenCalledWith("revoked");
   });
 
-  it("renders accurate totals and invokes pagination callbacks", () => {
-    const onPageChange = vi.fn();
-    const onPageSizeChange = vi.fn();
-    renderList({
-      pagination: { page: 1, pageSize: 20, total: 41, onPageChange, 
onPageSizeChange },
-    });
-    expect(screen.getByText(/Showing 1.+20 of 41/)).toBeInTheDocument();
-    fireEvent.click(screen.getByRole("button", { name: /next/i }));
-    fireEvent.change(screen.getByRole("combobox", { name: /rows per page/i }), 
{
-      target: { value: "50" },
-    });
-    expect(onPageChange).toHaveBeenCalledWith(2);
-    expect(onPageSizeChange).toHaveBeenCalledWith(50);
+  const paging = {
+    page: 1,
+    pageSize: 20,
+    hasNext: true,
+    onPrevious: vi.fn(),
+    onNext: vi.fn(),
+    onPageSizeChange: vi.fn(),
+  };
+
+  // Make sure the first page cannot go back.
+  it("disables Previous on the first page", () => {
+    renderList({ paging });
+    expect(screen.getByRole("button", { name: /previous/i })).toBeDisabled();
+    expect(screen.getByRole("button", { name: /next/i })).toBeEnabled();
+  });
+
+  // Make sure a page without a next cursor is treated as the last page.
+  it("disables Next when the signer sends no next cursor", () => {
+    renderList({ paging: { ...paging, page: 2, hasNext: false } });
+    expect(screen.getByRole("button", { name: /next/i })).toBeDisabled();
+    expect(screen.getByRole("button", { name: /previous/i })).toBeEnabled();
+  });
+
+  // Make sure a filter that empties the page can still move to the next page.
+  it("keeps the pager when no row on the page matches", () => {
+    renderList({ rows: [active], search: "not-present", paging });
+    expect(screen.getByRole("button", { name: /next/i })).toBeEnabled();
   });
 
   it("surfaces an error state with a retry callback", () => {
diff --git a/web/src/features/core/signer/__tests__/api.test.ts 
b/web/src/features/core/signer/__tests__/api.test.ts
index 44ae3d36a..43dcf856f 100644
--- a/web/src/features/core/signer/__tests__/api.test.ts
+++ b/web/src/features/core/signer/__tests__/api.test.ts
@@ -45,17 +45,17 @@ const certificate = {
 };
 
 describe("listCertificates", () => {
-  it("round-trips pagination and returns the envelope", async () => {
+  it("sends the cursor and returns the next one", async () => {
     fetchMock.mockResolvedValueOnce(
-      mockResponse(200, { certificates: [certificate], total: 1, limit: 20, 
offset: 0 }),
+      mockResponse(200, { certificates: [certificate], limit: 20, next_cursor: 
"c2" }),
     );
-    const result = await listCertificates({ limit: 20, offset: 0 });
-    expect(result.total).toBe(1);
+    const result = await listCertificates({ limit: 20, cursor: "c1" });
+    expect(result.next_cursor).toBe("c2");
     expect(result.certificates).toHaveLength(1);
     const url = fetchMock.mock.calls[0]?.[0] as string;
-    expect(url).toContain("/api/v1/signer/admin/certificates");
+    expect(url).toContain("/api/v1/connectors/signer/certificates");
     expect(url).toContain("limit=20");
-    expect(url).toContain("offset=0");
+    expect(url).toContain("cursor=c1");
   });
 });
 
@@ -64,7 +64,7 @@ describe("getCertificate", () => {
     fetchMock.mockResolvedValueOnce(mockResponse(200, certificate));
     const out = await getCertificate(42);
     expect(out.serial_number).toBe(42);
-    
expect(fetchMock.mock.calls[0]?.[0]).toContain("/api/v1/signer/admin/certificates/42");
+    
expect(fetchMock.mock.calls[0]?.[0]).toContain("/api/v1/connectors/signer/certificates/42");
   });
 });
 
@@ -85,7 +85,7 @@ describe("revokeCertificate", () => {
     expect(out.reason).toBe("compromised");
 
     const [url, init] = fetchMock.mock.calls[0] ?? [];
-    expect(url).toContain("/api/v1/signer/admin/certificates/42/revoke");
+    expect(url).toContain("/api/v1/connectors/signer/certificates/42/revoke");
     expect(init?.method).toBe("POST");
     const sent = JSON.parse(String(init?.body));
     expect(sent).toEqual({ reason: "compromised" });
diff --git a/web/src/features/core/signer/__tests__/queries.test.ts 
b/web/src/features/core/signer/__tests__/queries.test.ts
index d57c2feb1..61def87fc 100644
--- a/web/src/features/core/signer/__tests__/queries.test.ts
+++ b/web/src/features/core/signer/__tests__/queries.test.ts
@@ -36,7 +36,7 @@ describe("signerKeys", () => {
   });
 
   it("list key carries the params", () => {
-    const params = { limit: 20, offset: 0 };
+    const params = { limit: 20, cursor: "c1" };
     expect(signerKeys.list(params)).toEqual(["signer-certificates", "list", 
params]);
   });
 
diff --git a/web/src/features/core/signer/__tests__/schemas.test.ts 
b/web/src/features/core/signer/__tests__/schemas.test.ts
index 4ce5f7124..94f766a7e 100644
--- a/web/src/features/core/signer/__tests__/schemas.test.ts
+++ b/web/src/features/core/signer/__tests__/schemas.test.ts
@@ -32,10 +32,8 @@ describe("signer schemas", () => {
     expect(certificateSchema.parse(certificate)).toEqual(certificate);
   });
 
-  it("accepts a paginated certificate list", () => {
-    expect(
-      certificateListSchema.parse({ certificates: [certificate], total: 21, 
limit: 20, offset: 0 }),
-    ).toMatchObject({ total: 21, limit: 20, offset: 0 });
+  it("accepts a last page with no next cursor", () => {
+    expect(certificateListSchema.parse({ certificates: [], limit: 20 
}).next_cursor).toBeUndefined();
   });
 
   it("accepts an idempotent revoke response", () => {
@@ -56,7 +54,7 @@ describe("signer schemas", () => {
     ["certificate", { ...certificate, serial_number: "42" }, 
certificateSchema],
     [
       "list",
-      { certificates: [certificate], total: -1, limit: 20, offset: 0 },
+      { certificates: [certificate], limit: 20, next_cursor: 7 },
       certificateListSchema,
     ],
     [
diff --git a/web/src/features/core/signer/api.ts 
b/web/src/features/core/signer/api.ts
index 4b92efdf0..a71cee95b 100644
--- a/web/src/features/core/signer/api.ts
+++ b/web/src/features/core/signer/api.ts
@@ -15,8 +15,6 @@
 // specific language governing permissions and limitations
 // under the License.
 
-// Calls are namespaced under /signer so the portal proxy routes them to the
-// signer service with the administrator's Bearer token.
 import { apiFetch } from "@/shared/api/client";
 import {
   type Certificate,
@@ -33,21 +31,21 @@ export async function listCertificates(
 ): Promise<CertificateList> {
   const search = new URLSearchParams();
   if (typeof params.limit === "number") search.set("limit", 
String(params.limit));
-  if (typeof params.offset === "number") search.set("offset", 
String(params.offset));
+  if (params.cursor) search.set("cursor", params.cursor);
   const qs = search.toString();
-  const raw = await apiFetch(`/signer/admin/certificates${qs ? `?${qs}` : 
""}`);
+  const raw = await apiFetch(`/connectors/signer/certificates${qs ? `?${qs}` : 
""}`);
   return certificateListSchema.parse(raw);
 }
 
 export async function getCertificate(serial: number | string): 
Promise<Certificate> {
-  const raw = await apiFetch(`/signer/admin/certificates/${serial}`);
+  const raw = await apiFetch(`/connectors/signer/certificates/${serial}`);
   return certificateSchema.parse(raw);
 }
 
 // serial comes from the certificate; the backend keys revocation off the real
 // serial_number (never a key id or timestamp).
 export async function revokeCertificate(serial: number, reason: string): 
Promise<RevokeResponse> {
-  const raw = await apiFetch(`/signer/admin/certificates/${serial}/revoke`, {
+  const raw = await 
apiFetch(`/connectors/signer/certificates/${serial}/revoke`, {
     method: "POST",
     body: { reason },
   });
diff --git a/web/src/features/core/signer/components/CertificateList.tsx 
b/web/src/features/core/signer/components/CertificateList.tsx
index a8bd8cdc7..5b2e714a4 100644
--- a/web/src/features/core/signer/components/CertificateList.tsx
+++ b/web/src/features/core/signer/components/CertificateList.tsx
@@ -19,13 +19,15 @@
 
 import Link from "next/link";
 import * as React from "react";
-import { DataTable, type DataTableColumn, type DataTablePagination } from 
"@/shared/ui/DataTable";
+import { Button } from "@/shared/ui/button";
+import { DataTable, type DataTableColumn } from "@/shared/ui/DataTable";
 import { EmptyState } from "@/shared/ui/EmptyState";
 import { ErrorState } from "@/shared/ui/ErrorState";
 import { Input } from "@/shared/ui/input";
 import { TableSkeleton } from "@/shared/ui/Loading";
 import { StatusBadge } from "@/shared/ui/StatusBadge";
 import type { Certificate } from "../schemas";
+import type { CertificateListPaging } from "../types";
 import {
   CERTIFICATE_STATUS_LABELS,
   type CertificateStatus,
@@ -43,7 +45,7 @@ export type CertificateListProps = {
   onSearchChange: (next: string) => void;
   statusFilter: CertificateStatus | "all";
   onStatusFilterChange: (next: CertificateStatus | "all") => void;
-  pagination?: DataTablePagination;
+  paging?: CertificateListPaging;
 };
 
 export function CertificateList({
@@ -55,10 +57,8 @@ export function CertificateList({
   onSearchChange,
   statusFilter,
   onStatusFilterChange,
-  pagination,
+  paging,
 }: CertificateListProps) {
-  // Status/search narrow only the current server page; the signer API 
paginates
-  // by limit/offset and has no status filter, so deeper filtering is 
client-side.
   const filtered = React.useMemo(() => {
     const needle = search.trim().toLowerCase();
     return rows.filter((row) => {
@@ -160,25 +160,50 @@ export function CertificateList({
         <ErrorState message={error.message} onRetry={onRetry} />
       ) : filtered.length === 0 ? (
         <EmptyState
-          heading={
-            (pagination?.total ?? rows.length) === 0
-              ? "No certificates yet"
-              : "No matches on this page"
-          }
+          heading={rows.length === 0 ? "No certificates yet" : "No matches on 
this page"}
           description={
-            (pagination?.total ?? rows.length) === 0
+            rows.length === 0
               ? "The signer has not issued any certificates."
               : "No certificates on the loaded page match the current filters."
           }
         />
       ) : (
-        <DataTable
-          columns={columns}
-          rows={filtered}
-          rowKey={(row) => String(row.serial_number)}
-          {...(pagination !== undefined ? { pagination } : {})}
-        />
+        <DataTable columns={columns} rows={filtered} rowKey={(row) => 
String(row.serial_number)} />
       )}
+      {paging && !isLoading && (error || rows.length > 0) && <CursorPager 
{...paging} />}
+    </div>
+  );
+}
+
+// The DataTable pager needs a total. The signer sends none, so this one only 
goes forward and back.
+function CursorPager({ page, pageSize, hasNext, onPrevious, onNext, 
onPageSizeChange }: CertificateListPaging) {
+  return (
+    <div className="flex flex-col gap-3 text-sm text-muted-foreground 
sm:flex-row sm:items-center sm:justify-between">
+      <label className="flex items-center gap-2">
+        <span>Rows per page</span>
+        <select
+          value={pageSize}
+          onChange={(e) => onPageSizeChange(Number(e.target.value))}
+          className="h-8 rounded-md border border-border bg-background px-2 
text-xs"
+        >
+          {[10, 20, 50, 100].map((n) => (
+            <option key={n} value={n}>
+              {n}
+            </option>
+          ))}
+        </select>
+      </label>
+      <div className="flex items-center gap-2">
+        <Button variant="outline" size="sm" onClick={onPrevious} 
disabled={page <= 1}>
+          Previous
+        </Button>
+        <span aria-current="page" className="font-medium text-foreground">
+          Page {page}
+        </span>
+        <Button variant="outline" size="sm" onClick={onNext} 
disabled={!hasNext}>
+          Next
+        </Button>
+      </div>
     </div>
   );
 }
diff --git a/web/src/features/core/signer/schemas.ts 
b/web/src/features/core/signer/schemas.ts
index 58ba9b91a..a08fb0223 100644
--- a/web/src/features/core/signer/schemas.ts
+++ b/web/src/features/core/signer/schemas.ts
@@ -42,15 +42,15 @@ export const certificateSchema = z.object({
 });
 export type Certificate = z.infer<typeof certificateSchema>;
 
+// next_cursor is missing on the last page. The list has no total.
 export const certificateListSchema = z.object({
   certificates: z.array(certificateSchema),
-  total: z.number().int().nonnegative(),
   limit: z.number().int(),
-  offset: z.number().int(),
+  next_cursor: z.string().optional(),
 });
 export type CertificateList = z.infer<typeof certificateListSchema>;
 
-// Response from POST /signer/certificates/{serial}/revoke. already_revoked is
+// Response from POST /certificates/{serial}/revoke. already_revoked is
 // true when the certificate was revoked by a prior request (idempotent 
success).
 export const revokeResponseSchema = z.object({
   success: z.boolean(),
diff --git a/web/src/features/core/signer/types.ts 
b/web/src/features/core/signer/types.ts
index 02fadfb2c..7c43e01e9 100644
--- a/web/src/features/core/signer/types.ts
+++ b/web/src/features/core/signer/types.ts
@@ -15,9 +15,17 @@
 // specific language governing permissions and limitations
 // under the License.
 
-// The administrative signer list supports limit/offset. Search and status
-// filters are intentionally applied to the loaded page in the portal.
+// The signer has no search or status filter, so those apply to the loaded 
page only.
 export type CertificateListParams = {
   limit?: number;
-  offset?: number;
+  cursor?: string | undefined;
+};
+
+export type CertificateListPaging = {
+  page: number;
+  pageSize: number;
+  hasNext: boolean;
+  onPrevious: () => void;
+  onNext: () => void;
+  onPageSizeChange: (size: number) => void;
 };
diff --git a/web/src/lib/env.ts b/web/src/lib/env.ts
index e6ec12286..6114fe8f4 100644
--- a/web/src/lib/env.ts
+++ b/web/src/lib/env.ts
@@ -23,7 +23,6 @@ export const serverSchema = z.object({
   NEXTAUTH_URL: z.string().url().optional(),
 
   CUSTOS_CORE_API_BASE_URL: z.string().url().default("http://localhost:8080";),
-  CUSTOS_SIGNER_API_BASE_URL: 
z.string().url().default("http://localhost:8084";),
 
   OIDC_ISSUER_URL: z.string().url(),
   OIDC_CLIENT_ID: z.string().min(1),
diff --git a/web/src/mocks/handlers/signer.ts b/web/src/mocks/handlers/signer.ts
index 359bbcecf..7829c1461 100644
--- a/web/src/mocks/handlers/signer.ts
+++ b/web/src/mocks/handlers/signer.ts
@@ -53,29 +53,29 @@ function paginatedCertificates(): Certificate[] {
 }
 
 export const signerHandlers = [
-  http.get("*/api/v1/signer/admin/certificates", ({ request }) => {
+  // The mock cursor is the index of the next row.
+  http.get("*/api/v1/connectors/signer/certificates", ({ request }) => {
     const url = new URL(request.url);
     const scenario = signerScenario();
     const source = scenario === "empty" ? [] : scenario === "paginated" ? 
paginatedCertificates() : certificates;
     const limit = Number(url.searchParams.get("limit") ?? source.length);
-    const offset = Number(url.searchParams.get("offset") ?? 0);
-    const items = source.slice(offset, offset + limit);
+    const start = Number(url.searchParams.get("cursor") ?? 0);
+    const end = start + limit;
     return HttpResponse.json({
-      certificates: items,
-      total: source.length,
+      certificates: source.slice(start, end),
       limit,
-      offset,
+      ...(end < source.length ? { next_cursor: String(end) } : {}),
     });
   }),
 
-  http.get("*/api/v1/signer/admin/certificates/:serial", ({ params }) => {
+  http.get("*/api/v1/connectors/signer/certificates/:serial", ({ params }) => {
     const serial = Number(params["serial"]);
     const found = certificates.find((c) => c.serial_number === serial);
     if (!found) return HttpResponse.json({ error: "certificate not found" }, { 
status: 404 });
     return HttpResponse.json(found);
   }),
 
-  http.post("*/api/v1/signer/admin/certificates/:serial/revoke", async ({ 
params, request }) => {
+  http.post("*/api/v1/connectors/signer/certificates/:serial/revoke", async ({ 
params, request }) => {
     const scenario = signerScenario();
     if (scenario === "forbidden") {
       return HttpResponse.json(
diff --git a/web/tests/fixtures/signer-api.ts b/web/tests/fixtures/signer-api.ts
index 13ab5bc30..79a2ab42d 100644
--- a/web/tests/fixtures/signer-api.ts
+++ b/web/tests/fixtures/signer-api.ts
@@ -79,9 +79,10 @@ async function installSignerRoutes(context: BrowserContext) {
       return;
     }
 
+    // The mock cursor is the index of the next row.
     if (
       request.method() === "GET" &&
-      url.pathname === "/api/v1/signer/admin/certificates"
+      url.pathname === "/api/v1/connectors/signer/certificates"
     ) {
       const source =
         scenario === "empty"
@@ -90,18 +91,18 @@ async function installSignerRoutes(context: BrowserContext) 
{
             ? paginatedCertificates(certificates)
             : certificates;
       const limit = Number(url.searchParams.get("limit") ?? source.length);
-      const offset = Number(url.searchParams.get("offset") ?? 0);
+      const start = Number(url.searchParams.get("cursor") ?? 0);
+      const end = start + limit;
       await json(route, {
-        certificates: source.slice(offset, offset + limit),
-        total: source.length,
+        certificates: source.slice(start, end),
         limit,
-        offset,
+        ...(end < source.length ? { next_cursor: String(end) } : {}),
       });
       return;
     }
 
     const detailMatch = url.pathname.match(
-      /^\/api\/v1\/signer\/admin\/certificates\/(\d+)$/,
+      /^\/api\/v1\/connectors\/signer\/certificates\/(\d+)$/,
     );
     if (request.method() === "GET" && detailMatch) {
       const certificate = certificates.find(
@@ -116,7 +117,7 @@ async function installSignerRoutes(context: BrowserContext) 
{
     }
 
     const revokeMatch = url.pathname.match(
-      /^\/api\/v1\/signer\/admin\/certificates\/(\d+)\/revoke$/,
+      /^\/api\/v1\/connectors\/signer\/certificates\/(\d+)\/revoke$/,
     );
     if (request.method() === "POST" && revokeMatch) {
       if (scenario === "forbidden") {
diff --git a/web/tests/signer-certificates.e2e.ts 
b/web/tests/signer-certificates.e2e.ts
index a56a33a48..7e6cd8217 100644
--- a/web/tests/signer-certificates.e2e.ts
+++ b/web/tests/signer-certificates.e2e.ts
@@ -62,14 +62,19 @@ test.describe("ssh certificates", () => {
     await expect(page.getByRole("heading", { name: /no certificates yet/i 
})).toBeVisible();
   });
 
-  test("paginates against accurate server totals", async ({ page, signerApi }) 
=> {
+  test("pages forward and back with the server cursor", async ({ page, 
signerApi }) => {
     await signInAs(page, "admin");
     signerApi.setScenario("paginated");
     await page.goto("/admin/signer/certificates");
-    await expect(page.getByText(/Showing 1.*20 of 25/)).toBeVisible();
+    await expect(page.getByText("Page 1")).toBeVisible();
+    await expect(page.getByRole("link", { name: "100" })).toBeVisible();
+    await expect(page.getByRole("button", { name: /^Previous$/ 
})).toBeDisabled();
     await page.getByRole("button", { name: /^Next$/ }).click();
-    await expect(page.getByText(/Showing 21.*25 of 25/)).toBeVisible();
+    await expect(page.getByText("Page 2")).toBeVisible();
     await expect(page.getByRole("link", { name: "120" })).toBeVisible();
+    await expect(page.getByRole("button", { name: /^Next$/ })).toBeDisabled();
+    await page.getByRole("button", { name: /^Previous$/ }).click();
+    await expect(page.getByRole("link", { name: "100" })).toBeVisible();
   });
 
   test("distinguishes no matches on a loaded page", async ({ page }) => {

Reply via email to