public void ExecuteAuthorizationFilterAsync(ServiceRouteContext serviceRouteContext, CancellationToken cancellationToken)
        {
            var result = OnAuthorization(serviceRouteContext);

            if (!result)
            {
                serviceRouteContext.ResultMessage.ExceptionMessage = "令牌验证失败.";
            }
        }
Beispiel #2
0
        public virtual void ExecuteAuthorizationFilterAsync(ServiceRouteContext serviceRouteContext, CancellationToken cancellationToken)
        {
            var result = OnAuthorization(serviceRouteContext);

            if (!result)
            {
                serviceRouteContext.ResultMessage.StatusCode       = Exceptions.StatusCode.UnAuthentication;
                serviceRouteContext.ResultMessage.ExceptionMessage = "令牌验证失败.";
            }
        }
Beispiel #3
0
        private async Task OnAuthorization(ServiceEntry entry, RemoteInvokeMessage remoteInvokeMessage,
                                           RemoteInvokeResultMessage resultMessage, CancellationTokenSource cancelTokenSource)
        {
            if (entry.Descriptor.EnableAuthorization() && entry.Descriptor.AuthType() == AuthorizationType.AppSecret.ToString())
            {
                var route = await _serviceRouteProvider.Locate(entry.Descriptor.Id);

                var routeContext = new ServiceRouteContext()
                {
                    Route         = route,
                    InvokeMessage = remoteInvokeMessage,
                    ResultMessage = resultMessage,
                };
                _authorizationFilter.ExecuteAuthorizationFilterAsync(routeContext, cancelTokenSource.Token);
                if (!string.IsNullOrEmpty(resultMessage.ExceptionMessage))
                {
                    cancelTokenSource.Cancel();
                }
            }
        }
Beispiel #4
0
 public virtual bool OnAuthorization(ServiceRouteContext context)
 {
     return(true);
 }
 public virtual bool OnAuthorization(ServiceRouteContext context)
 {
     return(context.Route.Address.Any(p => p.Token == context.InvokeMessage.Token));
 }