From cd5d33db40c29f4d74e7301b23f253995456e4b2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 21:19:18 +0000 Subject: [PATCH 1/2] docs(kernel): auth-service handleRequest names the whole surface, the mount-layer checks and the transport argument Claude-Session: https://claude.ai/code/session_016WV4d1NJYFGVi2FRztyBNo Co-authored-by: Claude --- content/docs/kernel/contracts/auth-service.mdx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/content/docs/kernel/contracts/auth-service.mdx b/content/docs/kernel/contracts/auth-service.mdx index 9159f89b4c1..127710dd836 100644 --- a/content/docs/kernel/contracts/auth-service.mdx +++ b/content/docs/kernel/contracts/auth-service.mdx @@ -75,11 +75,17 @@ Everything after `verify` is optional, and each optional member describes a capa ### handleRequest -The HTTP entry point for authentication. It receives a standard `Request` (login, OAuth callback, etc.) and returns a standard `Response`. The concrete implementation owns route handling, credential parsing, and cookie/token issuance. +The HTTP entry point for authentication. It receives a standard `Request` (login, OAuth callback, etc.) and returns a standard `Response`. The concrete implementation owns route handling, credential parsing, and cookie/token issuance. An implementation answers its whole auth route surface here, the routes it mounts itself as well as its library's, so a host that forwards its auth path to this method serves what the implementation's own mount does. + +With the shipped `plugin-auth`, a host that forwards to `handleRequest` gets: + +- **The whole auth surface.** Every route the self-hosted mount serves under `/api/v1/auth/*`: the routes the platform mounts itself (`/config`, `/bootstrap-status`, the `/admin/*` doors and the rest) and better-auth behind them, not better-auth alone. +- **The mount-layer checks.** The same checks as the self-hosted mount run on this path: the IP allow-list (`allowed_ip_ranges`), the one-account-per-request rule, the organization IP list and the platform-admin wrappers. +- **An optional transport argument.** The checks judge the client address from the transport the host passes. Pass the transport's peer as the second argument, `handleRequest(request, { remoteAddress })`, or declare `server.trustProxy` when the host sits behind a proxy that sets `X-Forwarded-For`. With neither, a deployment that sets `allowed_ip_ranges` answers `403 IP_NOT_ALLOWED`. The second argument belongs to the plugin's `AuthManager`; the `IAuthService` shape above is unchanged. ```typescript -// Wire the auth service into an HTTP handler -const response = await authService.handleRequest(request); +// Wire the auth service into an HTTP handler, passing the transport's peer address +const response = await authService.handleRequest(request, { remoteAddress }); return response; ``` From 0d4ce515d4f2e67128821b4fb6ca63a771cb8800 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 21:42:26 +0000 Subject: [PATCH 2/2] docs(kernel): keep the IAuthService example one-argument; show the transport argument on AuthManager Claude-Session: https://claude.ai/code/session_016WV4d1NJYFGVi2FRztyBNo Co-authored-by: Claude --- content/docs/kernel/contracts/auth-service.mdx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/content/docs/kernel/contracts/auth-service.mdx b/content/docs/kernel/contracts/auth-service.mdx index 127710dd836..6b74997d239 100644 --- a/content/docs/kernel/contracts/auth-service.mdx +++ b/content/docs/kernel/contracts/auth-service.mdx @@ -84,9 +84,12 @@ With the shipped `plugin-auth`, a host that forwards to `handleRequest` gets: - **An optional transport argument.** The checks judge the client address from the transport the host passes. Pass the transport's peer as the second argument, `handleRequest(request, { remoteAddress })`, or declare `server.trustProxy` when the host sits behind a proxy that sets `X-Forwarded-For`. With neither, a deployment that sets `allowed_ip_ranges` answers `403 IP_NOT_ALLOWED`. The second argument belongs to the plugin's `AuthManager`; the `IAuthService` shape above is unchanged. ```typescript -// Wire the auth service into an HTTP handler, passing the transport's peer address -const response = await authService.handleRequest(request, { remoteAddress }); +// Wire the auth service into an HTTP handler +const response = await authService.handleRequest(request); return response; + +// With plugin-auth's AuthManager, also pass the transport's peer address +const managed = await authManager.handleRequest(request, { remoteAddress }); ``` ### verify