Serve MCP and hooks with a secret through the portal tunnel
The connector now serves /mcp, its OAuth documents and /hooks/ besides /api/v1/, refuses any dot segment (httpx resolves them, which carried /api/v1/../../mcp onto the MCP mount), addresses calls to the hub's host, and bridges served sockets by calling the app with a websocket scope. A hook without a secret answers the tunnel with the 404 (or 1008) of a wrong secret. Requests through the hub get the hub's issuer, resource and consent page in the OAuth metadata and the 401, and the MCP host check admits the hub while enrolled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WgBfkm4rCmtd1T4vHWjEPx
This commit is contained in:
+13
-5
@@ -540,19 +540,27 @@ async def rebuild_busy(request: Request, exc: RebuildBusy) -> JSONResponse: # n
|
||||
include_in_schema=False,
|
||||
tags=["oauth"],
|
||||
)
|
||||
def oauth_authorization_server() -> JSONResponse:
|
||||
def oauth_authorization_server(request: Request) -> JSONResponse:
|
||||
"""RFC 8414 metadata, so an agent can find its way in unaided.
|
||||
|
||||
The authorization endpoint is the dashboard rather than the API: approving
|
||||
a client needs a signed-in human, and the browser session lives there.
|
||||
Through the hub that is the dashboard the portal opens, which the hub names
|
||||
when the link attaches; the hub's own address is the guess an older one
|
||||
leaves.
|
||||
"""
|
||||
issuer = settings.oauth_issuer
|
||||
from fluksio.cloud import config as cloud_config
|
||||
|
||||
base = cloud_config.portal_base(request.headers)
|
||||
issuer = base or settings.oauth_issuer
|
||||
dashboard = settings.FRONTEND_HOST.rstrip("/")
|
||||
if base is not None:
|
||||
connector = getattr(request.app.state, "cloud_connector", None)
|
||||
dashboard = getattr(connector, "app_url", None) or base
|
||||
return JSONResponse(
|
||||
content={
|
||||
"issuer": issuer,
|
||||
"authorization_endpoint": (
|
||||
f"{settings.FRONTEND_HOST.rstrip('/')}/oauth/authorize"
|
||||
),
|
||||
"authorization_endpoint": f"{dashboard}/oauth/authorize",
|
||||
"token_endpoint": f"{issuer}{settings.API_V1_STR}/oauth/token",
|
||||
"registration_endpoint": f"{issuer}{settings.API_V1_STR}/oauth/register",
|
||||
"jwks_uri": f"{issuer}/.well-known/jwks.json",
|
||||
|
||||
Reference in New Issue
Block a user