last ...
This commit is contained in:
@@ -21,7 +21,7 @@ namespace xIds.Providers
|
||||
AllowMultiple = false,
|
||||
Inherited = true
|
||||
)]
|
||||
public class XApiKeyAccessAttribute : AuthorizeAttribute, IAuthorizationFilter
|
||||
public class XApiKeyAccessAttribute : AuthorizeAttribute, IAsyncAuthorizationFilter
|
||||
{
|
||||
/// <summary>
|
||||
/// Optional allowed scopes. If empty, no scope enforcement.
|
||||
@@ -46,21 +46,7 @@ namespace xIds.Providers
|
||||
/// Authorization Filtering ...
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public void OnAuthorization(AuthorizationFilterContext context)
|
||||
{
|
||||
Task.FromResult(OnAuthorizationAsync(context));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle Authorization Filtering Using Tasks ...
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle Authorization Filtering Using Tasks ...
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
private async Task OnAuthorizationAsync(
|
||||
AuthorizationFilterContext context,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-17
@@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user