Browse Source

WIP on Ocelot: Change routing and config errors.

pull/565/head^2
Eduard Tomàs 7 years ago
parent
commit
e59829e96b
6 changed files with 27 additions and 8 deletions
  1. +11
    -1
      src/Apigw/OcelotApiGw/Startup.cs
  2. +1
    -1
      src/Apigw/OcelotApiGw/configuration/configuration.json
  3. +3
    -1
      src/BFFs/PurchaseBff/Controllers/BasketController.cs
  4. +10
    -3
      src/BFFs/PurchaseBff/Program.cs
  5. +1
    -1
      src/BFFs/PurchaseBff/Startup.cs
  6. +1
    -1
      src/Services/Basket/Basket.API/Properties/launchSettings.json

+ 11
- 1
src/Apigw/OcelotApiGw/Startup.cs View File

@ -34,7 +34,17 @@ namespace OcelotApiGw
{
x.Authority = identityUrl;
x.RequireHttpsMetadata = false;
x.Audience = "ocelot";
x.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters()
{
ValidAudiences = new[] { "orders", "basket", "locations", "marketing", "purchasebff" }
};
x.Events = new Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents()
{
OnAuthenticationFailed = async ctx =>
{
int i = 0;
}
};
});
services.AddOcelot(_cfg);


+ 1
- 1
src/Apigw/OcelotApiGw/configuration/configuration.json View File

@ -11,7 +11,7 @@
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "http",
"DownstreamHost": "purchase-bff",
"DownstreamHost": "purchasebff",
"DownstreamPort": 80,
"UpstreamPathTemplate": "/purchase-bff/{everything}",
"UpstreamHttpMethod": [],


+ 3
- 1
src/BFFs/PurchaseBff/Controllers/BasketController.cs View File

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using PurchaseBff.Models;
using PurchaseBff.Services;
using System;
@ -9,6 +10,7 @@ using System.Threading.Tasks;
namespace PurchaseBff.Controllers
{
[Route("api/v1/[controller]")]
[Authorize]
public class BasketController : Controller
{
private readonly ICatalogService _catalog;


+ 10
- 3
src/BFFs/PurchaseBff/Program.cs View File

@ -18,12 +18,19 @@ namespace PurchaseBff
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
WebHost
.CreateDefaultBuilder(args)
.ConfigureAppConfiguration(cb =>
{
cb.AddJsonFile("appsettings.localhost.json", optional: true);
var sources = cb.Sources;
sources.Insert(3, new Microsoft.Extensions.Configuration.Json.JsonConfigurationSource()
{
Optional = true,
Path = "appsettings.localhost.json",
ReloadOnChange = false
});
})
.UseStartup<Startup>()
.Build();
}
}

+ 1
- 1
src/BFFs/PurchaseBff/Startup.cs View File

@ -88,7 +88,7 @@ namespace PurchaseBff
{
options.Authority = identityUrl;
options.RequireHttpsMetadata = false;
options.Audience = "ocelot";
options.Audience = "purchasebff";
options.Events = new JwtBearerEvents()
{
OnAuthenticationFailed = async ctx =>


+ 1
- 1
src/Services/Basket/Basket.API/Properties/launchSettings.json View File

@ -3,7 +3,7 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:55103/",
"applicationUrl": "http://localhost:51078/",
"sslPort": 0
}
},


Loading…
Cancel
Save