diff --git a/Providers/XApiKeyAccessAttribute.cs b/Providers/XApiKeyAccessAttribute.cs index 1da9693..d8d8d47 100644 --- a/Providers/XApiKeyAccessAttribute.cs +++ b/Providers/XApiKeyAccessAttribute.cs @@ -21,7 +21,7 @@ namespace xIds.Providers AllowMultiple = false, Inherited = true )] - public class XApiKeyAccessAttribute : AuthorizeAttribute, IAuthorizationFilter + public class XApiKeyAccessAttribute : AuthorizeAttribute, IAsyncAuthorizationFilter { /// /// Optional allowed scopes. If empty, no scope enforcement. @@ -46,21 +46,7 @@ namespace xIds.Providers /// Authorization Filtering ... /// /// - public void OnAuthorization(AuthorizationFilterContext context) - { - Task.FromResult(OnAuthorizationAsync(context)); - } - - /// - /// Handle Authorization Filtering Using Tasks ... - /// - /// - /// - /// - private async Task OnAuthorizationAsync( - AuthorizationFilterContext context, - CancellationToken cancellationToken = default - ) + public async Task OnAuthorizationAsync(AuthorizationFilterContext context) { // // Access HttpContext ... @@ -125,7 +111,7 @@ namespace xIds.Providers userInfo: null, clientIP: clientIP, requiredScope: scopes, - cancellationToken: cancellationToken + cancellationToken: default ); if (validationResult.Errors.HasChild()) { @@ -155,5 +141,18 @@ namespace xIds.Providers context.Result = new UnauthorizedObjectResult(error); } } + + /// + /// Handle Authorization Filtering Using Tasks ... + /// + /// + /// + /// + private async Task OnAuthorizationAsync( + AuthorizationFilterContext context, + CancellationToken cancellationToken = default + ) + { + } } } \ No newline at end of file diff --git a/Startup.cs b/Startup.cs index 053d294..b1770c7 100644 --- a/Startup.cs +++ b/Startup.cs @@ -133,23 +133,7 @@ namespace xIds // app.UseEndpoints(endpoints => { - // - // endpoints.MapDefaultControllerRoute(); - - // - try - { - endpoints.MapDefaultControllerRoute(); - } - catch (ReflectionTypeLoadException ex) - { - foreach (var loaderException in ex.LoaderExceptions) - { - // Log or inspect the specific error, e.g., "Could not load file or assembly..." - Console.WriteLine(loaderException?.Message); - } - throw; // Re-throw to preserve the original behavior - } + endpoints.MapDefaultControllerRoute(); }); } }