@@ -33,7 +33,7 @@ public async Task<bool> HandleRequestAsync()
3333 {
3434 // Check if the request is for the resource metadata endpoint
3535 string requestPath = Request . Path . Value ?? string . Empty ;
36-
36+
3737 string expectedMetadataPath = this . Options . ResourceMetadataUri ? . ToString ( ) ?? string . Empty ;
3838 if ( this . Options . ResourceMetadataUri != null && ! this . Options . ResourceMetadataUri . IsAbsoluteUri )
3939 {
@@ -64,14 +64,14 @@ private string GetAbsoluteResourceMetadataUri()
6464 {
6565 var options = this . Options ;
6666 var resourceMetadataUri = options . ResourceMetadataUri ;
67-
67+
6868 string currentPath = resourceMetadataUri ? . ToString ( ) ?? string . Empty ;
69-
69+
7070 if ( resourceMetadataUri != null && resourceMetadataUri . IsAbsoluteUri )
7171 {
7272 return currentPath ;
7373 }
74-
74+
7575 // For relative URIs, combine with the base URL
7676 string baseUrl = GetBaseUrl ( ) ;
7777 string relativePath = resourceMetadataUri ? . OriginalString . TrimStart ( '/' ) ?? string . Empty ;
@@ -80,7 +80,7 @@ private string GetAbsoluteResourceMetadataUri()
8080 {
8181 throw new InvalidOperationException ( $ "Could not create absolute URI for resource metadata. Base URL: { baseUrl } , Relative Path: { relativePath } ") ;
8282 }
83-
83+
8484 return absoluteUri . ToString ( ) ;
8585 }
8686
@@ -92,7 +92,7 @@ private Task HandleResourceMetadataRequestAsync(CancellationToken cancellationTo
9292 {
9393 var options = this . Options ;
9494 var resourceMetadata = options . GetResourceMetadata ( Request . HttpContext ) ;
95-
95+
9696 // Create a copy to avoid modifying the original
9797 var metadata = new ProtectedResourceMetadata
9898 {
@@ -102,22 +102,22 @@ private Task HandleResourceMetadataRequestAsync(CancellationToken cancellationTo
102102 ScopesSupported = [ .. resourceMetadata . ScopesSupported ] ,
103103 ResourceDocumentation = resourceMetadata . ResourceDocumentation
104104 } ;
105-
105+
106106 Response . StatusCode = StatusCodes . Status200OK ;
107107 Response . ContentType = "application/json" ;
108-
108+
109109 var json = JsonSerializer . Serialize (
110- metadata ,
110+ metadata ,
111111 McpJsonUtilities . DefaultOptions . GetTypeInfo ( typeof ( ProtectedResourceMetadata ) ) ) ;
112-
112+
113113 return Response . WriteAsync ( json , cancellationToken ) ;
114114 }
115115
116116 /// <inheritdoc />
117117 protected override async Task < AuthenticateResult > HandleAuthenticateAsync ( )
118118 {
119119 // If ForwardAuthenticate is set, forward the authentication to the specified scheme
120- if ( ! string . IsNullOrEmpty ( Options . ForwardAuthenticate ) &&
120+ if ( ! string . IsNullOrEmpty ( Options . ForwardAuthenticate ) &&
121121 Options . ForwardAuthenticate != Scheme . Name )
122122 {
123123 // Simply forward the authentication request to the specified scheme and return its result
@@ -136,14 +136,14 @@ protected override Task HandleChallengeAsync(AuthenticationProperties properties
136136 string rawPrmDocumentUri = GetAbsoluteResourceMetadataUri ( ) ;
137137
138138 properties ??= new AuthenticationProperties ( ) ;
139-
139+
140140 // Store the resource_metadata in properties in case other handlers need it
141141 properties . Items [ "resource_metadata" ] = rawPrmDocumentUri ;
142-
142+
143143 // Add the WWW-Authenticate header with Bearer scheme and resource metadata
144144 string headerValue = $ "Bearer realm=\" { Scheme . Name } \" , resource_metadata=\" { rawPrmDocumentUri } \" ";
145145 Response . Headers . Append ( "WWW-Authenticate" , headerValue ) ;
146-
146+
147147 return base . HandleChallengeAsync ( properties ) ;
148148 }
149149}
0 commit comments