You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if(HasAuthorizationMetadata(result.Tools.Select(tool =>toolCollectionis not null&&toolCollection.TryGetPrimitive(tool.Name,outvarserverTool)?serverTool:null))
thrownewInvalidOperationException("Authorization filter was not invoked for tools/list operation, but authorization metadata was found on the tools. Ensure that AddAuthorizationFilters() is called on the IMcpServerBuilder to configure authorization filters.");
thrownewInvalidOperationException("Authorization filter was not invoked for tools/call operation, but authorization metadata was found on the tool. Ensure that AddAuthorizationFilters() is called on the IMcpServerBuilder to configure authorization filters.");
if(HasAuthorizationMetadata(result.Resources.Select(resource =>resourceCollectionis not null&&resourceCollection.TryGetPrimitive(resource.Uri,outvarserverResource)?serverResource:null))
thrownewInvalidOperationException("Authorization filter was not invoked for resources/list operation, but authorization metadata was found on the resources. Ensure that AddAuthorizationFilters() is called on the IMcpServerBuilder to configure authorization filters.");
if(HasAuthorizationMetadata(result.ResourceTemplates.Select(resourceTemplate =>resourceCollectionis not null&&resourceCollection.TryGetPrimitive(resourceTemplate.UriTemplate,outvarserverResource)?serverResource:null))
thrownewInvalidOperationException("Authorization filter was not invoked for resources/templates/list operation, but authorization metadata was found on the resource templates. Ensure that AddAuthorizationFilters() is called on the IMcpServerBuilder to configure authorization filters.");
thrownewInvalidOperationException("Authorization filter was not invoked for resources/read operation, but authorization metadata was found on the resource. Ensure that AddAuthorizationFilters() is called on the IMcpServerBuilder to configure authorization filters.");
if(HasAuthorizationMetadata(result.Prompts.Select(prompt =>promptCollectionis not null&&promptCollection.TryGetPrimitive(prompt.Name,outvarserverPrompt)?serverPrompt:null))
thrownewInvalidOperationException("Authorization filter was not invoked for prompts/list operation, but authorization metadata was found on the prompts. Ensure that AddAuthorizationFilters() is called on the IMcpServerBuilder to configure authorization filters.");
thrownewInvalidOperationException("Authorization filter was not invoked for prompts/get operation, but authorization metadata was found on the prompt. Ensure that AddAuthorizationFilters() is called on the IMcpServerBuilder to configure authorization filters.");
280
-
}
281
-
282
-
returnawaitnext(context,cancellationToken);
283
-
});
284
-
}
285
-
286
155
/// <summary>
287
156
/// Filters a collection of items based on authorization policies in their metadata.
288
157
/// For list operations where we need to filter results by authorization.
// https://github.com/dotnet/aspnetcore/issues/63365 tracks adding this as public API to AuthorizationPolicy itself.
344
213
// Copied from https://github.com/dotnet/aspnetcore/blob/9f2977bf9cfb539820983bda3bedf81c8cda9f20/src/Security/Authorization/Policy/src/AuthorizationMiddleware.cs#L116-L138
0 commit comments