diff --git a/docker-compose.override.yml b/docker-compose.override.yml
index c8375040d..6870b617f 100644
--- a/docker-compose.override.yml
+++ b/docker-compose.override.yml
@@ -61,6 +61,8 @@ services:
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
- UseCustomizationData=True
- AzureServiceBusEnabled=False
+ - GracePeriodTime=1
+ - CheckUpdateTime=30000
ports:
- "5102:80"
diff --git a/src/BuildingBlocks/DataProtection/DataProtection/DataProtection.csproj b/src/BuildingBlocks/DataProtection/DataProtection/DataProtection.csproj
index 41281cf54..c5266d0a9 100644
--- a/src/BuildingBlocks/DataProtection/DataProtection/DataProtection.csproj
+++ b/src/BuildingBlocks/DataProtection/DataProtection/DataProtection.csproj
@@ -1,13 +1,13 @@
- netstandard2.0
+ netstandard1.5
Microsoft.eShopOnContainers.BuildingBlocks
-
+
-
+
\ No newline at end of file
diff --git a/src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/Microsoft.AspNetCore.HealthChecks.csproj b/src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/Microsoft.AspNetCore.HealthChecks.csproj
index 0f6b99f32..023554e60 100644
--- a/src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/Microsoft.AspNetCore.HealthChecks.csproj
+++ b/src/BuildingBlocks/HealthChecks/src/Microsoft.AspNetCore.HealthChecks/Microsoft.AspNetCore.HealthChecks.csproj
@@ -1,7 +1,7 @@
- netstandard2.0
+ netstandard1.3
@@ -9,7 +9,7 @@
-
+
diff --git a/src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.SqlServer/Microsoft.Extensions.HealthChecks.SqlServer.csproj b/src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.SqlServer/Microsoft.Extensions.HealthChecks.SqlServer.csproj
index 60017a85f..35aacef13 100644
--- a/src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.SqlServer/Microsoft.Extensions.HealthChecks.SqlServer.csproj
+++ b/src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.SqlServer/Microsoft.Extensions.HealthChecks.SqlServer.csproj
@@ -1,7 +1,7 @@
- netstandard2.0
+ netstandard1.3
@@ -9,7 +9,7 @@
-
+
diff --git a/src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Microsoft.Extensions.HealthChecks.csproj b/src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Microsoft.Extensions.HealthChecks.csproj
index 80e8026b0..8ef22e156 100644
--- a/src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Microsoft.Extensions.HealthChecks.csproj
+++ b/src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Microsoft.Extensions.HealthChecks.csproj
@@ -1,7 +1,7 @@
- netstandard2.0
+ netstandard1.3
@@ -9,7 +9,7 @@
-
+
diff --git a/src/Services/Basket/Basket.API/Startup.cs b/src/Services/Basket/Basket.API/Startup.cs
index e2a2b6e3e..a00477f1e 100644
--- a/src/Services/Basket/Basket.API/Startup.cs
+++ b/src/Services/Basket/Basket.API/Startup.cs
@@ -3,6 +3,7 @@ using Autofac.Extensions.DependencyInjection;
using Basket.API.Infrastructure.Filters;
using Basket.API.IntegrationEvents.EventHandling;
using Basket.API.IntegrationEvents.Events;
+using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
@@ -25,6 +26,7 @@ using StackExchange.Redis;
using Swashbuckle.AspNetCore.Swagger;
using System;
using System.Collections.Generic;
+using System.IdentityModel.Tokens.Jwt;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Basket.API
@@ -50,6 +52,8 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
}).AddControllersAsServices();
+ ConfigureAuthService(services);
+
services.AddHealthChecks(checks =>
{
checks.AddValueTaskCheck("HTTP Endpoint", () => new ValueTask(HealthCheckResult.Healthy("Ok")),
@@ -57,16 +61,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
);
});
- services.Configure(Configuration);
-
- services.AddAuthentication()
- .AddJwtBearer(options =>
- {
- options.Authority = Configuration.GetValue("IdentityUrl");
- options.Audience = "basket";
- options.RequireHttpsMetadata = false;
-
- });
+ services.Configure(Configuration);
//By connecting here we are making sure that our service
//cannot start until redis is ready. This might slow down startup,
@@ -151,7 +146,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
services.AddSingleton();
services.AddTransient();
services.AddTransient();
-
+
services.AddOptions();
var container = new ContainerBuilder();
@@ -167,7 +162,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
{
app.UseStaticFiles();
app.UseCors("CorsPolicy");
- app.UseAuthentication();
+ ConfigureAuth(app);
app.UseMvcWithDefaultRoute();
app.UseSwagger()
@@ -181,6 +176,30 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
}
+ private void ConfigureAuthService(IServiceCollection services)
+ {
+ // prevent from mapping "sub" claim to nameidentifier.
+ JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
+
+ var identityUrl = Configuration.GetValue("IdentityUrl");
+
+ services.AddAuthentication(options =>
+ {
+ options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
+ options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
+
+ }).AddJwtBearer(options =>
+ {
+ options.Authority = identityUrl;
+ options.RequireHttpsMetadata = false;
+ options.Audience = "basket";
+ });
+ }
+
+ protected virtual void ConfigureAuth(IApplicationBuilder app)
+ {
+ app.UseAuthentication();
+ }
private void RegisterEventBus(IServiceCollection services)
{
diff --git a/src/Services/Catalog/Catalog.API/Startup.cs b/src/Services/Catalog/Catalog.API/Startup.cs
index 7f64e9a88..64754c3ab 100644
--- a/src/Services/Catalog/Catalog.API/Startup.cs
+++ b/src/Services/Catalog/Catalog.API/Startup.cs
@@ -36,25 +36,13 @@
public class Startup
{
- public IConfigurationRoot Configuration { get; }
-
- public Startup(IHostingEnvironment env)
+ public Startup(IConfiguration configuration)
{
- var builder = new ConfigurationBuilder()
- .SetBasePath(env.ContentRootPath)
- .AddJsonFile($"settings.json", optional: false, reloadOnChange: true)
- .AddJsonFile($"settings.{env.EnvironmentName}.json", optional: true);
-
- if (env.IsDevelopment())
- {
- builder.AddUserSecrets(typeof(Startup).GetTypeInfo().Assembly);
- }
-
- builder.AddEnvironmentVariables();
-
- Configuration = builder.Build();
+ Configuration = configuration;
}
+ public IConfiguration Configuration { get; }
+
public IServiceProvider ConfigureServices(IServiceCollection services)
{
// Add framework services.
diff --git a/src/Services/Identity/Identity.API/Controllers/AccountController.cs b/src/Services/Identity/Identity.API/Controllers/AccountController.cs
index 6b56b3467..02b50129f 100644
--- a/src/Services/Identity/Identity.API/Controllers/AccountController.cs
+++ b/src/Services/Identity/Identity.API/Controllers/AccountController.cs
@@ -2,24 +2,26 @@
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
-using Identity.API.Models;
-using Identity.API.Models.AccountViewModels;
-using Identity.API.Services;
using IdentityModel;
-using IdentityServer4.Models;
+using IdentityServer4.Quickstart.UI.Models;
using IdentityServer4.Services;
-using IdentityServer4.Stores;
-using Microsoft.AspNetCore.Authentication;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Identity;
+using Microsoft.AspNetCore.Http.Authentication;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Logging;
using System;
+using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
-
+using IdentityServer4.Models;
+using IdentityServer4.Stores;
+using Identity.API.Services;
+using Identity.API.Models;
+using Microsoft.Extensions.Logging;
+using Microsoft.AspNetCore.Authorization;
+using Identity.API.Models.AccountViewModels;
+using Microsoft.AspNetCore.Identity;
+using Microsoft.AspNetCore.Authentication;
namespace IdentityServer4.Quickstart.UI.Controllers
{
@@ -38,12 +40,12 @@ namespace IdentityServer4.Quickstart.UI.Controllers
private readonly UserManager _userManager;
public AccountController(
-
+
//InMemoryUserLoginService loginService,
ILoginService loginService,
IIdentityServerInteractionService interaction,
IClientStore clientStore,
- ILoggerFactory loggerFactory,
+ ILoggerFactory loggerFactory,
UserManager userManager)
{
_loginService = loginService;
@@ -84,7 +86,7 @@ namespace IdentityServer4.Quickstart.UI.Controllers
var user = await _loginService.FindByUsername(model.Email);
if (await _loginService.ValidateCredentials(user, model.Password))
{
- AuthenticationProperties props = null;
+ AuthenticationProperties props = null;
if (model.RememberMe)
{
props = new AuthenticationProperties
@@ -192,16 +194,16 @@ namespace IdentityServer4.Quickstart.UI.Controllers
try
{
// hack: try/catch to handle social providers that throw
- await HttpContext.SignOutAsync(idp, new AuthenticationProperties { RedirectUri = url });
+ await HttpContext.Authentication.SignOutAsync(idp, new AuthenticationProperties { RedirectUri = url });
}
- catch(Exception ex)
+ catch (Exception ex)
{
_logger.LogCritical(ex.Message);
}
}
// delete authentication cookie
- await HttpContext.SignOutAsync();
+ await HttpContext.Authentication.SignOutAsync();
// set this so UI rendering sees an anonymous user
HttpContext.User = new ClaimsPrincipal(new ClaimsIdentity());
@@ -215,7 +217,7 @@ namespace IdentityServer4.Quickstart.UI.Controllers
public async Task DeviceLogOut(string redirectUrl)
{
// delete authentication cookie
- await HttpContext.SignOutAsync();
+ await HttpContext.Authentication.SignOutAsync();
// set this so UI rendering sees an anonymous user
HttpContext.User = new ClaimsPrincipal(new ClaimsIdentity());
@@ -238,7 +240,7 @@ namespace IdentityServer4.Quickstart.UI.Controllers
// start challenge and roundtrip the return URL
var props = new AuthenticationProperties
{
- RedirectUri = returnUrl,
+ RedirectUri = returnUrl,
Items = { { "scheme", provider } }
};
return new ChallengeResult(provider, props);
@@ -291,7 +293,8 @@ namespace IdentityServer4.Quickstart.UI.Controllers
}
}
- if (returnUrl != null) {
+ if (returnUrl != null)
+ {
if (HttpContext.User.Identity.IsAuthenticated)
return Redirect(returnUrl);
else
diff --git a/src/Services/Identity/Identity.API/Identity.API.csproj b/src/Services/Identity/Identity.API/Identity.API.csproj
index 49f9b4c2e..7c221e858 100644
--- a/src/Services/Identity/Identity.API/Identity.API.csproj
+++ b/src/Services/Identity/Identity.API/Identity.API.csproj
@@ -1,10 +1,10 @@
- netcoreapp2.0
- 2.0.0
+ netcoreapp1.1
+ 1.1.2
aspnet-eShopOnContainers.Identity-90487118-103c-4ff0-b9da-e5e26f7ab0c5
-
+ $(AssetTargetFallback);portable-net45+win8+wp8+wpa81;
..\..\..\..\docker-compose.dcproj
@@ -16,8 +16,30 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+ All
+
+
+ All
+
+
+
+
+
+
+
+
+
@@ -30,9 +52,9 @@
-
-
-
+
+
+
diff --git a/src/Services/Identity/Identity.API/Models/ApplicationUser.cs b/src/Services/Identity/Identity.API/Models/ApplicationUser.cs
index 1c1f7bda1..b520c333b 100644
--- a/src/Services/Identity/Identity.API/Models/ApplicationUser.cs
+++ b/src/Services/Identity/Identity.API/Models/ApplicationUser.cs
@@ -1,4 +1,8 @@
-using Microsoft.AspNetCore.Identity;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
namespace Identity.API.Models
diff --git a/src/Services/Identity/Identity.API/Program.cs b/src/Services/Identity/Identity.API/Program.cs
index 9a035bd93..2f731c045 100644
--- a/src/Services/Identity/Identity.API/Program.cs
+++ b/src/Services/Identity/Identity.API/Program.cs
@@ -1,6 +1,4 @@
-using Microsoft.AspNetCore;
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Logging;
+using Microsoft.AspNetCore.Hosting;
using System.IO;
namespace eShopOnContainers.Identity
@@ -9,19 +7,15 @@ namespace eShopOnContainers.Identity
{
public static void Main(string[] args)
{
- BuildWebHost(args).Run();
- }
-
- public static IWebHost BuildWebHost(string[] args) =>
- WebHost.CreateDefaultBuilder(args)
- .UseContentRoot(Directory.GetCurrentDirectory())
+ var host = new WebHostBuilder()
+ .UseKestrel()
.UseHealthChecks("/hc")
+ .UseContentRoot(Directory.GetCurrentDirectory())
+ .UseIISIntegration()
.UseStartup()
- .ConfigureLogging((hostingContext, builder) =>
- {
- builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
- builder.AddConsole();
- builder.AddDebug();
- }).Build();
+ .Build();
+
+ host.Run();
+ }
}
}
diff --git a/src/Services/Identity/Identity.API/Startup.cs b/src/Services/Identity/Identity.API/Startup.cs
index 711c4b9c1..a07cd69c2 100644
--- a/src/Services/Identity/Identity.API/Startup.cs
+++ b/src/Services/Identity/Identity.API/Startup.cs
@@ -1,6 +1,4 @@
-using Autofac;
-using Autofac.Extensions.DependencyInjection;
-using Identity.API.Certificate;
+using Identity.API.Certificate;
using Identity.API.Configuration;
using Identity.API.Data;
using Identity.API.Models;
@@ -11,12 +9,16 @@ using IdentityServer4.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
+using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.eShopOnContainers.BuildingBlocks;
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.HealthChecks;
+using Identity.API.Certificate;
+using Autofac.Extensions.DependencyInjection;
+using Autofac;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
@@ -28,17 +30,28 @@ namespace eShopOnContainers.Identity
{
public class Startup
{
- public Startup(IConfiguration configuration)
+ public Startup(IHostingEnvironment env)
{
- Configuration = configuration;
+ var builder = new ConfigurationBuilder()
+ .SetBasePath(env.ContentRootPath)
+ .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
+ .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
+
+ if (env.IsDevelopment())
+ {
+ // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
+ builder.AddUserSecrets();
+ }
+
+ builder.AddEnvironmentVariables();
+ Configuration = builder.Build();
}
- public IConfiguration Configuration { get; }
-
+ public IConfigurationRoot Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public IServiceProvider ConfigureServices(IServiceCollection services)
- {
+ {
// Add framework services.
services.AddDbContext(options =>
@@ -81,7 +94,7 @@ namespace eShopOnContainers.Identity
// Adds IdentityServer
services.AddIdentityServer(x => x.IssuerUri = "null")
- .AddSigningCredential(Certificate.Get())
+ .AddSigningCredential(Certificate.Get())
.AddAspNetIdentity()
.AddConfigurationStore(builder =>
builder.UseSqlServer(connectionString, options =>
@@ -123,11 +136,9 @@ namespace eShopOnContainers.Identity
await next();
});
-
+ app.UseIdentity();
// Adds IdentityServer
- app.UseAuthentication();
-
app.UseIdentityServer();
app.UseMvc(routes =>
diff --git a/src/Services/Location/Locations.API/Startup.cs b/src/Services/Location/Locations.API/Startup.cs
index 7d235ed0f..eb2077c8c 100644
--- a/src/Services/Location/Locations.API/Startup.cs
+++ b/src/Services/Location/Locations.API/Startup.cs
@@ -20,6 +20,7 @@ using RabbitMQ.Client;
using Swashbuckle.AspNetCore.Swagger;
using System;
using System.Collections.Generic;
+using System.IdentityModel.Tokens.Jwt;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Locations.API
@@ -40,13 +41,7 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
}).AddControllersAsServices();
- services.AddAuthentication()
- .AddJwtBearer(options =>
- {
- options.Authority = Configuration.GetValue("IdentityUrl");
- options.Audience = "locations";
- options.RequireHttpsMetadata = false;
- });
+ ConfigureAuthService(services);
services.Configure(Configuration);
@@ -138,7 +133,7 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
{
app.UseCors("CorsPolicy");
- app.UseAuthentication();
+ ConfigureAuth(app);
app.UseMvcWithDefaultRoute();
@@ -153,6 +148,25 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
.Wait();
}
+ private void ConfigureAuthService(IServiceCollection services)
+ {
+ // prevent from mapping "sub" claim to nameidentifier.
+ JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
+
+ services.AddAuthentication()
+ .AddJwtBearer(options =>
+ {
+ options.Authority = Configuration.GetValue("IdentityUrl");
+ options.Audience = "locations";
+ options.RequireHttpsMetadata = false;
+ });
+ }
+
+ protected virtual void ConfigureAuth(IApplicationBuilder app)
+ {
+ app.UseAuthentication();
+ }
+
private void RegisterEventBus(IServiceCollection services)
{
if (Configuration.GetValue("AzureServiceBusEnabled"))
diff --git a/src/Services/Marketing/Marketing.API/Startup.cs b/src/Services/Marketing/Marketing.API/Startup.cs
index 952594556..15b845337 100644
--- a/src/Services/Marketing/Marketing.API/Startup.cs
+++ b/src/Services/Marketing/Marketing.API/Startup.cs
@@ -28,6 +28,7 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
+ using System.IdentityModel.Tokens.Jwt;
using System.Reflection;
using System.Threading.Tasks;
@@ -52,13 +53,7 @@
services.Configure(Configuration);
- services.AddAuthentication()
- .AddJwtBearer(options =>
- {
- options.Authority = Configuration.GetValue("IdentityUrl");
- options.Audience = "marketing";
- options.RequireHttpsMetadata = false;
- });
+ ConfigureAuthService(services);
services.AddHealthChecks(checks =>
{
@@ -171,7 +166,7 @@
{
app.UseCors("CorsPolicy");
- app.UseAuthentication();
+ ConfigureAuth(app);
app.UseMvcWithDefaultRoute();
@@ -190,7 +185,21 @@
ConfigureEventBus(app);
}
- private void RegisterEventBus(IServiceCollection services)
+ private void ConfigureAuthService(IServiceCollection services)
+ {
+ // prevent from mapping "sub" claim to nameidentifier.
+ JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
+
+ services.AddAuthentication()
+ .AddJwtBearer(options =>
+ {
+ options.Authority = Configuration.GetValue("IdentityUrl");
+ options.Audience = "marketing";
+ options.RequireHttpsMetadata = false;
+ });
+ }
+
+ private void RegisterEventBus(IServiceCollection services)
{
if (Configuration.GetValue("AzureServiceBusEnabled"))
{
@@ -221,6 +230,11 @@
eventBus.Subscribe();
}
+ protected virtual void ConfigureAuth(IApplicationBuilder app)
+ {
+ app.UseAuthentication();
+ }
+
private async Task WaitForSqlAvailabilityAsync(MarketingContext ctx, ILoggerFactory loggerFactory, IApplicationBuilder app, int retries = 0)
{
var logger = loggerFactory.CreateLogger(nameof(Startup));
diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/HostedServices/GracePeriodManagerService.cs b/src/Services/Ordering/Ordering.API/Infrastructure/HostedServices/GracePeriodManagerService.cs
index 58408b2fd..f38fc8fd8 100644
--- a/src/Services/Ordering/Ordering.API/Infrastructure/HostedServices/GracePeriodManagerService.cs
+++ b/src/Services/Ordering/Ordering.API/Infrastructure/HostedServices/GracePeriodManagerService.cs
@@ -2,6 +2,7 @@
{
using Dapper;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
+ using Microsoft.eShopOnContainers.Services.Ordering.API;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Ordering.API.Application.IntegrationEvents.Events;
@@ -14,11 +15,11 @@
public class GracePeriodManagerService
: HostedService
{
- private readonly GracePeriodManagerSettings _settings;
+ private readonly OrderingSettings _settings;
private readonly ILogger _logger;
private readonly IEventBus _eventBus;
- public GracePeriodManagerService(IOptions settings,
+ public GracePeriodManagerService(IOptions settings,
IEventBus eventBus,
ILogger logger)
{
diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/HostedServices/GracePeriodManagerSettings.cs b/src/Services/Ordering/Ordering.API/Infrastructure/HostedServices/GracePeriodManagerSettings.cs
deleted file mode 100644
index 2997c051d..000000000
--- a/src/Services/Ordering/Ordering.API/Infrastructure/HostedServices/GracePeriodManagerSettings.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-namespace Ordering.API.Infrastructure.HostedServices
-{
- public class GracePeriodManagerSettings
- {
- public string ConnectionString { get; set; }
-
- public string EventBusConnection { get; set; }
-
- public int GracePeriodTime { get; set; }
-
- public int CheckUpdateTime { get; set; }
-
- }
-}
diff --git a/src/Services/Ordering/Ordering.API/OrderingSettings.cs b/src/Services/Ordering/Ordering.API/OrderingSettings.cs
index 8c75ba62d..bfe4d0793 100644
--- a/src/Services/Ordering/Ordering.API/OrderingSettings.cs
+++ b/src/Services/Ordering/Ordering.API/OrderingSettings.cs
@@ -3,5 +3,12 @@
public class OrderingSettings
{
public bool UseCustomizationData { get; set; }
+ public string ConnectionString { get; set; }
+
+ public string EventBusConnection { get; set; }
+
+ public int GracePeriodTime { get; set; }
+
+ public int CheckUpdateTime { get; set; }
}
}
diff --git a/src/Services/Ordering/Ordering.API/Startup.cs b/src/Services/Ordering/Ordering.API/Startup.cs
index c793a3950..7f22540fa 100644
--- a/src/Services/Ordering/Ordering.API/Startup.cs
+++ b/src/Services/Ordering/Ordering.API/Startup.cs
@@ -35,30 +35,18 @@
using System.Collections.Generic;
using System.Data.Common;
using System.Data.SqlClient;
+ using System.IdentityModel.Tokens.Jwt;
using System.Reflection;
using System.Threading.Tasks;
public class Startup
{
- public Startup(IHostingEnvironment env)
+ public Startup(IConfiguration configuration)
{
- var builder = new ConfigurationBuilder()
- .SetBasePath(env.ContentRootPath)
- .AddJsonFile("settings.json", optional: true, reloadOnChange: true)
- .AddJsonFile("graceperiodsettings.json", optional: true, reloadOnChange: true)
- .AddJsonFile($"settings.{env.EnvironmentName}.json", optional: true);
-
- if (env.IsDevelopment())
- {
- builder.AddUserSecrets(typeof(Startup).GetTypeInfo().Assembly);
- }
-
- builder.AddEnvironmentVariables();
-
- Configuration = builder.Build();
+ Configuration = configuration;
}
- public IConfigurationRoot Configuration { get; }
+ public IConfiguration Configuration { get; }
public IServiceProvider ConfigureServices(IServiceCollection services)
{
@@ -71,7 +59,6 @@
// Configure GracePeriodManager Hosted Service
services.AddSingleton();
- services.Configure(Configuration);
services.AddTransient();
@@ -228,6 +215,9 @@
private void ConfigureAuthService(IServiceCollection services)
{
+ // prevent from mapping "sub" claim to nameidentifier.
+ JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
+
var identityUrl = Configuration.GetValue("IdentityUrl");
services.AddAuthentication(options =>
diff --git a/src/Services/Ordering/Ordering.API/graceperiodsettings.json b/src/Services/Ordering/Ordering.API/graceperiodsettings.json
deleted file mode 100644
index 1c9d30e5e..000000000
--- a/src/Services/Ordering/Ordering.API/graceperiodsettings.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "ConnectionString": "Server=tcp:127.0.0.1,5433;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;",
- "GracePeriodTime": "1",
- "CheckUpdateTime": "30000"
-}
-
diff --git a/src/Services/Ordering/Ordering.API/settings.json b/src/Services/Ordering/Ordering.API/settings.json
index aa3499295..d2068fcab 100644
--- a/src/Services/Ordering/Ordering.API/settings.json
+++ b/src/Services/Ordering/Ordering.API/settings.json
@@ -11,5 +11,7 @@
}
},
"AzureServiceBusEnabled": false,
- "SubscriptionClientName": "Ordering"
+ "SubscriptionClientName": "Ordering",
+ "GracePeriodTime": "1",
+ "CheckUpdateTime": "30000"
}
diff --git a/src/Web/WebMVC/Startup.cs b/src/Web/WebMVC/Startup.cs
index 1791e8da1..8b10c1ecc 100644
--- a/src/Web/WebMVC/Startup.cs
+++ b/src/Web/WebMVC/Startup.cs
@@ -82,11 +82,10 @@ namespace Microsoft.eShopOnContainers.WebMVC
// Add Authentication services
services.AddAuthentication(options => {
+ options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
- options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
- options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
- .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme)
+ .AddCookie()
.AddOpenIdConnect(options => {
options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.Authority = identityUrl.ToString();
diff --git a/src/Web/WebSPA/Startup.cs b/src/Web/WebSPA/Startup.cs
index 22511c135..1659af537 100644
--- a/src/Web/WebSPA/Startup.cs
+++ b/src/Web/WebSPA/Startup.cs
@@ -16,24 +16,22 @@ namespace eShopConContainers.WebSPA
{
public class Startup
{
+ public Startup(IConfiguration configuration)
+ {
+ Configuration = configuration;
+ }
+
+ public IConfiguration Configuration { get; }
+
private IHostingEnvironment _hostingEnv;
public Startup(IHostingEnvironment env)
{
_hostingEnv = env;
- var builder = new ConfigurationBuilder()
- .SetBasePath(env.ContentRootPath)
- .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
- .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
- .AddEnvironmentVariables();
-
- Configuration = builder.Build();
-
var localPath = new Uri(Configuration["ASPNETCORE_URLS"])?.LocalPath ?? "/";
Configuration["BaseUrl"] = localPath;
}
- public static IConfigurationRoot Configuration { get; set;}
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
diff --git a/test/Services/FunctionalTests/Services/Basket/BasketTestsStartup.cs b/test/Services/FunctionalTests/Services/Basket/BasketTestsStartup.cs
index 2beb73bd1..31d83fddc 100644
--- a/test/Services/FunctionalTests/Services/Basket/BasketTestsStartup.cs
+++ b/test/Services/FunctionalTests/Services/Basket/BasketTestsStartup.cs
@@ -2,12 +2,13 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.eShopOnContainers.Services.Basket.API;
+using Microsoft.Extensions.Configuration;
namespace FunctionalTests.Services.Basket
{
public class BasketTestsStartup : Startup
{
- public BasketTestsStartup(IHostingEnvironment env) : base(env)
+ public BasketTestsStartup(IConfiguration env) : base(env)
{
}
diff --git a/test/Services/FunctionalTests/Services/Location/LocationsTestsStartup.cs b/test/Services/FunctionalTests/Services/Location/LocationsTestsStartup.cs
index b80408388..679518fb0 100644
--- a/test/Services/FunctionalTests/Services/Location/LocationsTestsStartup.cs
+++ b/test/Services/FunctionalTests/Services/Location/LocationsTestsStartup.cs
@@ -4,12 +4,13 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.eShopOnContainers.Services.Locations.API;
+ using Microsoft.Extensions.Configuration;
using System.Security.Claims;
using System.Threading.Tasks;
public class LocationsTestsStartup : Startup
{
- public LocationsTestsStartup(IHostingEnvironment env) : base(env)
+ public LocationsTestsStartup(IConfiguration env) : base(env)
{
}
diff --git a/test/Services/FunctionalTests/Services/Marketing/MarketingTestsStartup.cs b/test/Services/FunctionalTests/Services/Marketing/MarketingTestsStartup.cs
index e43db6646..14176da67 100644
--- a/test/Services/FunctionalTests/Services/Marketing/MarketingTestsStartup.cs
+++ b/test/Services/FunctionalTests/Services/Marketing/MarketingTestsStartup.cs
@@ -4,10 +4,11 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Builder;
using FunctionalTests.Middleware;
+ using Microsoft.Extensions.Configuration;
public class MarketingTestsStartup : Startup
{
- public MarketingTestsStartup(IHostingEnvironment env) : base(env)
+ public MarketingTestsStartup(IConfiguration env) : base(env)
{
}
diff --git a/test/Services/FunctionalTests/Services/Ordering/OrderingTestsStartup.cs b/test/Services/FunctionalTests/Services/Ordering/OrderingTestsStartup.cs
index 0d8676f61..46e5fe8c1 100644
--- a/test/Services/FunctionalTests/Services/Ordering/OrderingTestsStartup.cs
+++ b/test/Services/FunctionalTests/Services/Ordering/OrderingTestsStartup.cs
@@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.eShopOnContainers.Services.Ordering.API;
+using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Text;
@@ -10,7 +11,7 @@ namespace FunctionalTests.Services.Ordering
{
public class OrderingTestsStartup : Startup
{
- public OrderingTestsStartup(IHostingEnvironment env) : base(env)
+ public OrderingTestsStartup(IConfiguration env) : base(env)
{
}
diff --git a/test/Services/IntegrationTests/Services/Basket/BasketTestsStartup.cs b/test/Services/IntegrationTests/Services/Basket/BasketTestsStartup.cs
index 788c9621d..6bc1bbe6d 100644
--- a/test/Services/IntegrationTests/Services/Basket/BasketTestsStartup.cs
+++ b/test/Services/IntegrationTests/Services/Basket/BasketTestsStartup.cs
@@ -2,12 +2,13 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.eShopOnContainers.Services.Basket.API;
+using Microsoft.Extensions.Configuration;
namespace IntegrationTests.Services.Basket
{
public class BasketTestsStartup : Startup
{
- public BasketTestsStartup(IHostingEnvironment env) : base(env)
+ public BasketTestsStartup(IConfiguration env) : base(env)
{
}
diff --git a/test/Services/IntegrationTests/Services/Locations/LocationsTestsStartup.cs b/test/Services/IntegrationTests/Services/Locations/LocationsTestsStartup.cs
index 28a51456b..efcc9a3c0 100644
--- a/test/Services/IntegrationTests/Services/Locations/LocationsTestsStartup.cs
+++ b/test/Services/IntegrationTests/Services/Locations/LocationsTestsStartup.cs
@@ -5,12 +5,13 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.eShopOnContainers.Services.Locations.API;
+ using Microsoft.Extensions.Configuration;
using System.Security.Claims;
using System.Threading.Tasks;
public class LocationsTestsStartup : Startup
{
- public LocationsTestsStartup(IHostingEnvironment env) : base(env)
+ public LocationsTestsStartup(IConfiguration env) : base(env)
{
}
diff --git a/test/Services/IntegrationTests/Services/Marketing/MarketingTestsStartup.cs b/test/Services/IntegrationTests/Services/Marketing/MarketingTestsStartup.cs
index b8d337ab2..b2d8ed3dc 100644
--- a/test/Services/IntegrationTests/Services/Marketing/MarketingTestsStartup.cs
+++ b/test/Services/IntegrationTests/Services/Marketing/MarketingTestsStartup.cs
@@ -4,10 +4,11 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Builder;
using IntegrationTests.Middleware;
+ using Microsoft.Extensions.Configuration;
public class MarketingTestsStartup : Startup
{
- public MarketingTestsStartup(IHostingEnvironment env) : base(env)
+ public MarketingTestsStartup(IConfiguration env) : base(env)
{
}
diff --git a/test/Services/IntegrationTests/Services/Ordering/OrderingTestsStartup.cs b/test/Services/IntegrationTests/Services/Ordering/OrderingTestsStartup.cs
index 72fe91f0e..a5aab6136 100644
--- a/test/Services/IntegrationTests/Services/Ordering/OrderingTestsStartup.cs
+++ b/test/Services/IntegrationTests/Services/Ordering/OrderingTestsStartup.cs
@@ -5,12 +5,13 @@ using System.Text;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Builder;
using IntegrationTests.Middleware;
+using Microsoft.Extensions.Configuration;
namespace IntegrationTests.Services.Ordering
{
public class OrderingTestsStartup : Startup
{
- public OrderingTestsStartup(IHostingEnvironment env) : base(env)
+ public OrderingTestsStartup(IConfiguration env) : base(env)
{
}