authorizationServerMetadataURLs returns a list of URLs to try when looking for authorization server metadata as mandated by the MCP specification: https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization#authorization-server-metadata-discovery.
(issuerURL string)
| 37 | // authorization server metadata as mandated by the MCP specification: |
| 38 | // https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization#authorization-server-metadata-discovery. |
| 39 | func authorizationServerMetadataURLs(issuerURL string) []string { |
| 40 | var urls []string |
| 41 | |
| 42 | baseURL, err := url.Parse(issuerURL) |
| 43 | if err != nil { |
| 44 | return nil |
| 45 | } |
| 46 | |
| 47 | if baseURL.Path == "" { |
| 48 | // "OAuth 2.0 Authorization Server Metadata". |
| 49 | baseURL.Path = "/.well-known/oauth-authorization-server" |
| 50 | urls = append(urls, baseURL.String()) |
| 51 | // "OpenID Connect Discovery 1.0". |
| 52 | baseURL.Path = "/.well-known/openid-configuration" |
| 53 | urls = append(urls, baseURL.String()) |
| 54 | return urls |
| 55 | } |
| 56 | |
| 57 | originalPath := baseURL.Path |
| 58 | // "OAuth 2.0 Authorization Server Metadata with path insertion". |
| 59 | baseURL.Path = "/.well-known/oauth-authorization-server/" + strings.TrimLeft(originalPath, "/") |
| 60 | urls = append(urls, baseURL.String()) |
| 61 | // "OpenID Connect Discovery 1.0 with path insertion". |
| 62 | baseURL.Path = "/.well-known/openid-configuration/" + strings.TrimLeft(originalPath, "/") |
| 63 | urls = append(urls, baseURL.String()) |
| 64 | // "OpenID Connect Discovery 1.0 with path appending". |
| 65 | baseURL.Path = "/" + strings.Trim(originalPath, "/") + "/.well-known/openid-configuration" |
| 66 | urls = append(urls, baseURL.String()) |
| 67 | |
| 68 | return urls |
| 69 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…