public async Task <object> InvokeInterfaceAsync(ClientRequestMessage clientMessage) { var invokeInfos = InterfaceCollection.GetInvokeInformation(clientMessage.Method); var authentication = new SignalARRRAuthentication(_serviceProvider); var result = await authentication.Authorize(ClientContext, clientMessage.Authorization, invokeInfos.MethodInfo); if (!result.Succeeded) { throw new UnauthorizedException(); } object instance; if (invokeInfos.MethodInfo.DeclaringType == HARRR.GetType()) { instance = ActivatorUtilities.CreateInstance(_serviceProvider, HARRR.GetType()); } else { instance = invokeInfos.Factory.DynamicInvoke(_serviceProvider); } return(await InvokeMethodInfoAsync(instance, invokeInfos.MethodInfo, clientMessage.Arguments, clientMessage.GenericArguments)); }
public async Task <IAsyncEnumerable <object> > InvokeMethodStreamAsync(ClientRequestMessage clientMessage, CancellationToken cancellationToken) { var methodInformations = MethodsCollection.GetMethodInformations(clientMessage.Method); var authentication = new SignalARRRAuthentication(_serviceProvider); var result = await authentication.Authorize(ClientContext, clientMessage.Authorization, methodInformations.MethodInfo); if (!result.Succeeded) { throw new UnauthorizedException(); } object instance; if (methodInformations.MethodInfo.DeclaringType == HARRR.GetType()) { instance = ActivatorUtilities.CreateInstance(_serviceProvider, HARRR.GetType()); } else { instance = _serviceProvider.GetRequiredService(methodInformations.MethodInfo.ReflectedType); } return(await InvokeStreamMethodInfoAsync(instance, methodInformations.MethodInfo, clientMessage.Arguments, cancellationToken)); }
public async Task <IAsyncEnumerable <object> > InvokeInterfaceStreamAsync(ClientRequestMessage clientMessage, CancellationToken cancellationToken) { var invokeInfos = InterfaceCollection.GetInvokeInformation(clientMessage.Method); var authentication = new SignalARRRAuthentication(_serviceProvider); var result = await authentication.Authorize(ClientContext, clientMessage.Authorization, invokeInfos.MethodInfo); if (!result.Succeeded) { throw new UnauthorizedException(); } var instance = invokeInfos.Factory.DynamicInvoke(_serviceProvider); return(await InvokeStreamMethodInfoAsync(instance, invokeInfos.MethodInfo, clientMessage.Arguments, cancellationToken)); }
public async Task <PolicyAuthorizationResult> TryAuthenticate(MethodInfo methodInfo) { if (!methodInfo.GetAuthorizeData().Any()) { return(PolicyAuthorizationResult.Success()); } if (UserValidUntil >= DateTime.Now) { return(PolicyAuthorizationResult.Success()); } var hubContextType = typeof(ClientContextDispatcher <>).MakeGenericType(HARRRType); var harrrContext = (IClientContextDispatcher)ServiceProvider.GetRequiredService(hubContextType); var res = await harrrContext.Challenge(Id); var authentication = new SignalARRRAuthentication(ServiceProvider); return(await authentication.Authorize(this, res, methodInfo)); }