Merge from migration/net-5
This commit is contained in:
commit
bbef451d53
@ -10,5 +10,5 @@ metadata:
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
data:
|
||||
{{ (.Files.Glob "envoy.yaml").AsConfig | indent 2 }}
|
||||
{{ (.Files.Glob "envoy.yaml").AsConfig | indent 2 }}
|
||||
|
||||
|
@ -10,5 +10,5 @@ metadata:
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
data:
|
||||
{{ (.Files.Glob "envoy.yaml").AsConfig | indent 2 }}
|
||||
{{ (.Files.Glob "envoy.yaml").AsConfig | indent 2 }}
|
||||
|
||||
|
@ -10,5 +10,5 @@ metadata:
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
data:
|
||||
{{ (.Files.Glob "envoy.yaml").AsConfig | indent 2 -}}
|
||||
{{ (.Files.Glob "envoy.yaml").AsConfig | indent 2 -}}
|
||||
|
||||
|
@ -10,5 +10,5 @@ metadata:
|
||||
release: {{ .Release.Name }}
|
||||
heritage: {{ .Release.Service }}
|
||||
data:
|
||||
{{ (.Files.Glob "envoy.yaml").AsConfig | indent 2 }}
|
||||
{{ (.Files.Glob "envoy.yaml").AsConfig | indent 2 }}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
|
||||
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
|
||||
WORKDIR /src
|
||||
|
||||
# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles
|
||||
|
@ -1,7 +1,6 @@
|
||||
using Grpc.Core;
|
||||
using Grpc.Core.Interceptors;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Infrastructure
|
||||
@ -30,7 +29,6 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Infrastruct
|
||||
try
|
||||
{
|
||||
var response = await t;
|
||||
_logger.LogDebug($"Response received: {response}");
|
||||
return response;
|
||||
}
|
||||
catch (RpcException e)
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<AssemblyName>Mobile.Shopping.HttpAggregator</AssemblyName>
|
||||
<RootNamespace>Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator</RootNamespace>
|
||||
<DockerComposeProjectPath>..\..\..\docker-compose.dcproj</DockerComposeProjectPath>
|
||||
@ -15,20 +15,20 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="3.0.0" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="3.0.0" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.11.2" />
|
||||
<PackageReference Include="Grpc.AspNetCore.Server.ClientFactory" Version="2.25.0" />
|
||||
<PackageReference Include="Grpc.Core" Version="2.25.0" />
|
||||
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.25.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.25.0" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.0" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="3.1.2" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="3.1.2" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.14.0" />
|
||||
<PackageReference Include="Grpc.AspNetCore.Server.ClientFactory" Version="2.34.0" />
|
||||
<PackageReference Include="Grpc.Core" Version="2.34.0" />
|
||||
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.34.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.34.0" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="3.1.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="5.0.1" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0-dev-00834" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc5" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1,48 +1,32 @@
|
||||
using CatalogApi;
|
||||
using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Config;
|
||||
using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using static CatalogApi.Catalog;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services
|
||||
{
|
||||
public class CatalogService : ICatalogService
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly UrlsConfig _urls;
|
||||
private readonly Catalog.CatalogClient _client;
|
||||
|
||||
public CatalogService(HttpClient httpClient, IOptions<UrlsConfig> config)
|
||||
public CatalogService(Catalog.CatalogClient client)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
_urls = config.Value;
|
||||
_client = client;
|
||||
}
|
||||
|
||||
public async Task<CatalogItem> GetCatalogItemAsync(int id)
|
||||
{
|
||||
|
||||
return await GrpcCallerService.CallService(_urls.Catalog + UrlsConfig.CatalogOperations.GetItemById(id), async channel =>
|
||||
{
|
||||
var client = new CatalogClient(channel);
|
||||
var request = new CatalogItemRequest { Id = id };
|
||||
var response = await client.GetItemByIdAsync(request);
|
||||
return MapToCatalogItemResponse(response);
|
||||
});
|
||||
var request = new CatalogItemRequest { Id = id };
|
||||
var response = await _client.GetItemByIdAsync(request);
|
||||
return MapToCatalogItemResponse(response);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<CatalogItem>> GetCatalogItemsAsync(IEnumerable<int> ids)
|
||||
{
|
||||
|
||||
return await GrpcCallerService.CallService(_urls.GrpcCatalog, async channel=>
|
||||
{
|
||||
var client = new CatalogClient(channel);
|
||||
var request = new CatalogItemsRequest { Ids = string.Join(",", ids), PageIndex = 1, PageSize = 10 };
|
||||
var response = await client.GetItemsByIdsAsync(request);
|
||||
return response.Data.Select(this.MapToCatalogItemResponse);
|
||||
});
|
||||
var request = new CatalogItemsRequest { Ids = string.Join(",", ids), PageIndex = 1, PageSize = 10 };
|
||||
var response = await _client.GetItemsByIdsAsync(request);
|
||||
return response.Data.Select(MapToCatalogItemResponse);
|
||||
}
|
||||
|
||||
private CatalogItem MapToCatalogItemResponse(CatalogItemResponse catalogItemResponse)
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Devspaces.Support;
|
||||
using CatalogApi;
|
||||
using Devspaces.Support;
|
||||
using GrpcBasket;
|
||||
using GrpcOrdering;
|
||||
using HealthChecks.UI.Client;
|
||||
@ -182,9 +183,6 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator
|
||||
|
||||
//register http services
|
||||
|
||||
services.AddHttpClient<ICatalogService, CatalogService>()
|
||||
.AddDevspacesSupport();
|
||||
|
||||
services.AddHttpClient<IOrderApiClient, OrderApiClient>()
|
||||
.AddDevspacesSupport();
|
||||
|
||||
@ -193,7 +191,7 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator
|
||||
|
||||
public static IServiceCollection AddGrpcServices(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<GrpcExceptionInterceptor>();
|
||||
services.AddTransient<GrpcExceptionInterceptor>();
|
||||
|
||||
services.AddScoped<IBasketService, BasketService>();
|
||||
|
||||
@ -203,6 +201,14 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator
|
||||
options.Address = new Uri(basketApi);
|
||||
}).AddInterceptor<GrpcExceptionInterceptor>();
|
||||
|
||||
services.AddScoped<ICatalogService, CatalogService>();
|
||||
|
||||
services.AddGrpcClient<Catalog.CatalogClient>((services, options) =>
|
||||
{
|
||||
var catalogApi = services.GetRequiredService<IOptions<UrlsConfig>>().Value.GrpcCatalog;
|
||||
options.Address = new Uri(catalogApi);
|
||||
}).AddInterceptor<GrpcExceptionInterceptor>();
|
||||
|
||||
services.AddScoped<IOrderingService, OrderingService>();
|
||||
|
||||
services.AddGrpcClient<OrderingGrpc.OrderingGrpcClient>((services, options) =>
|
||||
|
@ -1,7 +1,6 @@
|
||||
using Grpc.Core;
|
||||
using Grpc.Core.Interceptors;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Infrastructure
|
||||
@ -30,7 +29,6 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Infrastructure
|
||||
try
|
||||
{
|
||||
var response = await t;
|
||||
_logger.LogDebug($"Response received: {response}");
|
||||
return response;
|
||||
}
|
||||
catch (RpcException e)
|
||||
|
@ -1,53 +1,41 @@
|
||||
using CatalogApi;
|
||||
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Config;
|
||||
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using static CatalogApi.Catalog;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services
|
||||
{
|
||||
public class CatalogService : ICatalogService
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly Catalog.CatalogClient _client;
|
||||
private readonly ILogger<CatalogService> _logger;
|
||||
private readonly UrlsConfig _urls;
|
||||
|
||||
public CatalogService(HttpClient httpClient, ILogger<CatalogService> logger, IOptions<UrlsConfig> config)
|
||||
public CatalogService(Catalog.CatalogClient client, ILogger<CatalogService> logger)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
_client = client;
|
||||
_logger = logger;
|
||||
_urls = config.Value;
|
||||
}
|
||||
|
||||
public async Task<CatalogItem> GetCatalogItemAsync(int id)
|
||||
{
|
||||
return await GrpcCallerService.CallService(_urls.GrpcCatalog, async channel =>
|
||||
{
|
||||
var client = new CatalogClient(channel);
|
||||
var request = new CatalogItemRequest { Id = id };
|
||||
_logger.LogInformation("grpc client created, request = {@request}", request);
|
||||
var response = await client.GetItemByIdAsync(request);
|
||||
_logger.LogInformation("grpc response {@response}", response);
|
||||
return MapToCatalogItemResponse(response);
|
||||
});
|
||||
var request = new CatalogItemRequest { Id = id };
|
||||
_logger.LogInformation("grpc request {@request}", request);
|
||||
var response = await _client.GetItemByIdAsync(request);
|
||||
_logger.LogInformation("grpc response {@response}", response);
|
||||
return MapToCatalogItemResponse(response);
|
||||
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<CatalogItem>> GetCatalogItemsAsync(IEnumerable<int> ids)
|
||||
{
|
||||
return await GrpcCallerService.CallService(_urls.GrpcCatalog, async channel =>
|
||||
{
|
||||
var client = new CatalogClient(channel);
|
||||
var request = new CatalogItemsRequest { Ids = string.Join(",", ids), PageIndex = 1, PageSize = 10 };
|
||||
_logger.LogInformation("grpc client created, request = {@request}", request);
|
||||
var response = await client.GetItemsByIdsAsync(request);
|
||||
_logger.LogInformation("grpc response {@response}", response);
|
||||
return response.Data.Select(this.MapToCatalogItemResponse);
|
||||
});
|
||||
var request = new CatalogItemsRequest { Ids = string.Join(",", ids), PageIndex = 1, PageSize = 10 };
|
||||
_logger.LogInformation("grpc request {@request}", request);
|
||||
var response = await _client.GetItemsByIdsAsync(request);
|
||||
_logger.LogInformation("grpc response {@response}", response);
|
||||
return response.Data.Select(this.MapToCatalogItemResponse);
|
||||
|
||||
}
|
||||
|
||||
private CatalogItem MapToCatalogItemResponse(CatalogItemResponse catalogItemResponse)
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Devspaces.Support;
|
||||
using CatalogApi;
|
||||
using Devspaces.Support;
|
||||
using GrpcBasket;
|
||||
using GrpcOrdering;
|
||||
using HealthChecks.UI.Client;
|
||||
@ -185,9 +186,6 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator
|
||||
|
||||
//register http services
|
||||
|
||||
services.AddHttpClient<ICatalogService, CatalogService>()
|
||||
.AddDevspacesSupport();
|
||||
|
||||
services.AddHttpClient<IOrderApiClient, OrderApiClient>()
|
||||
.AddHttpMessageHandler<HttpClientAuthorizationDelegatingHandler>()
|
||||
.AddDevspacesSupport();
|
||||
@ -197,7 +195,7 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator
|
||||
|
||||
public static IServiceCollection AddGrpcServices(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<GrpcExceptionInterceptor>();
|
||||
services.AddTransient<GrpcExceptionInterceptor>();
|
||||
|
||||
services.AddScoped<IBasketService, BasketService>();
|
||||
|
||||
@ -207,6 +205,14 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator
|
||||
options.Address = new Uri(basketApi);
|
||||
}).AddInterceptor<GrpcExceptionInterceptor>();
|
||||
|
||||
services.AddScoped<ICatalogService, CatalogService>();
|
||||
|
||||
services.AddGrpcClient<Catalog.CatalogClient>((services, options) =>
|
||||
{
|
||||
var catalogApi = services.GetRequiredService<IOptions<UrlsConfig>>().Value.GrpcCatalog;
|
||||
options.Address = new Uri(catalogApi);
|
||||
}).AddInterceptor<GrpcExceptionInterceptor>();
|
||||
|
||||
services.AddScoped<IOrderingService, OrderingService>();
|
||||
|
||||
services.AddGrpcClient<OrderingGrpc.OrderingGrpcClient>((services, options) =>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<DebugType>portable</DebugType>
|
||||
<PreserveCompilationContext>true</PreserveCompilationContext>
|
||||
<AssemblyName>Catalog.API</AssemblyName>
|
||||
@ -42,29 +42,30 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="3.0.0" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.AzureStorage" Version="3.0.1" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="3.0.3" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="3.0.0" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="3.0.0" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="5.0.1" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.11.2" />
|
||||
<PackageReference Include="Grpc.AspNetCore.Server" Version="2.25.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.25.0" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.12.0" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.12.0" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.1" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="3.2.2" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.AzureStorage" Version="3.3.1" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="3.1.4" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="3.2.0" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="3.1.2" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.14.0" />
|
||||
<PackageReference Include="Grpc.AspNetCore.Server" Version="2.34.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.34.0" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="3.1.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="3.1.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="3.1.10" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="5.0.1" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
|
||||
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.1-dev-00216" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0-dev-00834" />
|
||||
<PackageReference Include="Serilog.Sinks.Http" Version="5.2.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Http" Version="7.2.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Seq" Version="4.1.0-dev-00166" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc5" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
|
||||
<PackageReference Include="System.IO.Compression.ZipFile" Version="4.4.0-beta-24913-02" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -2,11 +2,11 @@
|
||||
{
|
||||
public class CatalogSettings
|
||||
{
|
||||
public string PicBaseUrl { get;set;}
|
||||
public string PicBaseUrl { get; set; }
|
||||
|
||||
public string EventBusConnection { get; set; }
|
||||
|
||||
public bool UseCustomizationData { get; set; }
|
||||
public bool AzureStorageEnabled { get; set; }
|
||||
public bool AzureStorageEnabled { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
EXPOSE 443
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
|
||||
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
|
||||
WORKDIR /src
|
||||
|
||||
# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles
|
||||
|
@ -1,9 +1,9 @@
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using Catalog.API.Extensions;
|
||||
using Catalog.API.Extensions;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
|
||||
using Microsoft.eShopOnContainers.Services.Catalog.API;
|
||||
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@ -12,121 +12,113 @@ using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Catalog.API
|
||||
var configuration = GetConfiguration();
|
||||
|
||||
Log.Logger = CreateSerilogLogger(configuration);
|
||||
|
||||
try
|
||||
{
|
||||
public class Program
|
||||
Log.Information("Configuring web host ({ApplicationContext})...", Program.AppName);
|
||||
var host = CreateHostBuilder(configuration, args);
|
||||
|
||||
Log.Information("Applying migrations ({ApplicationContext})...", Program.AppName);
|
||||
host.MigrateDbContext<CatalogContext>((context, services) =>
|
||||
{
|
||||
public static readonly string Namespace = typeof(Program).Namespace;
|
||||
public static readonly string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1);
|
||||
var env = services.GetService<IWebHostEnvironment>();
|
||||
var settings = services.GetService<IOptions<CatalogSettings>>();
|
||||
var logger = services.GetService<ILogger<CatalogContextSeed>>();
|
||||
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
var configuration = GetConfiguration();
|
||||
new CatalogContextSeed()
|
||||
.SeedAsync(context, env, settings, logger)
|
||||
.Wait();
|
||||
})
|
||||
.MigrateDbContext<IntegrationEventLogContext>((_, __) => { });
|
||||
|
||||
Log.Logger = CreateSerilogLogger(configuration);
|
||||
Log.Information("Starting web host ({ApplicationContext})...", Program.AppName);
|
||||
host.Run();
|
||||
|
||||
try
|
||||
{
|
||||
Log.Information("Configuring web host ({ApplicationContext})...", AppName);
|
||||
var host = CreateHostBuilder(configuration, args);
|
||||
|
||||
Log.Information("Applying migrations ({ApplicationContext})...", AppName);
|
||||
host.MigrateDbContext<CatalogContext>((context, services) =>
|
||||
{
|
||||
var env = services.GetService<IWebHostEnvironment>();
|
||||
var settings = services.GetService<IOptions<CatalogSettings>>();
|
||||
var logger = services.GetService<ILogger<CatalogContextSeed>>();
|
||||
|
||||
new CatalogContextSeed()
|
||||
.SeedAsync(context, env, settings, logger)
|
||||
.Wait();
|
||||
})
|
||||
.MigrateDbContext<IntegrationEventLogContext>((_, __) => { });
|
||||
|
||||
Log.Information("Starting web host ({ApplicationContext})...", AppName);
|
||||
host.Run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Fatal(ex, "Program terminated unexpectedly ({ApplicationContext})!", AppName);
|
||||
return 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Log.CloseAndFlush();
|
||||
}
|
||||
}
|
||||
|
||||
private static IWebHost CreateHostBuilder(IConfiguration configuration, string[] args) =>
|
||||
WebHost.CreateDefaultBuilder(args)
|
||||
.ConfigureAppConfiguration(x => x.AddConfiguration(configuration))
|
||||
.CaptureStartupErrors(false)
|
||||
.ConfigureKestrel(options =>
|
||||
{
|
||||
var ports = GetDefinedPorts(configuration);
|
||||
options.Listen(IPAddress.Any, ports.httpPort, listenOptions =>
|
||||
{
|
||||
listenOptions.Protocols = HttpProtocols.Http1AndHttp2;
|
||||
});
|
||||
options.Listen(IPAddress.Any, ports.grpcPort, listenOptions =>
|
||||
{
|
||||
listenOptions.Protocols = HttpProtocols.Http2;
|
||||
});
|
||||
|
||||
})
|
||||
.UseStartup<Startup>()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseWebRoot("Pics")
|
||||
.UseSerilog()
|
||||
.Build();
|
||||
|
||||
private static Serilog.ILogger CreateSerilogLogger(IConfiguration configuration)
|
||||
{
|
||||
var seqServerUrl = configuration["Serilog:SeqServerUrl"];
|
||||
var logstashUrl = configuration["Serilog:LogstashgUrl"];
|
||||
return new LoggerConfiguration()
|
||||
.MinimumLevel.Verbose()
|
||||
.Enrich.WithProperty("ApplicationContext", AppName)
|
||||
.Enrich.FromLogContext()
|
||||
.WriteTo.Console()
|
||||
.WriteTo.Seq(string.IsNullOrWhiteSpace(seqServerUrl) ? "http://seq" : seqServerUrl)
|
||||
.WriteTo.Http(string.IsNullOrWhiteSpace(logstashUrl) ? "http://logstash:8080" : logstashUrl)
|
||||
.ReadFrom.Configuration(configuration)
|
||||
.CreateLogger();
|
||||
}
|
||||
|
||||
private static (int httpPort, int grpcPort) GetDefinedPorts(IConfiguration config)
|
||||
{
|
||||
var grpcPort = config.GetValue("GRPC_PORT", 81);
|
||||
var port = config.GetValue("PORT", 80);
|
||||
return (port, grpcPort);
|
||||
}
|
||||
|
||||
private static IConfiguration GetConfiguration()
|
||||
{
|
||||
var builder = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||
.AddEnvironmentVariables();
|
||||
|
||||
var config = builder.Build();
|
||||
|
||||
if (config.GetValue<bool>("UseVault", false))
|
||||
{
|
||||
builder.AddAzureKeyVault(
|
||||
$"https://{config["Vault:Name"]}.vault.azure.net/",
|
||||
config["Vault:ClientId"],
|
||||
config["Vault:ClientSecret"]);
|
||||
}
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Fatal(ex, "Program terminated unexpectedly ({ApplicationContext})!", Program.AppName);
|
||||
return 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Log.CloseAndFlush();
|
||||
}
|
||||
|
||||
IWebHost CreateHostBuilder(IConfiguration configuration, string[] args) =>
|
||||
WebHost.CreateDefaultBuilder(args)
|
||||
.ConfigureAppConfiguration(x => x.AddConfiguration(configuration))
|
||||
.CaptureStartupErrors(false)
|
||||
.ConfigureKestrel(options =>
|
||||
{
|
||||
var ports = GetDefinedPorts(configuration);
|
||||
options.Listen(IPAddress.Any, ports.httpPort, listenOptions =>
|
||||
{
|
||||
listenOptions.Protocols = HttpProtocols.Http1AndHttp2;
|
||||
});
|
||||
options.Listen(IPAddress.Any, ports.grpcPort, listenOptions =>
|
||||
{
|
||||
listenOptions.Protocols = HttpProtocols.Http2;
|
||||
});
|
||||
|
||||
})
|
||||
.UseStartup<Startup>()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseWebRoot("Pics")
|
||||
.UseSerilog()
|
||||
.Build();
|
||||
|
||||
Serilog.ILogger CreateSerilogLogger(IConfiguration configuration)
|
||||
{
|
||||
var seqServerUrl = configuration["Serilog:SeqServerUrl"];
|
||||
var logstashUrl = configuration["Serilog:LogstashgUrl"];
|
||||
return new LoggerConfiguration()
|
||||
.MinimumLevel.Verbose()
|
||||
.Enrich.WithProperty("ApplicationContext", Program.AppName)
|
||||
.Enrich.FromLogContext()
|
||||
.WriteTo.Console()
|
||||
.WriteTo.Seq(string.IsNullOrWhiteSpace(seqServerUrl) ? "http://seq" : seqServerUrl)
|
||||
.WriteTo.Http(string.IsNullOrWhiteSpace(logstashUrl) ? "http://logstash:8080" : logstashUrl)
|
||||
.ReadFrom.Configuration(configuration)
|
||||
.CreateLogger();
|
||||
}
|
||||
|
||||
(int httpPort, int grpcPort) GetDefinedPorts(IConfiguration config)
|
||||
{
|
||||
var grpcPort = config.GetValue("GRPC_PORT", 81);
|
||||
var port = config.GetValue("PORT", 80);
|
||||
return (port, grpcPort);
|
||||
}
|
||||
|
||||
IConfiguration GetConfiguration()
|
||||
{
|
||||
var builder = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||
.AddEnvironmentVariables();
|
||||
|
||||
var config = builder.Build();
|
||||
|
||||
if (config.GetValue<bool>("UseVault", false))
|
||||
{
|
||||
builder.AddAzureKeyVault(
|
||||
$"https://{config["Vault:Name"]}.vault.azure.net/",
|
||||
config["Vault:ClientId"],
|
||||
config["Vault:ClientSecret"]);
|
||||
}
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
|
||||
public static class Program
|
||||
{
|
||||
public static string Namespace = typeof(Startup).Namespace;
|
||||
public static string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1);
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
@ -1,8 +1,8 @@
|
||||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
|
||||
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
|
||||
WORKDIR /src
|
||||
|
||||
# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<UserSecretsId>aspnet-eShopOnContainers.Identity-90487118-103c-4ff0-b9da-e5e26f7ab0c5</UserSecretsId>
|
||||
<DockerComposeProjectPath>..\..\..\..\docker-compose.dcproj</DockerComposeProjectPath>
|
||||
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
|
||||
{
|
||||
public class ConsentInputModel
|
||||
public record ConsentInputModel
|
||||
{
|
||||
public string Button { get; set; }
|
||||
public IEnumerable<string> ScopesConsented { get; set; }
|
||||
public bool RememberConsent { get; set; }
|
||||
public string ReturnUrl { get; set; }
|
||||
public string Button { get; init; }
|
||||
public IEnumerable<string> ScopesConsented { get; init; }
|
||||
public bool RememberConsent { get; init; }
|
||||
public string ReturnUrl { get; init; }
|
||||
}
|
||||
}
|
@ -1,12 +1,10 @@
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using IdentityServer4.Models;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
|
||||
{
|
||||
public class ConsentViewModel : ConsentInputModel
|
||||
public record ConsentViewModel : ConsentInputModel
|
||||
{
|
||||
public ConsentViewModel(ConsentInputModel model, string returnUrl, AuthorizationRequest request, Client client, Resources resources)
|
||||
{
|
||||
@ -24,16 +22,16 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewMo
|
||||
ResourceScopes = resources.ApiResources.SelectMany(x => x.Scopes).Select(x => new ScopeViewModel(x, ScopesConsented.Contains(x.Name) || model == null)).ToArray();
|
||||
}
|
||||
|
||||
public string ClientName { get; set; }
|
||||
public string ClientUrl { get; set; }
|
||||
public string ClientLogoUrl { get; set; }
|
||||
public bool AllowRememberConsent { get; set; }
|
||||
public string ClientName { get; init; }
|
||||
public string ClientUrl { get; init; }
|
||||
public string ClientLogoUrl { get; init; }
|
||||
public bool AllowRememberConsent { get; init; }
|
||||
|
||||
public IEnumerable<ScopeViewModel> IdentityScopes { get; set; }
|
||||
public IEnumerable<ScopeViewModel> ResourceScopes { get; set; }
|
||||
public IEnumerable<ScopeViewModel> IdentityScopes { get; init; }
|
||||
public IEnumerable<ScopeViewModel> ResourceScopes { get; init; }
|
||||
}
|
||||
|
||||
public class ScopeViewModel
|
||||
public record ScopeViewModel
|
||||
{
|
||||
public ScopeViewModel(Scope scope, bool check)
|
||||
{
|
||||
@ -55,11 +53,11 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewMo
|
||||
Checked = check || identity.Required;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public string DisplayName { get; set; }
|
||||
public string Description { get; set; }
|
||||
public bool Emphasize { get; set; }
|
||||
public bool Required { get; set; }
|
||||
public bool Checked { get; set; }
|
||||
public string Name { get; init; }
|
||||
public string DisplayName { get; init; }
|
||||
public string Description { get; init; }
|
||||
public bool Emphasize { get; init; }
|
||||
public bool Required { get; init; }
|
||||
public bool Checked { get; init; }
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
|
||||
{
|
||||
public class ForgotPasswordViewModel
|
||||
public record ForgotPasswordViewModel
|
||||
{
|
||||
[Required]
|
||||
[EmailAddress]
|
||||
public string Email { get; set; }
|
||||
public string Email { get; init; }
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
|
||||
{
|
||||
public class LoggedOutViewModel
|
||||
public record LoggedOutViewModel
|
||||
{
|
||||
public string PostLogoutRedirectUri { get; set; }
|
||||
public string ClientName { get; set; }
|
||||
public string SignOutIframeUrl { get; set; }
|
||||
public string PostLogoutRedirectUri { get; init; }
|
||||
public string ClientName { get; init; }
|
||||
public string SignOutIframeUrl { get; init; }
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
|
||||
{
|
||||
public class LoginViewModel
|
||||
public record LoginViewModel
|
||||
{
|
||||
[Required]
|
||||
[EmailAddress]
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
|
||||
{
|
||||
public class LogoutViewModel
|
||||
public record LogoutViewModel
|
||||
{
|
||||
public string LogoutId { get; set; }
|
||||
}
|
||||
|
@ -2,24 +2,24 @@
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
|
||||
{
|
||||
public class RegisterViewModel
|
||||
public record RegisterViewModel
|
||||
{
|
||||
[Required]
|
||||
[EmailAddress]
|
||||
[Display(Name = "Email")]
|
||||
public string Email { get; set; }
|
||||
public string Email { get; init; }
|
||||
|
||||
[Required]
|
||||
[StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
|
||||
[DataType(DataType.Password)]
|
||||
[Display(Name = "Password")]
|
||||
public string Password { get; set; }
|
||||
public string Password { get; init; }
|
||||
|
||||
[DataType(DataType.Password)]
|
||||
[Display(Name = "Confirm password")]
|
||||
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
|
||||
public string ConfirmPassword { get; set; }
|
||||
public string ConfirmPassword { get; init; }
|
||||
|
||||
public ApplicationUser User { get; set; }
|
||||
public ApplicationUser User { get; init; }
|
||||
}
|
||||
}
|
||||
|
@ -2,22 +2,22 @@
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
|
||||
{
|
||||
public class ResetPasswordViewModel
|
||||
public record ResetPasswordViewModel
|
||||
{
|
||||
[Required]
|
||||
[EmailAddress]
|
||||
public string Email { get; set; }
|
||||
public string Email { get; init; }
|
||||
|
||||
[Required]
|
||||
[StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
|
||||
[DataType(DataType.Password)]
|
||||
public string Password { get; set; }
|
||||
public string Password { get; init; }
|
||||
|
||||
[DataType(DataType.Password)]
|
||||
[Display(Name = "Confirm password")]
|
||||
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
|
||||
public string ConfirmPassword { get; set; }
|
||||
public string ConfirmPassword { get; init; }
|
||||
|
||||
public string Code { get; set; }
|
||||
public string Code { get; init; }
|
||||
}
|
||||
}
|
||||
|
@ -3,14 +3,14 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
|
||||
{
|
||||
public class SendCodeViewModel
|
||||
public record SendCodeViewModel
|
||||
{
|
||||
public string SelectedProvider { get; set; }
|
||||
public string SelectedProvider { get; init; }
|
||||
|
||||
public ICollection<SelectListItem> Providers { get; set; }
|
||||
public ICollection<SelectListItem> Providers { get; init; }
|
||||
|
||||
public string ReturnUrl { get; set; }
|
||||
public string ReturnUrl { get; init; }
|
||||
|
||||
public bool RememberMe { get; set; }
|
||||
public bool RememberMe { get; init; }
|
||||
}
|
||||
}
|
||||
|
@ -2,20 +2,20 @@
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
|
||||
{
|
||||
public class VerifyCodeViewModel
|
||||
public record VerifyCodeViewModel
|
||||
{
|
||||
[Required]
|
||||
public string Provider { get; set; }
|
||||
public string Provider { get; init; }
|
||||
|
||||
[Required]
|
||||
public string Code { get; set; }
|
||||
public string Code { get; init; }
|
||||
|
||||
public string ReturnUrl { get; set; }
|
||||
public string ReturnUrl { get; init; }
|
||||
|
||||
[Display(Name = "Remember this browser?")]
|
||||
public bool RememberBrowser { get; set; }
|
||||
public bool RememberBrowser { get; init; }
|
||||
|
||||
[Display(Name = "Remember me?")]
|
||||
public bool RememberMe { get; set; }
|
||||
public bool RememberMe { get; init; }
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ using IdentityServer4.Models;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models
|
||||
{
|
||||
public class ErrorViewModel
|
||||
public record ErrorViewModel
|
||||
{
|
||||
public ErrorMessage Error { get; set; }
|
||||
}
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels
|
||||
{
|
||||
public class AddPhoneNumberViewModel
|
||||
public record AddPhoneNumberViewModel
|
||||
{
|
||||
[Required]
|
||||
[Phone]
|
||||
[Display(Name = "Phone number")]
|
||||
public string PhoneNumber { get; set; }
|
||||
public string PhoneNumber { get; init; }
|
||||
}
|
||||
}
|
||||
|
@ -2,22 +2,22 @@
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels
|
||||
{
|
||||
public class ChangePasswordViewModel
|
||||
public record ChangePasswordViewModel
|
||||
{
|
||||
[Required]
|
||||
[DataType(DataType.Password)]
|
||||
[Display(Name = "Current password")]
|
||||
public string OldPassword { get; set; }
|
||||
public string OldPassword { get; init; }
|
||||
|
||||
[Required]
|
||||
[StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
|
||||
[DataType(DataType.Password)]
|
||||
[Display(Name = "New password")]
|
||||
public string NewPassword { get; set; }
|
||||
public string NewPassword { get; init; }
|
||||
|
||||
[DataType(DataType.Password)]
|
||||
[Display(Name = "Confirm new password")]
|
||||
[Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
|
||||
public string ConfirmPassword { get; set; }
|
||||
public string ConfirmPassword { get; init; }
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,10 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels
|
||||
{
|
||||
public class ConfigureTwoFactorViewModel
|
||||
public record ConfigureTwoFactorViewModel
|
||||
{
|
||||
public string SelectedProvider { get; set; }
|
||||
public string SelectedProvider { get; init; }
|
||||
|
||||
public ICollection<SelectListItem> Providers { get; set; }
|
||||
public ICollection<SelectListItem> Providers { get; init; }
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels
|
||||
{
|
||||
public class FactorViewModel
|
||||
public record FactorViewModel
|
||||
{
|
||||
public string Purpose { get; set; }
|
||||
public string Purpose { get; init; }
|
||||
}
|
||||
}
|
||||
|
@ -3,16 +3,16 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels
|
||||
{
|
||||
public class IndexViewModel
|
||||
public record IndexViewModel
|
||||
{
|
||||
public bool HasPassword { get; set; }
|
||||
public bool HasPassword { get; init; }
|
||||
|
||||
public IList<UserLoginInfo> Logins { get; set; }
|
||||
public IList<UserLoginInfo> Logins { get; init; }
|
||||
|
||||
public string PhoneNumber { get; set; }
|
||||
public string PhoneNumber { get; init; }
|
||||
|
||||
public bool TwoFactor { get; set; }
|
||||
public bool TwoFactor { get; init; }
|
||||
|
||||
public bool BrowserRemembered { get; set; }
|
||||
public bool BrowserRemembered { get; init; }
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,17 @@
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels
|
||||
{
|
||||
public class SetPasswordViewModel
|
||||
public record SetPasswordViewModel
|
||||
{
|
||||
[Required]
|
||||
[StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
|
||||
[DataType(DataType.Password)]
|
||||
[Display(Name = "New password")]
|
||||
public string NewPassword { get; set; }
|
||||
public string NewPassword { get; init; }
|
||||
|
||||
[DataType(DataType.Password)]
|
||||
[Display(Name = "Confirm new password")]
|
||||
[Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
|
||||
public string ConfirmPassword { get; set; }
|
||||
public string ConfirmPassword { get; init; }
|
||||
}
|
||||
}
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels
|
||||
{
|
||||
public class VerifyPhoneNumberViewModel
|
||||
public record VerifyPhoneNumberViewModel
|
||||
{
|
||||
[Required]
|
||||
public string Code { get; set; }
|
||||
public string Code { get; init; }
|
||||
|
||||
[Required]
|
||||
[Phone]
|
||||
[Display(Name = "Phone number")]
|
||||
public string PhoneNumber { get; set; }
|
||||
public string PhoneNumber { get; init; }
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using IdentityServer4.EntityFramework.DbContexts;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.eShopOnContainers.Services.Identity.API;
|
||||
using Microsoft.eShopOnContainers.Services.Identity.API.Data;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@ -11,103 +12,92 @@ using Serilog;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Identity.API
|
||||
string Namespace = typeof(Startup).Namespace;
|
||||
string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1);
|
||||
|
||||
var configuration = GetConfiguration();
|
||||
|
||||
Log.Logger = CreateSerilogLogger(configuration);
|
||||
|
||||
try
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static readonly string Namespace = typeof(Program).Namespace;
|
||||
public static readonly string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1);
|
||||
Log.Information("Configuring web host ({ApplicationContext})...", AppName);
|
||||
var host = BuildWebHost(configuration, args);
|
||||
|
||||
public static int Main(string[] args)
|
||||
Log.Information("Applying migrations ({ApplicationContext})...", AppName);
|
||||
host.MigrateDbContext<PersistedGrantDbContext>((_, __) => { })
|
||||
.MigrateDbContext<ApplicationDbContext>((context, services) =>
|
||||
{
|
||||
var configuration = GetConfiguration();
|
||||
var env = services.GetService<IWebHostEnvironment>();
|
||||
var logger = services.GetService<ILogger<ApplicationDbContextSeed>>();
|
||||
var settings = services.GetService<IOptions<AppSettings>>();
|
||||
|
||||
Log.Logger = CreateSerilogLogger(configuration);
|
||||
|
||||
try
|
||||
{
|
||||
Log.Information("Configuring web host ({ApplicationContext})...", AppName);
|
||||
var host = BuildWebHost(configuration, args);
|
||||
|
||||
Log.Information("Applying migrations ({ApplicationContext})...", AppName);
|
||||
host.MigrateDbContext<PersistedGrantDbContext>((_, __) => { })
|
||||
.MigrateDbContext<ApplicationDbContext>((context, services) =>
|
||||
{
|
||||
var env = services.GetService<IWebHostEnvironment>();
|
||||
var logger = services.GetService<ILogger<ApplicationDbContextSeed>>();
|
||||
var settings = services.GetService<IOptions<AppSettings>>();
|
||||
|
||||
new ApplicationDbContextSeed()
|
||||
.SeedAsync(context, env, logger, settings)
|
||||
.Wait();
|
||||
})
|
||||
.MigrateDbContext<ConfigurationDbContext>((context, services) =>
|
||||
{
|
||||
new ConfigurationDbContextSeed()
|
||||
.SeedAsync(context, configuration)
|
||||
.Wait();
|
||||
});
|
||||
|
||||
Log.Information("Starting web host ({ApplicationContext})...", AppName);
|
||||
host.Run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Fatal(ex, "Program terminated unexpectedly ({ApplicationContext})!", AppName);
|
||||
return 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Log.CloseAndFlush();
|
||||
}
|
||||
}
|
||||
|
||||
private static IWebHost BuildWebHost(IConfiguration configuration, string[] args) =>
|
||||
WebHost.CreateDefaultBuilder(args)
|
||||
.CaptureStartupErrors(false)
|
||||
.ConfigureAppConfiguration(x => x.AddConfiguration(configuration))
|
||||
.UseStartup<Startup>()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseSerilog()
|
||||
.Build();
|
||||
|
||||
private static Serilog.ILogger CreateSerilogLogger(IConfiguration configuration)
|
||||
new ApplicationDbContextSeed()
|
||||
.SeedAsync(context, env, logger, settings)
|
||||
.Wait();
|
||||
})
|
||||
.MigrateDbContext<ConfigurationDbContext>((context, services) =>
|
||||
{
|
||||
var seqServerUrl = configuration["Serilog:SeqServerUrl"];
|
||||
var logstashUrl = configuration["Serilog:LogstashgUrl"];
|
||||
return new LoggerConfiguration()
|
||||
.MinimumLevel.Verbose()
|
||||
.Enrich.WithProperty("ApplicationContext", AppName)
|
||||
.Enrich.FromLogContext()
|
||||
.WriteTo.Console()
|
||||
.WriteTo.Seq(string.IsNullOrWhiteSpace(seqServerUrl) ? "http://seq" : seqServerUrl)
|
||||
.WriteTo.Http(string.IsNullOrWhiteSpace(logstashUrl) ? "http://localhost:8080" : logstashUrl)
|
||||
.ReadFrom.Configuration(configuration)
|
||||
.CreateLogger();
|
||||
}
|
||||
new ConfigurationDbContextSeed()
|
||||
.SeedAsync(context, configuration)
|
||||
.Wait();
|
||||
});
|
||||
|
||||
private static IConfiguration GetConfiguration()
|
||||
{
|
||||
var builder = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||
.AddEnvironmentVariables();
|
||||
Log.Information("Starting web host ({ApplicationContext})...", AppName);
|
||||
host.Run();
|
||||
|
||||
var config = builder.Build();
|
||||
|
||||
if (config.GetValue<bool>("UseVault", false))
|
||||
{
|
||||
builder.AddAzureKeyVault(
|
||||
$"https://{config["Vault:Name"]}.vault.azure.net/",
|
||||
config["Vault:ClientId"],
|
||||
config["Vault:ClientSecret"]);
|
||||
}
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Fatal(ex, "Program terminated unexpectedly ({ApplicationContext})!", AppName);
|
||||
return 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Log.CloseAndFlush();
|
||||
}
|
||||
|
||||
IWebHost BuildWebHost(IConfiguration configuration, string[] args) =>
|
||||
WebHost.CreateDefaultBuilder(args)
|
||||
.CaptureStartupErrors(false)
|
||||
.ConfigureAppConfiguration(x => x.AddConfiguration(configuration))
|
||||
.UseStartup<Startup>()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseSerilog()
|
||||
.Build();
|
||||
|
||||
Serilog.ILogger CreateSerilogLogger(IConfiguration configuration)
|
||||
{
|
||||
var seqServerUrl = configuration["Serilog:SeqServerUrl"];
|
||||
var logstashUrl = configuration["Serilog:LogstashgUrl"];
|
||||
return new LoggerConfiguration()
|
||||
.MinimumLevel.Verbose()
|
||||
.Enrich.WithProperty("ApplicationContext", AppName)
|
||||
.Enrich.FromLogContext()
|
||||
.WriteTo.Console()
|
||||
.WriteTo.Seq(string.IsNullOrWhiteSpace(seqServerUrl) ? "http://seq" : seqServerUrl)
|
||||
.WriteTo.Http(string.IsNullOrWhiteSpace(logstashUrl) ? "http://localhost:8080" : logstashUrl)
|
||||
.ReadFrom.Configuration(configuration)
|
||||
.CreateLogger();
|
||||
}
|
||||
|
||||
IConfiguration GetConfiguration()
|
||||
{
|
||||
var builder = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||
.AddEnvironmentVariables();
|
||||
|
||||
var config = builder.Build();
|
||||
|
||||
if (config.GetValue<bool>("UseVault", false))
|
||||
{
|
||||
builder.AddAzureKeyVault(
|
||||
$"https://{config["Vault:Name"]}.vault.azure.net/",
|
||||
config["Vault:ClientId"],
|
||||
config["Vault:ClientSecret"]);
|
||||
}
|
||||
|
||||
return builder.Build();
|
||||
}
|
@ -14,7 +14,7 @@ import { Header } from '../shared/components/header/header';
|
||||
exports: [BasketStatusComponent]
|
||||
})
|
||||
export class BasketModule {
|
||||
static forRoot(): ModuleWithProviders {
|
||||
static forRoot(): ModuleWithProviders<BasketModule> {
|
||||
return {
|
||||
ngModule: BasketModule,
|
||||
providers: [
|
||||
|
@ -22,14 +22,14 @@ export class CampaignsComponent implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
if (this.configurationService.isReady) {
|
||||
this.isCampaignDetailFunctionEnabled = this.configurationService.serverSettings.activateCampaignDetailFunction;
|
||||
this.getCampaigns(9, 0)
|
||||
} else {
|
||||
this.configurationService.settingsLoaded$.subscribe(x => {
|
||||
this.isCampaignDetailFunctionEnabled = this.configurationService.serverSettings.activateCampaignDetailFunction;
|
||||
this.getCampaigns(9, 0);
|
||||
});
|
||||
}
|
||||
|
||||
this.isCampaignDetailFunctionEnabled = this.configurationService.serverSettings.activateCampaignDetailFunction;
|
||||
}
|
||||
|
||||
onPageChanged(value: any) {
|
||||
|
@ -56,6 +56,9 @@ export class CatalogComponent implements OnInit {
|
||||
|
||||
onFilterApplied(event: any) {
|
||||
event.preventDefault();
|
||||
|
||||
this.brandSelected = this.brandSelected && this.brandSelected.toString() != "null" ? this.brandSelected : null;
|
||||
this.typeSelected = this.typeSelected && this.typeSelected.toString() != "null" ? this.typeSelected : null;
|
||||
this.getCatalog(this.paginationInfo.itemsPage, this.paginationInfo.actualPage, this.brandSelected, this.typeSelected);
|
||||
}
|
||||
|
||||
@ -82,6 +85,7 @@ export class CatalogComponent implements OnInit {
|
||||
|
||||
getCatalog(pageSize: number, pageIndex: number, brand?: number, type?: number) {
|
||||
this.errorReceived = false;
|
||||
|
||||
this.service.getCatalog(pageIndex, pageSize, brand, type)
|
||||
.pipe(catchError((err) => this.handleError(err)))
|
||||
.subscribe(catalog => {
|
||||
|
@ -29,7 +29,7 @@ export class Identity implements OnInit {
|
||||
this.service.AuthorizedCallback();
|
||||
}
|
||||
|
||||
console.log('identity component, checking authorized' + this.service.IsAuthorized);
|
||||
console.log('identity component, checking authorized ' + this.service.IsAuthorized);
|
||||
this.authenticated = this.service.IsAuthorized;
|
||||
|
||||
if (this.authenticated) {
|
||||
|
@ -57,7 +57,7 @@ import { UppercasePipe } from './pipes/uppercase.pipe';
|
||||
]
|
||||
})
|
||||
export class SharedModule {
|
||||
static forRoot(): ModuleWithProviders {
|
||||
static forRoot(): ModuleWithProviders<SharedModule> {
|
||||
return {
|
||||
ngModule: SharedModule,
|
||||
providers: [
|
||||
|
@ -2,12 +2,14 @@
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../out-tsc/app",
|
||||
"module": "es2015",
|
||||
"baseUrl": "",
|
||||
"types": []
|
||||
},
|
||||
"exclude": [
|
||||
"test.ts",
|
||||
"**/*.spec.ts"
|
||||
"files": [
|
||||
"main.ts",
|
||||
"polyfills.ts"
|
||||
],
|
||||
"include": [
|
||||
"Client/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../out-tsc/spec",
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"baseUrl": "",
|
||||
"types": [
|
||||
|
@ -1,4 +1,4 @@
|
||||
ARG NODE_IMAGE=node:8.16
|
||||
ARG NODE_IMAGE=node:12.0
|
||||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
@ -27,6 +27,12 @@
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"budgets": [
|
||||
{
|
||||
"type": "anyComponentStyle",
|
||||
"maximumWarning": "6kb"
|
||||
}
|
||||
],
|
||||
"optimization": true,
|
||||
"outputHashing": "all",
|
||||
"sourceMap": false,
|
||||
@ -119,10 +125,13 @@
|
||||
"schematics": {
|
||||
"@schematics/angular:component": {
|
||||
"prefix": "app",
|
||||
"styleext": "scss"
|
||||
"style": "scss"
|
||||
},
|
||||
"@schematics/angular:directive": {
|
||||
"prefix": "app"
|
||||
}
|
||||
},
|
||||
"cli": {
|
||||
"analytics": false
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"IdentityUrl": "http://localhost:5105",
|
||||
"MarketingUrl": "http://localhost:5110",
|
||||
"MarketingUrl": "http://localhost:5203",
|
||||
"CallBackUrl": "http://localhost:5104/",
|
||||
"PurchaseUrl": "http://localhost:5202",
|
||||
"PurchaseUrlHC": "http://localhost:5202/hc",
|
||||
|
16920
src/Web/WebSPA/package-lock.json
generated
16920
src/Web/WebSPA/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -27,17 +27,18 @@
|
||||
"lint:ts": "tslint -c tslint.json Client/**/*.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@angular/animations": "8.2.14",
|
||||
"@angular/common": "8.2.14",
|
||||
"@angular/compiler": "8.2.14",
|
||||
"@angular/core": "8.2.14",
|
||||
"@angular/forms": "8.2.14",
|
||||
"@angular/platform-browser": "8.2.14",
|
||||
"@angular/platform-browser-dynamic": "8.2.14",
|
||||
"@angular/platform-server": "8.2.14",
|
||||
"@angular/router": "8.2.14",
|
||||
"@angular-devkit/schematics": "^11.0.4",
|
||||
"@angular/animations": "10.2.3",
|
||||
"@angular/common": "10.2.3",
|
||||
"@angular/compiler": "10.2.3",
|
||||
"@angular/core": "10.2.3",
|
||||
"@angular/forms": "10.2.3",
|
||||
"@angular/platform-browser": "10.2.3",
|
||||
"@angular/platform-browser-dynamic": "10.2.3",
|
||||
"@angular/platform-server": "10.2.3",
|
||||
"@angular/router": "10.2.3",
|
||||
"@microsoft/signalr": "3.0.1",
|
||||
"@ng-bootstrap/ng-bootstrap": "5.2.1",
|
||||
"@ng-bootstrap/ng-bootstrap": "^8.0.0",
|
||||
"@popperjs/core": "2.0.0",
|
||||
"acorn": "^6.4.1",
|
||||
"acorn-dynamic-import": "4.0.0",
|
||||
@ -47,48 +48,50 @@
|
||||
"font-awesome": "4.7.0",
|
||||
"isomorphic-fetch": "2.2.1",
|
||||
"jquery": "3.5.0",
|
||||
"ngx-toastr": "10.1.0",
|
||||
"ngx-toastr": "^13.2.0",
|
||||
"normalize.css": "8.0.0",
|
||||
"popper.js": "1.16.1",
|
||||
"rxjs": "~6.4.0",
|
||||
"rxjs-compat": "~6.4.0",
|
||||
"rxjs": "^6.5.2",
|
||||
"rxjs-compat": "^6.5.2",
|
||||
"tslib": "^2.0.0",
|
||||
"typedoc": "^0.19.2",
|
||||
"webpack-dev-server": "3.1.14",
|
||||
"zone.js": "~0.9.1"
|
||||
"zone.js": "~0.10.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "0.803.23",
|
||||
"@angular/cli": "8.3.23",
|
||||
"@angular/compiler-cli": "8.2.14",
|
||||
"@angular/language-service": "8.2.14",
|
||||
"@angular-devkit/build-angular": "~0.1002.0",
|
||||
"@angular/cli": "10.2.0",
|
||||
"@angular/compiler-cli": "10.2.3",
|
||||
"@angular/language-service": "10.2.3",
|
||||
"@types/core-js": "2.5.0",
|
||||
"@types/hammerjs": "2.0.35",
|
||||
"@types/jasmine": "^3.5.10",
|
||||
"@types/node": "^11.15.9",
|
||||
"@types/node": "^12.11.1",
|
||||
"@types/protractor": "4.0.0",
|
||||
"@types/selenium-webdriver": "3.0.10",
|
||||
"codelyzer": "^5.2.2",
|
||||
"codelyzer": "^5.1.2",
|
||||
"eslint": "^6.8.0",
|
||||
"handlebars": "^4.7.6",
|
||||
"jasmine-core": "^3.5.0",
|
||||
"jasmine-spec-reporter": "^4.2.1",
|
||||
"karma": "^4.4.1",
|
||||
"karma-chrome-launcher": "^2.2.0",
|
||||
"jasmine-core": "~3.5.0",
|
||||
"jasmine-spec-reporter": "~5.0.0",
|
||||
"karma": "~5.0.0",
|
||||
"karma-chrome-launcher": "~3.1.0",
|
||||
"karma-cli": "^2.0.0",
|
||||
"karma-jasmine": "^2.0.1",
|
||||
"karma-jasmine-html-reporter": "^1.5.3",
|
||||
"karma-jasmine": "~4.0.0",
|
||||
"karma-jasmine-html-reporter": "^1.5.0",
|
||||
"lodash": "^4.17.19",
|
||||
"merge": "1.2.1",
|
||||
"npm-watch": "0.5.0",
|
||||
"protractor": "^5.4.3",
|
||||
"protractor": "~7.0.0",
|
||||
"rxjs-tslint": "^0.1.7",
|
||||
"sass-lint": "1.12.1",
|
||||
"ts-helpers": "1.1.2",
|
||||
"ts-node": "~7.0.1",
|
||||
"tslint": "^5.14.0",
|
||||
"tslint": "~6.1.0",
|
||||
"typedoc": "^0.19.2",
|
||||
"typescript": "3.4.5",
|
||||
"typescript": "4.0.5",
|
||||
"url-loader": "1.1.1",
|
||||
"webpack": "^4.42.1"
|
||||
}
|
||||
},
|
||||
"peerDependencies": {}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
"moduleResolution": "node",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"target": "es5",
|
||||
"target": "es2018",
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
],
|
||||
@ -16,7 +16,7 @@
|
||||
"es2016",
|
||||
"dom"
|
||||
],
|
||||
"module": "es2015"
|
||||
"module": "es2020"
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
"enableIvy": false
|
||||
|
@ -49,6 +49,9 @@
|
||||
true,
|
||||
"check-space"
|
||||
],
|
||||
"deprecation": {
|
||||
"severity": "warning"
|
||||
},
|
||||
"indent": [
|
||||
true,
|
||||
"spaces"
|
||||
|
Loading…
x
Reference in New Issue
Block a user