@@ -32,40 +32,50 @@ type EnterpriseHandlerConfig struct {
3232
3333 // IdPIssuerURL is the enterprise IdP's issuer URL (e.g., "https://acme.okta.com").
3434 // Used for OIDC discovery to find the token endpoint.
35+ // REQUIRED.
3536 IdPIssuerURL string
3637
3738 // IdPClientID is the MCP Client's ID registered at the IdP.
39+ // OPTIONAL. Required if the IdP requires client authentication for token exchange.
3840 IdPClientID string
3941
4042 // IdPClientSecret is the MCP Client's secret registered at the IdP.
43+ // OPTIONAL. Required if the IdP requires client authentication for token exchange.
4144 IdPClientSecret string
4245
4346 // MCP Server configuration (the resource being accessed)
4447
4548 // MCPAuthServerURL is the MCP Server's authorization server issuer URL.
4649 // Used as the audience for token exchange and for metadata discovery.
50+ // REQUIRED.
4751 MCPAuthServerURL string
4852
4953 // MCPResourceURI is the MCP Server's resource identifier (RFC 9728).
5054 // Used as the resource parameter in token exchange.
55+ // REQUIRED.
5156 MCPResourceURI string
5257
5358 // MCPClientID is the MCP Client's ID registered at the MCP Server.
59+ // OPTIONAL. Required if the MCP Server requires client authentication.
5460 MCPClientID string
5561
5662 // MCPClientSecret is the MCP Client's secret registered at the MCP Server.
63+ // OPTIONAL. Required if the MCP Server requires client authentication.
5764 MCPClientSecret string
5865
5966 // MCPScopes is the list of scopes to request at the MCP Server.
67+ // OPTIONAL.
6068 MCPScopes []string
6169
6270 // IDTokenFetcher is called to obtain an ID Token when authorization is needed.
6371 // The implementation should handle the OIDC login flow (e.g., browser redirect,
6472 // callback handling) and return the ID token.
73+ // REQUIRED.
6574 IDTokenFetcher IDTokenFetcher
6675
6776 // HTTPClient is an optional HTTP client for customization.
6877 // If nil, http.DefaultClient is used.
78+ // OPTIONAL.
6979 HTTPClient * http.Client
7080}
7181
@@ -117,12 +127,8 @@ func (h *EnterpriseHandler) TokenSource(ctx context.Context) (oauth2.TokenSource
117127// Authorize performs the Enterprise Managed Authorization flow.
118128// It is called when a request fails with 401 or 403.
119129func (h * EnterpriseHandler ) Authorize (ctx context.Context , req * http.Request , resp * http.Response ) error {
120- defer func () {
121- if resp != nil && resp .Body != nil {
122- io .Copy (io .Discard , resp .Body )
123- resp .Body .Close ()
124- }
125- }()
130+ defer resp .Body .Close ()
131+ defer io .Copy (io .Discard , resp .Body )
126132
127133 httpClient := h .config .HTTPClient
128134 if httpClient == nil {
0 commit comments