public RouterService( IRouteEntryRegistry routeEntryRegistry, IRouteAuthorizationManager routeAuthorizationManager, ILogger logger) { _routeEntryRegistry = routeEntryRegistry; _routeAuthorizationManager = routeAuthorizationManager; InternalLogger.LoggerInstance = logger; _logger = logger .ForContext("RouterServiceId", RouterServiceId); _logger.Information("RouterService created with Id: {RouterServiceId}", RouterServiceId); }
public static RouteWorkflowTask Go( RouteRequest routeRequest, IRouteEntryRegistry routeEntryRegistry, IRouteAuthorizationManager routeAuthorizationManager, IRouterService routerService, ILogger logger) { var workflow = new RouteWorkflowTask(routeRequest, routeEntryRegistry, routeAuthorizationManager, routerService, logger); workflow.RouteResult = workflow.GoAsync(); return(workflow); }
internal RouteWorkflowTask( RouteRequest routeRequest, IRouteEntryRegistry routeEntryRegistry, IRouteAuthorizationManager routeAuthorizationManager, IRouterService routerService, ILogger logger) { _routeRequest = routeRequest; _routeEntryRegistry = routeEntryRegistry; _routeAuthorizationManager = routeAuthorizationManager; _routerService = routerService; _logger = logger .ForContext(SerilogConstants.Serilog_SourceContext_Name, nameof(RouteWorkflowTask)) .ForContext("Uri", Uri) .ForContext("ViewportName", ViewportOptions.ToString()) .ForContext("InitData", InitData) .ForContext("RouterServiceId", _routerService.RouterServiceId) .ForContext("RoutingWorkflowId", RoutingWorkflowId); }
/// <summary> /// Checks if the user has authorization to go to the target route. /// </summary> /// <param name="logger"></param> /// <param name="routeAuthorizationManager"></param> /// <param name="routingContext"></param> /// <returns></returns> public static async Task <bool> CheckRouteAuthorizationAsync( ILogger logger, IRouteAuthorizationManager routeAuthorizationManager, RoutingContext routingContext) { try { var routeAuthResult = await routeAuthorizationManager.CheckAuthorization(routingContext); var granted = routeAuthResult.Equals(RouteAuthorizationResult.Granted); logger.Information(granted ? "RouteEntry authorization granted." : "RouteEntry authorization denied."); return(granted); } catch (Exception e) { logger.Error(e, "Exception checking route authorization."); throw; } }