API Key Resource Bindings
Canonical internal architecture for centralized API key scopes, bindable resource catalogs, and the TopoloOne-to-Auth request path.
What It Is
This is the canonical architecture for API key scope metadata and bindable resource catalogs. Topolo Auth owns both catalogs. TopoloOne reads both from Auth. Owning applications remain the source of truth for the actual resources.
How It Works
Topolo Auth exposes two route families:
GET /api/services/:serviceId/api-key-scopesGET /api/services/:serviceId/api-key-resources
TopoloOne uses these routes to render the API key form. It does not keep hardcoded scope lists and it does not fetch bindable resources directly from application frontends.
Interfaces
- Auth route registration:
Applications/TopoloAuth/src/index.js - Auth controller methods:
Applications/TopoloAuth/src/controllers/auth.js - Auth repository access:
Applications/TopoloAuth/src/repositories/user.js - TopoloOne client requests:
Applications/TopoloOne/apps/dashboard-web/src/lib/api.ts
Data Flow
- TopoloOne loads service metadata from Auth.
- TopoloOne requests
api-key-scopesfor the chosen service. - Auth reads
service_api_key_scopesfrom D1. - If the service declares resource patterns, TopoloOne requests
api-key-resources. - Auth discovers the required resource types from
service_api_key_scopes.resource_pattern. - Auth sync providers refresh the service resource catalog for the current organization.
- Auth returns active rows from
service_api_key_resources. - TopoloOne submits the final key payload with
resourceBindings. - Auth validates and stores the key in
api_keys.resource_bindings.
Failure Modes
service_api_key_scopeshas no rows for the selected serviceresource_patternis missing, so Auth cannot infer bindable resource types- resource sync provider fails for the service or organization
service_api_key_resourcesis empty after sync- TopoloOne points at the wrong service ID or auth origin
- stale UI code bypasses the Auth-backed API-key endpoints
Debugging
- confirm the service ID in the Auth service registry
- query
service_api_key_scopesfor the service and verifyresource_pattern - query
service_api_key_resourcesfor(service_id, organization_id) - inspect
getServiceApiKeyResourcesin Auth to see whether sync failed before list - inspect
replaceServiceApiKeyResources,getServiceApiKeyResourceTypes, andlistServiceApiKeyResourcesin the Auth repository - confirm TopoloOne is calling
/api/services/:serviceId/api-key-scopesand/api/services/:serviceId/api-key-resources - current sync providers cover Socialize brands and Topolo Forecast workspaces, with older code still using the FinSight name in places
Change Log / Verification
- Verified on 2026-03-29 against the live controller and repository implementation
- Canonical D1 tables:
service_api_key_scopes,service_api_key_resources,api_keys - Canonical owning applications for current resource syncs: Socialize and Topolo Forecast