using Microsoft.AspNetCore.Authentication; using ModelContextProtocol.Authentication; namespace ModelContextProtocol.AspNetCore.Authentication; /// /// Options for the MCP authentication handler. /// public class McpAuthenticationOptions : AuthenticationSchemeOptions { private static readonly Uri DefaultResourceMetadataUri = new("/.well-known/oauth-protected-resource", UriKind.Relative); /// /// Initializes a new instance of the class. /// public McpAuthenticationOptions() { // "Bearer" is JwtBearerDefaults.AuthenticationScheme, but we don't have a reference to the JwtBearer package here. ForwardAuthenticate = "Bearer"; ResourceMetadataUri = DefaultResourceMetadataUri; Events = new McpAuthenticationEvents(); } /// /// Gets or sets the events used to handle authentication events. /// public new McpAuthenticationEvents Events { get => (McpAuthenticationEvents)base.Events!; set => base.Events = value; } /// /// The URI to the resource metadata document. /// /// /// This URI will be included in the WWW-Authenticate header when a 401 response is returned. /// public Uri ResourceMetadataUri { get; set; } /// /// Gets or sets the protected resource metadata. /// /// /// This contains the OAuth metadata for the protected resource, including authorization servers, /// supported scopes, and other information needed for clients to authenticate. /// public ProtectedResourceMetadata? ResourceMetadata { get; set; } }