Skip to content

feat(agent-readiness): publish OAuth Protected Resource Metadata (RFC 9728) #3312

Description

@koala73

Part of epic #3306.

Problem

Agents that hit a protected endpoint on api.worldmonitor.app get a 401 or similar but have no standard way to learn (a) which authorization server issues tokens for this resource, (b) what scopes they must request, or (c) what resource identifier to put in the token aud claim. RFC 9728 defines /.well-known/oauth-protected-resource for exactly this.

We already use Clerk for auth, and Clerk exposes a standards-compliant OIDC discovery document — so we have the upstream pieces; we just need to publish the resource-side metadata.

Fix

Serve /.well-known/oauth-protected-resource at the origin root with at minimum:

{
  "resource": "https://api.worldmonitor.app/",
  "authorization_servers": [
    "https://clerk.worldmonitor.app"
  ],
  "scopes_supported": [
    "read:public",
    "read:pro"
  ],
  "bearer_methods_supported": ["header"],
  "resource_documentation": "https://worldmonitor.app/docs/api/auth"
}

Exact values to confirm during implementation:

  • The Clerk OIDC issuer for our prod instance (check Clerk dashboard).
  • The actual scope namespace we want to advertise. Today our gate logic uses isCallerPremium (Clerk org:pro role OR Convex tier>=1) rather than OAuth scopes — so we either (a) advertise a pro scope and teach the gate to also honour it, or (b) advertise only read:public and keep premium out of this surface for now.

Implementation

Acceptance criteria

  • curl -s https://worldmonitor.app/.well-known/oauth-protected-resource returns valid JSON conforming to RFC 9728.
  • resource field matches the actual API origin (https://api.worldmonitor.app/).
  • authorization_servers[0]/.well-known/openid-configuration resolves (smoke check).
  • Advertised scopes match reality — no scopes we don't honour.
  • isitagentready.com "OAuth Protected Resource Metadata" check passes.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority, schedule when capacity allowsagent-readinessAgent-discoverability standards (well-known, RFC 8288/9727/9728, WebMCP, x402, etc.)area: APIBackend API, sidecar, keysenhancementNew feature or requestplatform: webWeb/browser-specificsecuritySecurity-related

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions