OAuthExternalResourceURL returns the external URL for OAuth 2.0 resource access. If a request is provided, it uses the request's Host header to construct the URL to make sure protected resource URLs origin matches with the resource URL being accessed by the client. This helps in cases, for example,
(r *http.Request)
| 440 | // If a request is provided, it uses the request's Host header to construct the URL to make sure protected resource URLs origin matches with the resource URL being accessed by the client. |
| 441 | // This helps in cases, for example, where the MCP server url starts with api.rilldata.com instead of admin.rilldata.com. |
| 442 | func (u *URLs) OAuthExternalResourceURL(r *http.Request) string { |
| 443 | if r != nil { |
| 444 | scheme := "http" |
| 445 | if u.IsHTTPS() { |
| 446 | scheme = "https" |
| 447 | } |
| 448 | return fmt.Sprintf("%s://%s", scheme, r.Host) |
| 449 | } |
| 450 | return u.External() |
| 451 | } |
| 452 | |
| 453 | // OAuthProtectedResourceMetadata returns the URL for the OAuth 2.0 Protected Resource Metadata endpoint. |
| 454 | // This endpoint is used by MCP clients to discover authorization server information. |
no test coverage detected