Browse Source

updated signalr services

- envoy: webmarketingapigw
- latest client: webmvc
- service hub: ordering-signalrhub
pull/1358/head
hfz-r 4 years ago
parent
commit
8d9deceb80
4 changed files with 24 additions and 5 deletions
  1. +3
    -0
      src/ApiGateways/Envoy/config/webshopping/envoy.yaml
  2. +18
    -3
      src/Services/Ordering/Ordering.SignalrHub/Startup.cs
  3. +2
    -1
      src/Web/WebMVC/Controllers/AccountController.cs
  4. +1
    -1
      src/Web/WebMVC/libman.json

+ 3
- 0
src/ApiGateways/Envoy/config/webshopping/envoy.yaml View File

@ -56,6 +56,9 @@ static_resources:
auto_host_rewrite: true auto_host_rewrite: true
cluster: signalr-hub cluster: signalr-hub
timeout: 300s timeout: 300s
upgrade_configs:
upgrade_type: "websocket"
enabled: true
- name: "b-short" - name: "b-short"
match: match:
prefix: "/b/" prefix: "/b/"


+ 18
- 3
src/Services/Ordering/Ordering.SignalrHub/Startup.cs View File

@ -19,6 +19,7 @@ using Ordering.SignalrHub.IntegrationEvents.EventHandling;
using Ordering.SignalrHub.IntegrationEvents.Events; using Ordering.SignalrHub.IntegrationEvents.Events;
using RabbitMQ.Client; using RabbitMQ.Client;
using System; using System;
using System.Threading.Tasks;
using System.IdentityModel.Tokens.Jwt; using System.IdentityModel.Tokens.Jwt;
namespace Ordering.SignalrHub namespace Ordering.SignalrHub
@ -109,7 +110,7 @@ namespace Ordering.SignalrHub
RegisterEventBus(services); RegisterEventBus(services);
services.AddOptions(); services.AddOptions();
//configure autofac //configure autofac
var container = new ContainerBuilder(); var container = new ContainerBuilder();
container.RegisterModule(new ApplicationModule()); container.RegisterModule(new ApplicationModule());
@ -133,7 +134,7 @@ namespace Ordering.SignalrHub
loggerFactory.CreateLogger<Startup>().LogDebug("Using PATH BASE '{pathBase}'", pathBase); loggerFactory.CreateLogger<Startup>().LogDebug("Using PATH BASE '{pathBase}'", pathBase);
app.UsePathBase(pathBase); app.UsePathBase(pathBase);
} }
app.UseRouting(); app.UseRouting();
app.UseCors("CorsPolicy"); app.UseCors("CorsPolicy");
app.UseAuthentication(); app.UseAuthentication();
@ -150,7 +151,7 @@ namespace Ordering.SignalrHub
{ {
Predicate = r => r.Name.Contains("self") Predicate = r => r.Name.Contains("self")
}); });
endpoints.MapHub<NotificationsHub>("/hub/notificationhub", options => options.Transports = Microsoft.AspNetCore.Http.Connections.HttpTransports.All);
endpoints.MapHub<NotificationsHub>("/hub/notificationhub");
}); });
ConfigureEventBus(app); ConfigureEventBus(app);
@ -185,6 +186,20 @@ namespace Ordering.SignalrHub
options.Authority = identityUrl; options.Authority = identityUrl;
options.RequireHttpsMetadata = false; options.RequireHttpsMetadata = false;
options.Audience = "orders.signalrhub"; options.Audience = "orders.signalrhub";
options.Events = new JwtBearerEvents
{
OnMessageReceived = context =>
{
var accessToken = context.Request.Query["access_token"];
var path = context.HttpContext.Request.Path;
if (!string.IsNullOrEmpty(accessToken) && (path.StartsWithSegments("/hub/notificationhub")))
{
context.Token = accessToken;
}
return Task.CompletedTask;
}
};
}); });
} }


+ 2
- 1
src/Web/WebMVC/Controllers/AccountController.cs View File

@ -20,7 +20,8 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
_logger = logger ?? throw new ArgumentNullException(nameof(logger)); _logger = logger ?? throw new ArgumentNullException(nameof(logger));
} }
[Authorize(AuthenticationSchemes = "OpenIdConnect")] public async Task<IActionResult> SignIn(string returnUrl)
[Authorize(AuthenticationSchemes = "OpenIdConnect")]
public async Task<IActionResult> SignIn(string returnUrl)
{ {
var user = User as ClaimsPrincipal; var user = User as ClaimsPrincipal;
var token = await HttpContext.GetTokenAsync("access_token"); var token = await HttpContext.GetTokenAsync("access_token");


+ 1
- 1
src/Web/WebMVC/libman.json View File

@ -37,7 +37,7 @@
}, },
{ {
"provider": "unpkg", "provider": "unpkg",
"library": "@microsoft/signalr@3.0.1",
"library": "@microsoft/signalr@latest",
"destination": "wwwroot/lib/@microsoft/signalr/", "destination": "wwwroot/lib/@microsoft/signalr/",
"files": [ "files": [
"dist/browser/signalr.js", "dist/browser/signalr.js",


Loading…
Cancel
Save