From ab1d9cc8971cf8d8a2bf8af04389de277b96dc63 Mon Sep 17 00:00:00 2001 From: Sumit Ghosh Date: Mon, 4 Oct 2021 19:39:36 +0530 Subject: [PATCH] Updates `basket-api` to .NET 6 (#1742) * Use global usings * Use file-scoped namespaces * Updates docker images to preview 7 * Created a new migration plan * Included global usings for identity project * Updated docker file to preview version to 7 * Updated dockerfiles * Merged conent from Startup.cs to Program.cs * Removed Starup.cs * Removed unnecessary files * Revert "Removed unnecessary files" This reverts commit 536bddcd96b54673401cedbe802520dce12b3472. * Revert "Removed Starup.cs" This reverts commit 46175d7aa97475d88ec46bce39ed498c7037d924. * Revert "Merged conent from Startup.cs to Program.cs" This reverts commit 2766ea86dfef9220fe3f0c27a37a9a6c18153078. * Removed extra spaces * Updated basket-api project file * Update src/Services/Basket/Basket.API/Grpc/BasketService.cs Co-authored-by: David Pine * Apply suggestions from code review Co-authored-by: David Pine * Moved the fully qualified namespace on top * Updated relevant packages in basket.api project * Updated relevant packages in identity.api project Co-authored-by: David Pine --- .../Mobile.Bff.Shopping/aggregator/Dockerfile | 4 +- .../Web.Bff.Shopping/aggregator/Dockerfile | 4 +- ...orizationHeaderParameterOperationFilter.cs | 40 +- .../Basket/Basket.API/Basket.API.csproj | 44 +- .../Basket/Basket.API/BasketSettings.cs | 10 +- .../Controllers/BasketController.cs | 166 ++--- .../Basket.API/Controllers/HomeController.cs | 14 +- src/Services/Basket/Basket.API/Dockerfile | 4 +- .../Basket/Basket.API/GlobalUsings.cs | 61 ++ .../Basket/Basket.API/Grpc/BasketService.cs | 156 ++--- .../InternalServerErrorObjectResult.cs | 15 +- .../Exceptions/BasketDomainException.cs | 27 +- .../FailingMiddlewareAppBuilderExtensions.cs | 28 +- .../Filters/HttpGlobalExceptionFilter.cs | 77 +- .../Filters/JsonErrorResponse.cs | 14 +- .../Filters/ValidateModelStateFilter.cs | 42 +- .../AuthorizeCheckOperationFilter.cs | 49 +- .../Middlewares/FailingMiddleware.cs | 153 ++-- .../Middlewares/FailingOptions.cs | 14 +- .../Middlewares/FailingStartupFilter.cs | 30 +- .../FailingWebHostBuilderExtensions.cs | 20 +- .../Repositories/RedisBasketRepository.cs | 109 ++- .../OrderStartedIntegrationEventHandler.cs | 42 +- ...ductPriceChangedIntegrationEventHandler.cs | 93 ++- .../Events/OrderStartedIntegrationEvent.cs | 20 +- .../ProductPriceChangedIntegrationEvent.cs | 34 +- .../UserCheckoutAcceptedIntegrationEvent.cs | 113 ++- .../Basket/Basket.API/Model/BasketCheckout.cs | 32 +- .../Basket/Basket.API/Model/BasketItem.cs | 37 +- .../Basket/Basket.API/Model/CustomerBasket.cs | 26 +- .../Basket.API/Model/IBasketRepository.cs | 17 +- src/Services/Basket/Basket.API/Program.cs | 16 +- .../Basket.API/Services/IIdentityService.cs | 10 +- .../Basket.API/Services/IdentityService.cs | 26 +- src/Services/Basket/Basket.API/Startup.cs | 660 +++++++++--------- .../TestHttpResponseTrailersFeature.cs | 12 +- src/Services/Catalog/Catalog.API/Dockerfile | 4 +- .../Identity.API/Certificate/Certificate.cs | 6 +- .../Identity.API/Configuration/Config.cs | 9 +- .../Controllers/AccountController.cs | 21 +- .../Controllers/ConsentController.cs | 11 +- .../Controllers/HomeController.cs | 10 +- .../Identity.API/Data/ApplicationDbContext.cs | 6 +- .../Data/ApplicationDbContextSeed.cs | 20 +- .../Data/ConfigurationDbContextSeed.cs | 10 +- .../DevspacesRedirectUriValidator.cs | 12 +- .../IdentityDevspacesBuilderExtensions.cs | 4 +- src/Services/Identity/Identity.API/Dockerfile | 4 +- .../Extensions/LinqSelectExtensions.cs | 6 +- .../Factories/ApplicationDbContextFactory.cs | 8 +- .../ConfigurationDbContextFactory.cs | 9 +- .../PersistedGrantDbContextFactory.cs | 9 +- .../Identity/Identity.API/GlobalUsings.cs | 183 +++++ .../Identity.API/IWebHostExtensions.cs | 8 - .../Identity/Identity.API/Identity.API.csproj | 49 +- ...210813072445_InitialMigration.Designer.cs} | 167 +++-- ....cs => 20210813072445_InitialMigration.cs} | 105 ++- .../ApplicationDbContextModelSnapshot.cs | 165 +++-- ...210813072543_InitialMigration.Designer.cs} | 463 ++++++++---- ....cs => 20210813072543_InitialMigration.cs} | 297 ++++---- .../ConfigurationDbContextModelSnapshot.cs | 459 ++++++++---- ...29092100_InitialPersistedGrantMigration.cs | 65 -- ...210813072513_InitialMigration.Designer.cs} | 56 +- .../20210813072513_InitialMigration.cs | 75 ++ .../PersistedGrantDbContextModelSnapshot.cs | 52 +- .../AccountViewModels/ConsentInputModel.cs | 4 +- .../AccountViewModels/ConsentViewModel.cs | 2 - .../ForgotPasswordViewModel.cs | 4 +- .../AccountViewModels/LoginViewModel.cs | 4 +- .../AccountViewModels/RegisterViewModel.cs | 4 +- .../ResetPasswordViewModel.cs | 4 +- .../AccountViewModels/SendCodeViewModel.cs | 5 +- .../AccountViewModels/VerifyCodeViewModel.cs | 4 +- .../Identity.API/Models/ApplicationUser.cs | 5 +- .../Identity.API/Models/ErrorViewModel.cs | 4 - .../AddPhoneNumberViewModel.cs | 4 +- .../ChangePasswordViewModel.cs | 4 +- .../ConfigureTwoFactorViewModel.cs | 5 +- .../Models/ManageViewModels/IndexViewModel.cs | 5 +- .../ManageViewModels/SetPasswordViewModel.cs | 4 +- .../VerifyPhoneNumberViewModel.cs | 4 +- src/Services/Identity/Identity.API/Program.cs | 18 +- .../Identity.API/Services/EFLoginService.cs | 7 +- .../Identity.API/Services/ILoginService.cs | 5 +- .../Identity.API/Services/ProfileService.cs | 14 +- .../Identity.API/Services/RedirectService.cs | 4 +- src/Services/Identity/Identity.API/Startup.cs | 31 +- src/Services/Ordering/Ordering.API/Dockerfile | 4 +- .../Ordering.BackgroundTasks/Dockerfile | 4 +- .../Ordering/Ordering.SignalrHub/Dockerfile | 4 +- src/Services/Payment/Payment.API/Dockerfile | 4 +- src/Services/Webhooks/Webhooks.API/Dockerfile | 4 +- src/Web/WebMVC/Dockerfile | 4 +- src/Web/WebSPA/Dockerfile | 4 +- src/Web/WebhookClient/Dockerfile | 4 +- 95 files changed, 2547 insertions(+), 2142 deletions(-) create mode 100644 src/Services/Basket/Basket.API/GlobalUsings.cs create mode 100644 src/Services/Identity/Identity.API/GlobalUsings.cs rename src/Services/Identity/Identity.API/Migrations/{20190729091724_InitialMigration.Designer.cs => 20210813072445_InitialMigration.Designer.cs} (54%) rename src/Services/Identity/Identity.API/Migrations/{20190729091724_InitialMigration.cs => 20210813072445_InitialMigration.cs} (57%) rename src/Services/Identity/Identity.API/Migrations/ConfigurationDb/{20190729092011_InitialConfigurationMigration.Designer.cs => 20210813072543_InitialMigration.Designer.cs} (57%) rename src/Services/Identity/Identity.API/Migrations/ConfigurationDb/{20190729092011_InitialConfigurationMigration.cs => 20210813072543_InitialMigration.cs} (59%) delete mode 100644 src/Services/Identity/Identity.API/Migrations/PersistedGrantDb/20190729092100_InitialPersistedGrantMigration.cs rename src/Services/Identity/Identity.API/Migrations/PersistedGrantDb/{20190729092100_InitialPersistedGrantMigration.Designer.cs => 20210813072513_InitialMigration.Designer.cs} (54%) create mode 100644 src/Services/Identity/Identity.API/Migrations/PersistedGrantDb/20210813072513_InitialMigration.cs diff --git a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Dockerfile b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Dockerfile index 678ae3c8e..4519a8cfc 100644 --- a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Dockerfile +++ b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Dockerfile @@ -1,8 +1,8 @@ -FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.6 AS base +FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.7 AS base WORKDIR /app EXPOSE 80 -FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.6 AS build +FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.7 AS build WORKDIR /src # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/Dockerfile b/src/ApiGateways/Web.Bff.Shopping/aggregator/Dockerfile index bf1ad2358..61337cbf5 100644 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/Dockerfile +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/Dockerfile @@ -1,8 +1,8 @@ -FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.6 AS base +FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.7 AS base WORKDIR /app EXPOSE 80 -FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.6 AS build +FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.7 AS build WORKDIR /src # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles diff --git a/src/Services/Basket/Basket.API/Auth/Server/AuthorizationHeaderParameterOperationFilter.cs b/src/Services/Basket/Basket.API/Auth/Server/AuthorizationHeaderParameterOperationFilter.cs index 3d505b4ee..2acda7be8 100644 --- a/src/Services/Basket/Basket.API/Auth/Server/AuthorizationHeaderParameterOperationFilter.cs +++ b/src/Services/Basket/Basket.API/Auth/Server/AuthorizationHeaderParameterOperationFilter.cs @@ -1,33 +1,25 @@ -using Microsoft.AspNetCore.Mvc.Authorization; -using Microsoft.OpenApi.Models; -using Swashbuckle.AspNetCore.SwaggerGen; -using System.Collections.Generic; -using System.Linq; +namespace Microsoft.eShopOnContainers.Services.Basket.API.Auth.Server; -namespace Microsoft.eShopOnContainers.Services.Basket.API.Auth.Server +public class AuthorizationHeaderParameterOperationFilter : IOperationFilter { - public class AuthorizationHeaderParameterOperationFilter : IOperationFilter + public void Apply(OpenApiOperation operation, OperationFilterContext context) { - public void Apply(OpenApiOperation operation, OperationFilterContext context) + var filterPipeline = context.ApiDescription.ActionDescriptor.FilterDescriptors; + var isAuthorized = filterPipeline.Select(filterInfo => filterInfo.Filter).Any(filter => filter is AuthorizeFilter); + var allowAnonymous = filterPipeline.Select(filterInfo => filterInfo.Filter).Any(filter => filter is IAllowAnonymousFilter); + + if (isAuthorized && !allowAnonymous) { - var filterPipeline = context.ApiDescription.ActionDescriptor.FilterDescriptors; - var isAuthorized = filterPipeline.Select(filterInfo => filterInfo.Filter).Any(filter => filter is AuthorizeFilter); - var allowAnonymous = filterPipeline.Select(filterInfo => filterInfo.Filter).Any(filter => filter is IAllowAnonymousFilter); + operation.Parameters ??= new List(); - if (isAuthorized && !allowAnonymous) + + operation.Parameters.Add(new OpenApiParameter { - if (operation.Parameters == null) - operation.Parameters = new List(); - - - operation.Parameters.Add(new OpenApiParameter - { - Name = "Authorization", - In = ParameterLocation.Header, - Description = "access token", - Required = true - }); - } + Name = "Authorization", + In = ParameterLocation.Header, + Description = "access token", + Required = true + }); } } } diff --git a/src/Services/Basket/Basket.API/Basket.API.csproj b/src/Services/Basket/Basket.API/Basket.API.csproj index 77138f6a9..293d378ae 100644 --- a/src/Services/Basket/Basket.API/Basket.API.csproj +++ b/src/Services/Basket/Basket.API/Basket.API.csproj @@ -1,5 +1,4 @@  - net6.0 $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; @@ -15,31 +14,37 @@ - - + + + + - + - + - - - - - - - + + + + + + + - - - - - - + + + + + + + + + - + + @@ -53,5 +58,4 @@ - diff --git a/src/Services/Basket/Basket.API/BasketSettings.cs b/src/Services/Basket/Basket.API/BasketSettings.cs index 064d615ec..9db883101 100644 --- a/src/Services/Basket/Basket.API/BasketSettings.cs +++ b/src/Services/Basket/Basket.API/BasketSettings.cs @@ -1,7 +1,7 @@ -namespace Microsoft.eShopOnContainers.Services.Basket.API +namespace Microsoft.eShopOnContainers.Services.Basket.API; + +public class BasketSettings { - public class BasketSettings - { - public string ConnectionString { get; set; } - } + public string ConnectionString { get; set; } } + diff --git a/src/Services/Basket/Basket.API/Controllers/BasketController.cs b/src/Services/Basket/Basket.API/Controllers/BasketController.cs index 0a3b5879b..5468bbc15 100644 --- a/src/Services/Basket/Basket.API/Controllers/BasketController.cs +++ b/src/Services/Basket/Basket.API/Controllers/BasketController.cs @@ -1,103 +1,89 @@ -using Basket.API.IntegrationEvents.Events; -using Basket.API.Model; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; -using Microsoft.eShopOnContainers.Services.Basket.API.Model; -using Microsoft.eShopOnContainers.Services.Basket.API.Services; -using Microsoft.Extensions.Logging; -using System; -using System.Net; -using System.Security.Claims; -using System.Threading.Tasks; +namespace Microsoft.eShopOnContainers.Services.Basket.API.Controllers; -namespace Microsoft.eShopOnContainers.Services.Basket.API.Controllers +[Route("api/v1/[controller]")] +[Authorize] +[ApiController] +public class BasketController : ControllerBase { - [Route("api/v1/[controller]")] - [Authorize] - [ApiController] - public class BasketController : ControllerBase + private readonly IBasketRepository _repository; + private readonly IIdentityService _identityService; + private readonly IEventBus _eventBus; + private readonly ILogger _logger; + + public BasketController( + ILogger logger, + IBasketRepository repository, + IIdentityService identityService, + IEventBus eventBus) { - private readonly IBasketRepository _repository; - private readonly IIdentityService _identityService; - private readonly IEventBus _eventBus; - private readonly ILogger _logger; + _logger = logger; + _repository = repository; + _identityService = identityService; + _eventBus = eventBus; + } - public BasketController( - ILogger logger, - IBasketRepository repository, - IIdentityService identityService, - IEventBus eventBus) + [HttpGet("{id}")] + [ProducesResponseType(typeof(CustomerBasket), (int)HttpStatusCode.OK)] + public async Task> GetBasketByIdAsync(string id) + { + var basket = await _repository.GetBasketAsync(id); + + return Ok(basket ?? new CustomerBasket(id)); + } + + [HttpPost] + [ProducesResponseType(typeof(CustomerBasket), (int)HttpStatusCode.OK)] + public async Task> UpdateBasketAsync([FromBody] CustomerBasket value) + { + return Ok(await _repository.UpdateBasketAsync(value)); + } + + [Route("checkout")] + [HttpPost] + [ProducesResponseType((int)HttpStatusCode.Accepted)] + [ProducesResponseType((int)HttpStatusCode.BadRequest)] + public async Task CheckoutAsync([FromBody] BasketCheckout basketCheckout, [FromHeader(Name = "x-requestid")] string requestId) + { + var userId = _identityService.GetUserIdentity(); + + basketCheckout.RequestId = (Guid.TryParse(requestId, out Guid guid) && guid != Guid.Empty) ? + guid : basketCheckout.RequestId; + + var basket = await _repository.GetBasketAsync(userId); + + if (basket == null) { - _logger = logger; - _repository = repository; - _identityService = identityService; - _eventBus = eventBus; + return BadRequest(); } - [HttpGet("{id}")] - [ProducesResponseType(typeof(CustomerBasket), (int)HttpStatusCode.OK)] - public async Task> GetBasketByIdAsync(string id) - { - var basket = await _repository.GetBasketAsync(id); + var userName = this.HttpContext.User.FindFirst(x => x.Type == ClaimTypes.Name).Value; - return Ok(basket ?? new CustomerBasket(id)); + var eventMessage = new UserCheckoutAcceptedIntegrationEvent(userId, userName, basketCheckout.City, basketCheckout.Street, + basketCheckout.State, basketCheckout.Country, basketCheckout.ZipCode, basketCheckout.CardNumber, basketCheckout.CardHolderName, + basketCheckout.CardExpiration, basketCheckout.CardSecurityNumber, basketCheckout.CardTypeId, basketCheckout.Buyer, basketCheckout.RequestId, basket); + + // Once basket is checkout, sends an integration event to + // ordering.api to convert basket to order and proceeds with + // order creation process + try + { + _eventBus.Publish(eventMessage); + } + catch (Exception ex) + { + _logger.LogError(ex, "ERROR Publishing integration event: {IntegrationEventId} from {AppName}", eventMessage.Id, Program.AppName); + + throw; } - [HttpPost] - [ProducesResponseType(typeof(CustomerBasket), (int)HttpStatusCode.OK)] - public async Task> UpdateBasketAsync([FromBody] CustomerBasket value) - { - return Ok(await _repository.UpdateBasketAsync(value)); - } + return Accepted(); + } - [Route("checkout")] - [HttpPost] - [ProducesResponseType((int)HttpStatusCode.Accepted)] - [ProducesResponseType((int)HttpStatusCode.BadRequest)] - public async Task CheckoutAsync([FromBody] BasketCheckout basketCheckout, [FromHeader(Name = "x-requestid")] string requestId) - { - var userId = _identityService.GetUserIdentity(); - - basketCheckout.RequestId = (Guid.TryParse(requestId, out Guid guid) && guid != Guid.Empty) ? - guid : basketCheckout.RequestId; - - var basket = await _repository.GetBasketAsync(userId); - - if (basket == null) - { - return BadRequest(); - } - - var userName = this.HttpContext.User.FindFirst(x => x.Type == ClaimTypes.Name).Value; - - var eventMessage = new UserCheckoutAcceptedIntegrationEvent(userId, userName, basketCheckout.City, basketCheckout.Street, - basketCheckout.State, basketCheckout.Country, basketCheckout.ZipCode, basketCheckout.CardNumber, basketCheckout.CardHolderName, - basketCheckout.CardExpiration, basketCheckout.CardSecurityNumber, basketCheckout.CardTypeId, basketCheckout.Buyer, basketCheckout.RequestId, basket); - - // Once basket is checkout, sends an integration event to - // ordering.api to convert basket to order and proceeds with - // order creation process - try - { - _eventBus.Publish(eventMessage); - } - catch (Exception ex) - { - _logger.LogError(ex, "ERROR Publishing integration event: {IntegrationEventId} from {AppName}", eventMessage.Id, Program.AppName); - - throw; - } - - return Accepted(); - } - - // DELETE api/values/5 - [HttpDelete("{id}")] - [ProducesResponseType(typeof(void), (int)HttpStatusCode.OK)] - public async Task DeleteBasketByIdAsync(string id) - { - await _repository.DeleteBasketAsync(id); - } + // DELETE api/values/5 + [HttpDelete("{id}")] + [ProducesResponseType(typeof(void), (int)HttpStatusCode.OK)] + public async Task DeleteBasketByIdAsync(string id) + { + await _repository.DeleteBasketAsync(id); } } diff --git a/src/Services/Basket/Basket.API/Controllers/HomeController.cs b/src/Services/Basket/Basket.API/Controllers/HomeController.cs index d0c37a205..8b2b7c2e7 100644 --- a/src/Services/Basket/Basket.API/Controllers/HomeController.cs +++ b/src/Services/Basket/Basket.API/Controllers/HomeController.cs @@ -1,13 +1,11 @@ -using Microsoft.AspNetCore.Mvc; +namespace Microsoft.eShopOnContainers.Services.Basket.API.Controllers; -namespace Microsoft.eShopOnContainers.Services.Basket.API.Controllers +public class HomeController : Controller { - public class HomeController : Controller + // GET: // + public IActionResult Index() { - // GET: // - public IActionResult Index() - { - return new RedirectResult("~/swagger"); - } + return new RedirectResult("~/swagger"); } } + diff --git a/src/Services/Basket/Basket.API/Dockerfile b/src/Services/Basket/Basket.API/Dockerfile index 9ccc3d982..f5a27b1c7 100644 --- a/src/Services/Basket/Basket.API/Dockerfile +++ b/src/Services/Basket/Basket.API/Dockerfile @@ -1,8 +1,8 @@ -FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.6 AS base +FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.7 AS base WORKDIR /app EXPOSE 80 -FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.6 AS build +FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.7 AS build WORKDIR /src # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles diff --git a/src/Services/Basket/Basket.API/GlobalUsings.cs b/src/Services/Basket/Basket.API/GlobalUsings.cs new file mode 100644 index 000000000..3947e1cec --- /dev/null +++ b/src/Services/Basket/Basket.API/GlobalUsings.cs @@ -0,0 +1,61 @@ +global using Autofac.Extensions.DependencyInjection; +global using Autofac; +global using Azure.Core; +global using Azure.Identity; +global using Basket.API.Infrastructure.ActionResults; +global using Basket.API.Infrastructure.Exceptions; +global using Basket.API.Infrastructure.Filters; +global using Basket.API.Infrastructure.Middlewares; +global using Basket.API.IntegrationEvents.EventHandling; +global using Basket.API.IntegrationEvents.Events; +global using Basket.API.Model; +global using Grpc.Core; +global using GrpcBasket; +global using HealthChecks.UI.Client; +global using Microsoft.AspNetCore.Authentication.JwtBearer; +global using Microsoft.AspNetCore.Authorization; +global using Microsoft.AspNetCore.Builder; +global using Microsoft.AspNetCore.Diagnostics.HealthChecks; +global using Microsoft.AspNetCore.Hosting; +global using Microsoft.AspNetCore.Http.Features; +global using Microsoft.AspNetCore.Http; +global using Microsoft.AspNetCore.Mvc.Authorization; +global using Microsoft.AspNetCore.Mvc.Filters; +global using Microsoft.AspNetCore.Mvc; +global using Microsoft.AspNetCore.Server.Kestrel.Core; +global using Microsoft.AspNetCore; +global using Microsoft.Azure.ServiceBus; +global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; +global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; +global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus; +global using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ; +global using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus; +global using Microsoft.eShopOnContainers.Services.Basket.API.Controllers; +global using Microsoft.eShopOnContainers.Services.Basket.API.Infrastructure.Repositories; +global using Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.EventHandling; +global using Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.Events; +global using Microsoft.eShopOnContainers.Services.Basket.API.Model; +global using Microsoft.eShopOnContainers.Services.Basket.API.Services; +global using Microsoft.eShopOnContainers.Services.Basket.API; +global using Microsoft.Extensions.Configuration; +global using Microsoft.Extensions.DependencyInjection; +global using Microsoft.Extensions.Diagnostics.HealthChecks; +global using Microsoft.Extensions.Hosting; +global using Microsoft.Extensions.Logging; +global using Microsoft.Extensions.Options; +global using Microsoft.OpenApi.Models; +global using RabbitMQ.Client; +global using Serilog.Context; +global using Serilog; +global using StackExchange.Redis; +global using Swashbuckle.AspNetCore.SwaggerGen; +global using System.Collections.Generic; +global using System.ComponentModel.DataAnnotations; +global using System.IdentityModel.Tokens.Jwt; +global using System.IO; +global using System.Linq; +global using System.Net; +global using System.Security.Claims; +global using System.Text.Json; +global using System.Threading.Tasks; +global using System; \ No newline at end of file diff --git a/src/Services/Basket/Basket.API/Grpc/BasketService.cs b/src/Services/Basket/Basket.API/Grpc/BasketService.cs index 51633b326..50c23c0ff 100644 --- a/src/Services/Basket/Basket.API/Grpc/BasketService.cs +++ b/src/Services/Basket/Basket.API/Grpc/BasketService.cs @@ -1,102 +1,94 @@ -using Grpc.Core; -using Microsoft.AspNetCore.Authorization; -using Microsoft.eShopOnContainers.Services.Basket.API.Model; -using Microsoft.Extensions.Logging; -using System.Linq; -using System.Threading.Tasks; +namespace GrpcBasket; -namespace GrpcBasket +public class BasketService : Basket.BasketBase { - public class BasketService : Basket.BasketBase + private readonly IBasketRepository _repository; + private readonly ILogger _logger; + + public BasketService(IBasketRepository repository, ILogger logger) { - private readonly IBasketRepository _repository; - private readonly ILogger _logger; + _repository = repository; + _logger = logger; + } - public BasketService(IBasketRepository repository, ILogger logger) + [AllowAnonymous] + public override async Task GetBasketById(BasketRequest request, ServerCallContext context) + { + _logger.LogInformation("Begin grpc call from method {Method} for basket id {Id}", context.Method, request.Id); + + var data = await _repository.GetBasketAsync(request.Id); + + if (data != null) { - _repository = repository; - _logger = logger; + context.Status = new Status(StatusCode.OK, $"Basket with id {request.Id} do exist"); + + return MapToCustomerBasketResponse(data); + } + else + { + context.Status = new Status(StatusCode.NotFound, $"Basket with id {request.Id} do not exist"); } - [AllowAnonymous] - public override async Task GetBasketById(BasketRequest request, ServerCallContext context) + return new CustomerBasketResponse(); + } + + public override async Task UpdateBasket(CustomerBasketRequest request, ServerCallContext context) + { + _logger.LogInformation("Begin grpc call BasketService.UpdateBasketAsync for buyer id {Buyerid}", request.Buyerid); + + var customerBasket = MapToCustomerBasket(request); + + var response = await _repository.UpdateBasketAsync(customerBasket); + + if (response != null) { - _logger.LogInformation("Begin grpc call from method {Method} for basket id {Id}", context.Method, request.Id); - - var data = await _repository.GetBasketAsync(request.Id); - - if (data != null) - { - context.Status = new Status(StatusCode.OK, $"Basket with id {request.Id} do exist"); - - return MapToCustomerBasketResponse(data); - } - else - { - context.Status = new Status(StatusCode.NotFound, $"Basket with id {request.Id} do not exist"); - } - - return new CustomerBasketResponse(); + return MapToCustomerBasketResponse(response); } - public override async Task UpdateBasket(CustomerBasketRequest request, ServerCallContext context) + context.Status = new Status(StatusCode.NotFound, $"Basket with buyer id {request.Buyerid} do not exist"); + + return null; + } + + private CustomerBasketResponse MapToCustomerBasketResponse(CustomerBasket customerBasket) + { + var response = new CustomerBasketResponse { - _logger.LogInformation("Begin grpc call BasketService.UpdateBasketAsync for buyer id {Buyerid}", request.Buyerid); + Buyerid = customerBasket.BuyerId + }; - var customerBasket = MapToCustomerBasket(request); - - var response = await _repository.UpdateBasketAsync(customerBasket); - - if (response != null) - { - return MapToCustomerBasketResponse(response); - } - - context.Status = new Status(StatusCode.NotFound, $"Basket with buyer id {request.Buyerid} do not exist"); - - return null; - } - - private CustomerBasketResponse MapToCustomerBasketResponse(CustomerBasket customerBasket) + customerBasket.Items.ForEach(item => response.Items.Add(new BasketItemResponse { - var response = new CustomerBasketResponse - { - Buyerid = customerBasket.BuyerId - }; + Id = item.Id, + Oldunitprice = (double)item.OldUnitPrice, + Pictureurl = item.PictureUrl, + Productid = item.ProductId, + Productname = item.ProductName, + Quantity = item.Quantity, + Unitprice = (double)item.UnitPrice + })); - customerBasket.Items.ForEach(item => response.Items.Add(new BasketItemResponse - { - Id = item.Id, - Oldunitprice = (double)item.OldUnitPrice, - Pictureurl = item.PictureUrl, - Productid = item.ProductId, - Productname = item.ProductName, - Quantity = item.Quantity, - Unitprice = (double)item.UnitPrice - })); + return response; + } - return response; - } - - private CustomerBasket MapToCustomerBasket(CustomerBasketRequest customerBasketRequest) + private CustomerBasket MapToCustomerBasket(CustomerBasketRequest customerBasketRequest) + { + var response = new CustomerBasket { - var response = new CustomerBasket - { - BuyerId = customerBasketRequest.Buyerid - }; + BuyerId = customerBasketRequest.Buyerid + }; - customerBasketRequest.Items.ToList().ForEach(item => response.Items.Add(new BasketItem - { - Id = item.Id, - OldUnitPrice = (decimal)item.Oldunitprice, - PictureUrl = item.Pictureurl, - ProductId = item.Productid, - ProductName = item.Productname, - Quantity = item.Quantity, - UnitPrice = (decimal)item.Unitprice - })); + customerBasketRequest.Items.ToList().ForEach(item => response.Items.Add(new BasketItem + { + Id = item.Id, + OldUnitPrice = (decimal)item.Oldunitprice, + PictureUrl = item.Pictureurl, + ProductId = item.Productid, + ProductName = item.Productname, + Quantity = item.Quantity, + UnitPrice = (decimal)item.Unitprice + })); - return response; - } + return response; } } diff --git a/src/Services/Basket/Basket.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs b/src/Services/Basket/Basket.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs index a0b988156..5f95e586e 100644 --- a/src/Services/Basket/Basket.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs +++ b/src/Services/Basket/Basket.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs @@ -1,14 +1,11 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; +namespace Basket.API.Infrastructure.ActionResults; -namespace Basket.API.Infrastructure.ActionResults +public class InternalServerErrorObjectResult : ObjectResult { - public class InternalServerErrorObjectResult : ObjectResult + public InternalServerErrorObjectResult(object error) + : base(error) { - public InternalServerErrorObjectResult(object error) - : base(error) - { - StatusCode = StatusCodes.Status500InternalServerError; - } + StatusCode = StatusCodes.Status500InternalServerError; } } + diff --git a/src/Services/Basket/Basket.API/Infrastructure/Exceptions/BasketDomainException.cs b/src/Services/Basket/Basket.API/Infrastructure/Exceptions/BasketDomainException.cs index e0f2df6fa..0502b7924 100644 --- a/src/Services/Basket/Basket.API/Infrastructure/Exceptions/BasketDomainException.cs +++ b/src/Services/Basket/Basket.API/Infrastructure/Exceptions/BasketDomainException.cs @@ -1,21 +1,16 @@ -using System; +namespace Basket.API.Infrastructure.Exceptions; -namespace Basket.API.Infrastructure.Exceptions +public class BasketDomainException : Exception { - /// - /// Exception type for app exceptions - /// - public class BasketDomainException : Exception - { - public BasketDomainException() - { } + public BasketDomainException() + { } - public BasketDomainException(string message) - : base(message) - { } + public BasketDomainException(string message) + : base(message) + { } - public BasketDomainException(string message, Exception innerException) - : base(message, innerException) - { } - } + public BasketDomainException(string message, Exception innerException) + : base(message, innerException) + { } } + diff --git a/src/Services/Basket/Basket.API/Infrastructure/Exceptions/FailingMiddlewareAppBuilderExtensions.cs b/src/Services/Basket/Basket.API/Infrastructure/Exceptions/FailingMiddlewareAppBuilderExtensions.cs index a09f32f76..66f55dddd 100644 --- a/src/Services/Basket/Basket.API/Infrastructure/Exceptions/FailingMiddlewareAppBuilderExtensions.cs +++ b/src/Services/Basket/Basket.API/Infrastructure/Exceptions/FailingMiddlewareAppBuilderExtensions.cs @@ -1,20 +1,18 @@ -using Microsoft.AspNetCore.Builder; -using System; +namespace Basket.API.Infrastructure.Middlewares; -namespace Basket.API.Infrastructure.Middlewares +public static class FailingMiddlewareAppBuilderExtensions { - public static class FailingMiddlewareAppBuilderExtensions + public static IApplicationBuilder UseFailingMiddleware(this IApplicationBuilder builder) { - public static IApplicationBuilder UseFailingMiddleware(this IApplicationBuilder builder) - { - return UseFailingMiddleware(builder, null); - } - public static IApplicationBuilder UseFailingMiddleware(this IApplicationBuilder builder, Action action) - { - var options = new FailingOptions(); - action?.Invoke(options); - builder.UseMiddleware(options); - return builder; - } + return UseFailingMiddleware(builder, null); + } + + public static IApplicationBuilder UseFailingMiddleware(this IApplicationBuilder builder, Action action) + { + var options = new FailingOptions(); + action?.Invoke(options); + builder.UseMiddleware(options); + return builder; } } + diff --git a/src/Services/Basket/Basket.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs b/src/Services/Basket/Basket.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs index 0fd08a0a9..00b0b5195 100644 --- a/src/Services/Basket/Basket.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs +++ b/src/Services/Basket/Basket.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs @@ -1,58 +1,47 @@ -using Basket.API.Infrastructure.ActionResults; -using Basket.API.Infrastructure.Exceptions; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Filters; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using System.Net; +namespace Basket.API.Infrastructure.Filters; - -namespace Basket.API.Infrastructure.Filters +public partial class HttpGlobalExceptionFilter : IExceptionFilter { - public partial class HttpGlobalExceptionFilter : IExceptionFilter + private readonly IWebHostEnvironment env; + private readonly ILogger logger; + + public HttpGlobalExceptionFilter(IWebHostEnvironment env, ILogger logger) { - private readonly IWebHostEnvironment env; - private readonly ILogger logger; + this.env = env; + this.logger = logger; + } - public HttpGlobalExceptionFilter(IWebHostEnvironment env, ILogger logger) + public void OnException(ExceptionContext context) + { + logger.LogError(new EventId(context.Exception.HResult), + context.Exception, + context.Exception.Message); + + if (context.Exception.GetType() == typeof(BasketDomainException)) { - this.env = env; - this.logger = logger; - } + var json = new JsonErrorResponse + { + Messages = new[] { context.Exception.Message } + }; - public void OnException(ExceptionContext context) + context.Result = new BadRequestObjectResult(json); + context.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest; + } + else { - logger.LogError(new EventId(context.Exception.HResult), - context.Exception, - context.Exception.Message); - - if (context.Exception.GetType() == typeof(BasketDomainException)) + var json = new JsonErrorResponse { - var json = new JsonErrorResponse - { - Messages = new[] { context.Exception.Message } - }; + Messages = new[] { "An error occurred. Try it again." } + }; - context.Result = new BadRequestObjectResult(json); - context.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest; - } - else + if (env.IsDevelopment()) { - var json = new JsonErrorResponse - { - Messages = new[] { "An error occurred. Try it again." } - }; - - if (env.IsDevelopment()) - { - json.DeveloperMessage = context.Exception; - } - - context.Result = new InternalServerErrorObjectResult(json); - context.HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError; + json.DeveloperMessage = context.Exception; } - context.ExceptionHandled = true; + + context.Result = new InternalServerErrorObjectResult(json); + context.HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError; } + context.ExceptionHandled = true; } } diff --git a/src/Services/Basket/Basket.API/Infrastructure/Filters/JsonErrorResponse.cs b/src/Services/Basket/Basket.API/Infrastructure/Filters/JsonErrorResponse.cs index bcadc7358..88bc02eda 100644 --- a/src/Services/Basket/Basket.API/Infrastructure/Filters/JsonErrorResponse.cs +++ b/src/Services/Basket/Basket.API/Infrastructure/Filters/JsonErrorResponse.cs @@ -1,9 +1,9 @@ -namespace Basket.API.Infrastructure.Filters -{ - public class JsonErrorResponse - { - public string[] Messages { get; set; } +namespace Basket.API.Infrastructure.Filters; - public object DeveloperMessage { get; set; } - } +public class JsonErrorResponse +{ + public string[] Messages { get; set; } + + public object DeveloperMessage { get; set; } } + diff --git a/src/Services/Basket/Basket.API/Infrastructure/Filters/ValidateModelStateFilter.cs b/src/Services/Basket/Basket.API/Infrastructure/Filters/ValidateModelStateFilter.cs index 3e4c3e072..5c97b85dc 100644 --- a/src/Services/Basket/Basket.API/Infrastructure/Filters/ValidateModelStateFilter.cs +++ b/src/Services/Basket/Basket.API/Infrastructure/Filters/ValidateModelStateFilter.cs @@ -1,30 +1,26 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Filters; -using System.Linq; +namespace Basket.API.Infrastructure.Filters; -namespace Basket.API.Infrastructure.Filters +public class ValidateModelStateFilter : ActionFilterAttribute { - public class ValidateModelStateFilter : ActionFilterAttribute + public override void OnActionExecuting(ActionExecutingContext context) { - public override void OnActionExecuting(ActionExecutingContext context) + if (context.ModelState.IsValid) { - if (context.ModelState.IsValid) - { - return; - } - - var validationErrors = context.ModelState - .Keys - .SelectMany(k => context.ModelState[k].Errors) - .Select(e => e.ErrorMessage) - .ToArray(); - - var json = new JsonErrorResponse - { - Messages = validationErrors - }; - - context.Result = new BadRequestObjectResult(json); + return; } + + var validationErrors = context.ModelState + .Keys + .SelectMany(k => context.ModelState[k].Errors) + .Select(e => e.ErrorMessage) + .ToArray(); + + var json = new JsonErrorResponse + { + Messages = validationErrors + }; + + context.Result = new BadRequestObjectResult(json); } } + diff --git a/src/Services/Basket/Basket.API/Infrastructure/Middlewares/AuthorizeCheckOperationFilter.cs b/src/Services/Basket/Basket.API/Infrastructure/Middlewares/AuthorizeCheckOperationFilter.cs index 4a1c24aa6..0957614f9 100644 --- a/src/Services/Basket/Basket.API/Infrastructure/Middlewares/AuthorizeCheckOperationFilter.cs +++ b/src/Services/Basket/Basket.API/Infrastructure/Middlewares/AuthorizeCheckOperationFilter.cs @@ -1,36 +1,29 @@ -using Microsoft.AspNetCore.Authorization; -using Microsoft.OpenApi.Models; -using Swashbuckle.AspNetCore.SwaggerGen; -using System.Collections.Generic; -using System.Linq; +namespace Basket.API.Infrastructure.Filters; -namespace Basket.API.Infrastructure.Filters +public class AuthorizeCheckOperationFilter : IOperationFilter { - public class AuthorizeCheckOperationFilter : IOperationFilter + public void Apply(OpenApiOperation operation, OperationFilterContext context) { - public void Apply(OpenApiOperation operation, OperationFilterContext context) + // Check for authorize attribute + var hasAuthorize = context.MethodInfo.DeclaringType.GetCustomAttributes(true).OfType().Any() || + context.MethodInfo.GetCustomAttributes(true).OfType().Any(); + + if (!hasAuthorize) return; + + operation.Responses.TryAdd("401", new OpenApiResponse { Description = "Unauthorized" }); + operation.Responses.TryAdd("403", new OpenApiResponse { Description = "Forbidden" }); + + var oAuthScheme = new OpenApiSecurityScheme { - // Check for authorize attribute - var hasAuthorize = context.MethodInfo.DeclaringType.GetCustomAttributes(true).OfType().Any() || - context.MethodInfo.GetCustomAttributes(true).OfType().Any(); + Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "oauth2" } + }; - if (!hasAuthorize) return; - - operation.Responses.TryAdd("401", new OpenApiResponse { Description = "Unauthorized" }); - operation.Responses.TryAdd("403", new OpenApiResponse { Description = "Forbidden" }); - - var oAuthScheme = new OpenApiSecurityScheme + operation.Security = new List { - Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "oauth2" } - }; - - operation.Security = new List + new OpenApiSecurityRequirement { - new OpenApiSecurityRequirement - { - [ oAuthScheme ] = new [] { "basketapi" } - } - }; - } + [ oAuthScheme ] = new [] { "basketapi" } + } + }; } -} \ No newline at end of file +} diff --git a/src/Services/Basket/Basket.API/Infrastructure/Middlewares/FailingMiddleware.cs b/src/Services/Basket/Basket.API/Infrastructure/Middlewares/FailingMiddleware.cs index 0019a2049..c2a50467d 100644 --- a/src/Services/Basket/Basket.API/Infrastructure/Middlewares/FailingMiddleware.cs +++ b/src/Services/Basket/Basket.API/Infrastructure/Middlewares/FailingMiddleware.cs @@ -1,95 +1,88 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; -using System; -using System.Linq; -using System.Threading.Tasks; +namespace Basket.API.Infrastructure.Middlewares; -namespace Basket.API.Infrastructure.Middlewares +public class FailingMiddleware { - public class FailingMiddleware + private readonly RequestDelegate _next; + private bool _mustFail; + private readonly FailingOptions _options; + private readonly Microsoft.Extensions.Logging.ILogger _logger; + + public FailingMiddleware(RequestDelegate next, Microsoft.Extensions.Logging.ILogger logger, FailingOptions options) { - private readonly RequestDelegate _next; - private bool _mustFail; - private readonly FailingOptions _options; - private readonly ILogger _logger; + _next = next; + _options = options; + _mustFail = false; + _logger = logger; + } - public FailingMiddleware(RequestDelegate next, ILogger logger, FailingOptions options) + public async Task Invoke(HttpContext context) + { + var path = context.Request.Path; + if (path.Equals(_options.ConfigPath, StringComparison.OrdinalIgnoreCase)) { - _next = next; - _options = options; - _mustFail = false; - _logger = logger; - } - - public async Task Invoke(HttpContext context) - { - var path = context.Request.Path; - if (path.Equals(_options.ConfigPath, StringComparison.OrdinalIgnoreCase)) - { - await ProcessConfigRequest(context); - return; - } - - if (MustFail(context)) - { - _logger.LogInformation("Response for path {Path} will fail.", path); - context.Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError; - context.Response.ContentType = "text/plain"; - await context.Response.WriteAsync("Failed due to FailingMiddleware enabled."); - } - else - { - await _next.Invoke(context); - } - } - - private async Task ProcessConfigRequest(HttpContext context) - { - var enable = context.Request.Query.Keys.Any(k => k == "enable"); - var disable = context.Request.Query.Keys.Any(k => k == "disable"); - - if (enable && disable) - { - throw new ArgumentException("Must use enable or disable querystring values, but not both"); - } - - if (disable) - { - _mustFail = false; - await SendOkResponse(context, "FailingMiddleware disabled. Further requests will be processed."); - return; - } - if (enable) - { - _mustFail = true; - await SendOkResponse(context, "FailingMiddleware enabled. Further requests will return HTTP 500"); - return; - } - - // If reach here, that means that no valid parameter has been passed. Just output status - await SendOkResponse(context, string.Format("FailingMiddleware is {0}", _mustFail ? "enabled" : "disabled")); + await ProcessConfigRequest(context); return; } - private async Task SendOkResponse(HttpContext context, string message) + if (MustFail(context)) { - context.Response.StatusCode = (int)System.Net.HttpStatusCode.OK; + _logger.LogInformation("Response for path {Path} will fail.", path); + context.Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError; context.Response.ContentType = "text/plain"; - await context.Response.WriteAsync(message); + await context.Response.WriteAsync("Failed due to FailingMiddleware enabled."); } - - private bool MustFail(HttpContext context) + else { - var rpath = context.Request.Path.Value; - - if (_options.NotFilteredPaths.Any(p => p.Equals(rpath, StringComparison.InvariantCultureIgnoreCase))) - { - return false; - } - - return _mustFail && - (_options.EndpointPaths.Any(x => x == rpath) - || _options.EndpointPaths.Count == 0); + await _next.Invoke(context); } } + + private async Task ProcessConfigRequest(HttpContext context) + { + var enable = context.Request.Query.Keys.Any(k => k == "enable"); + var disable = context.Request.Query.Keys.Any(k => k == "disable"); + + if (enable && disable) + { + throw new ArgumentException("Must use enable or disable querystring values, but not both"); + } + + if (disable) + { + _mustFail = false; + await SendOkResponse(context, "FailingMiddleware disabled. Further requests will be processed."); + return; + } + if (enable) + { + _mustFail = true; + await SendOkResponse(context, "FailingMiddleware enabled. Further requests will return HTTP 500"); + return; + } + + // If reach here, that means that no valid parameter has been passed. Just output status + await SendOkResponse(context, string.Format("FailingMiddleware is {0}", _mustFail ? "enabled" : "disabled")); + return; + } + + private async Task SendOkResponse(HttpContext context, string message) + { + context.Response.StatusCode = (int)System.Net.HttpStatusCode.OK; + context.Response.ContentType = "text/plain"; + await context.Response.WriteAsync(message); + } + + private bool MustFail(HttpContext context) + { + var rpath = context.Request.Path.Value; + + if (_options.NotFilteredPaths.Any(p => p.Equals(rpath, StringComparison.InvariantCultureIgnoreCase))) + { + return false; + } + + return _mustFail && + (_options.EndpointPaths.Any(x => x == rpath) + || _options.EndpointPaths.Count == 0); + } } diff --git a/src/Services/Basket/Basket.API/Infrastructure/Middlewares/FailingOptions.cs b/src/Services/Basket/Basket.API/Infrastructure/Middlewares/FailingOptions.cs index e8a77f1fd..7818938d2 100644 --- a/src/Services/Basket/Basket.API/Infrastructure/Middlewares/FailingOptions.cs +++ b/src/Services/Basket/Basket.API/Infrastructure/Middlewares/FailingOptions.cs @@ -1,12 +1,10 @@ -using System.Collections.Generic; +namespace Basket.API.Infrastructure.Middlewares; -namespace Basket.API.Infrastructure.Middlewares +public class FailingOptions { - public class FailingOptions - { - public string ConfigPath = "/Failing"; - public List EndpointPaths { get; set; } = new List(); + public string ConfigPath = "/Failing"; + public List EndpointPaths { get; set; } = new List(); - public List NotFilteredPaths { get; set; } = new List(); - } + public List NotFilteredPaths { get; set; } = new List(); } + diff --git a/src/Services/Basket/Basket.API/Infrastructure/Middlewares/FailingStartupFilter.cs b/src/Services/Basket/Basket.API/Infrastructure/Middlewares/FailingStartupFilter.cs index 7d3b2ce18..74da62b5d 100644 --- a/src/Services/Basket/Basket.API/Infrastructure/Middlewares/FailingStartupFilter.cs +++ b/src/Services/Basket/Basket.API/Infrastructure/Middlewares/FailingStartupFilter.cs @@ -1,24 +1,20 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using System; +namespace Basket.API.Infrastructure.Middlewares; -namespace Basket.API.Infrastructure.Middlewares +public class FailingStartupFilter : IStartupFilter { - public class FailingStartupFilter : IStartupFilter + private readonly Action _options; + public FailingStartupFilter(Action optionsAction) { - private readonly Action _options; - public FailingStartupFilter(Action optionsAction) - { - _options = optionsAction; - } + _options = optionsAction; + } - public Action Configure(Action next) + public Action Configure(Action next) + { + return app => { - return app => - { - app.UseFailingMiddleware(_options); - next(app); - }; - } + app.UseFailingMiddleware(_options); + next(app); + }; } } + diff --git a/src/Services/Basket/Basket.API/Infrastructure/Middlewares/FailingWebHostBuilderExtensions.cs b/src/Services/Basket/Basket.API/Infrastructure/Middlewares/FailingWebHostBuilderExtensions.cs index 99be1b182..8a8ba9523 100644 --- a/src/Services/Basket/Basket.API/Infrastructure/Middlewares/FailingWebHostBuilderExtensions.cs +++ b/src/Services/Basket/Basket.API/Infrastructure/Middlewares/FailingWebHostBuilderExtensions.cs @@ -1,18 +1,14 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.DependencyInjection; -using System; +namespace Basket.API.Infrastructure.Middlewares; -namespace Basket.API.Infrastructure.Middlewares +public static class WebHostBuildertExtensions { - public static class WebHostBuildertExtensions + public static IWebHostBuilder UseFailing(this IWebHostBuilder builder, Action options) { - public static IWebHostBuilder UseFailing(this IWebHostBuilder builder, Action options) + builder.ConfigureServices(services => { - builder.ConfigureServices(services => - { - services.AddSingleton(new FailingStartupFilter(options)); - }); - return builder; - } + services.AddSingleton(new FailingStartupFilter(options)); + }); + return builder; } } + diff --git a/src/Services/Basket/Basket.API/Infrastructure/Repositories/RedisBasketRepository.cs b/src/Services/Basket/Basket.API/Infrastructure/Repositories/RedisBasketRepository.cs index 6e724d7ca..7db463f20 100644 --- a/src/Services/Basket/Basket.API/Infrastructure/Repositories/RedisBasketRepository.cs +++ b/src/Services/Basket/Basket.API/Infrastructure/Repositories/RedisBasketRepository.cs @@ -1,73 +1,64 @@ -using Microsoft.eShopOnContainers.Services.Basket.API.Model; -using Microsoft.Extensions.Logging; -using StackExchange.Redis; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using System.Text.Json; +namespace Microsoft.eShopOnContainers.Services.Basket.API.Infrastructure.Repositories; -namespace Microsoft.eShopOnContainers.Services.Basket.API.Infrastructure.Repositories +public class RedisBasketRepository : IBasketRepository { - public class RedisBasketRepository : IBasketRepository + private readonly ILogger _logger; + private readonly ConnectionMultiplexer _redis; + private readonly IDatabase _database; + + public RedisBasketRepository(ILoggerFactory loggerFactory, ConnectionMultiplexer redis) { - private readonly ILogger _logger; - private readonly ConnectionMultiplexer _redis; - private readonly IDatabase _database; + _logger = loggerFactory.CreateLogger(); + _redis = redis; + _database = redis.GetDatabase(); + } - public RedisBasketRepository(ILoggerFactory loggerFactory, ConnectionMultiplexer redis) + public async Task DeleteBasketAsync(string id) + { + return await _database.KeyDeleteAsync(id); + } + + public IEnumerable GetUsers() + { + var server = GetServer(); + var data = server.Keys(); + + return data?.Select(k => k.ToString()); + } + + public async Task GetBasketAsync(string customerId) + { + var data = await _database.StringGetAsync(customerId); + + if (data.IsNullOrEmpty) { - _logger = loggerFactory.CreateLogger(); - _redis = redis; - _database = redis.GetDatabase(); + return null; } - public async Task DeleteBasketAsync(string id) + return JsonSerializer.Deserialize(data, new JsonSerializerOptions { - return await _database.KeyDeleteAsync(id); + PropertyNameCaseInsensitive = true + }); + } + + public async Task UpdateBasketAsync(CustomerBasket basket) + { + var created = await _database.StringSetAsync(basket.BuyerId, JsonSerializer.Serialize(basket)); + + if (!created) + { + _logger.LogInformation("Problem occur persisting the item."); + return null; } - public IEnumerable GetUsers() - { - var server = GetServer(); - var data = server.Keys(); + _logger.LogInformation("Basket item persisted succesfully."); - return data?.Select(k => k.ToString()); - } + return await GetBasketAsync(basket.BuyerId); + } - public async Task GetBasketAsync(string customerId) - { - var data = await _database.StringGetAsync(customerId); - - if (data.IsNullOrEmpty) - { - return null; - } - - return JsonSerializer.Deserialize(data, new JsonSerializerOptions - { - PropertyNameCaseInsensitive = true - }); - } - - public async Task UpdateBasketAsync(CustomerBasket basket) - { - var created = await _database.StringSetAsync(basket.BuyerId, JsonSerializer.Serialize(basket)); - - if (!created) - { - _logger.LogInformation("Problem occur persisting the item."); - return null; - } - - _logger.LogInformation("Basket item persisted succesfully."); - - return await GetBasketAsync(basket.BuyerId); - } - - private IServer GetServer() - { - var endpoint = _redis.GetEndPoints(); - return _redis.GetServer(endpoint.First()); - } + private IServer GetServer() + { + var endpoint = _redis.GetEndPoints(); + return _redis.GetServer(endpoint.First()); } } diff --git a/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/OrderStartedIntegrationEventHandler.cs b/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/OrderStartedIntegrationEventHandler.cs index fb2c10e9e..2c93f82fd 100644 --- a/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/OrderStartedIntegrationEventHandler.cs +++ b/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/OrderStartedIntegrationEventHandler.cs @@ -1,37 +1,29 @@ -using Basket.API.IntegrationEvents.Events; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; -using Microsoft.eShopOnContainers.Services.Basket.API.Model; -using Microsoft.Extensions.Logging; -using Serilog.Context; -using System; -using System.Threading.Tasks; +namespace Basket.API.IntegrationEvents.EventHandling; -namespace Basket.API.IntegrationEvents.EventHandling +public class OrderStartedIntegrationEventHandler : IIntegrationEventHandler { - public class OrderStartedIntegrationEventHandler : IIntegrationEventHandler + private readonly IBasketRepository _repository; + private readonly ILogger _logger; + + public OrderStartedIntegrationEventHandler( + IBasketRepository repository, + ILogger logger) { - private readonly IBasketRepository _repository; - private readonly ILogger _logger; + _repository = repository ?? throw new ArgumentNullException(nameof(repository)); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); + } - public OrderStartedIntegrationEventHandler( - IBasketRepository repository, - ILogger logger) + public async Task Handle(OrderStartedIntegrationEvent @event) + { + using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) { - _repository = repository ?? throw new ArgumentNullException(nameof(repository)); - _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - } + _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); - public async Task Handle(OrderStartedIntegrationEvent @event) - { - using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) - { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); - - await _repository.DeleteBasketAsync(@event.UserId.ToString()); - } + await _repository.DeleteBasketAsync(@event.UserId.ToString()); } } } + diff --git a/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs b/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs index 6068bdda6..b389b73d7 100644 --- a/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs +++ b/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs @@ -1,64 +1,53 @@ -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; -using Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.Events; -using Microsoft.eShopOnContainers.Services.Basket.API.Model; -using Microsoft.Extensions.Logging; -using Serilog.Context; -using System; -using System.Linq; -using System.Threading.Tasks; +namespace Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.EventHandling; -namespace Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.EventHandling +public class ProductPriceChangedIntegrationEventHandler : IIntegrationEventHandler { - public class ProductPriceChangedIntegrationEventHandler : IIntegrationEventHandler + private readonly ILogger _logger; + private readonly IBasketRepository _repository; + + public ProductPriceChangedIntegrationEventHandler( + ILogger logger, + IBasketRepository repository) { - private readonly ILogger _logger; - private readonly IBasketRepository _repository; + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); + _repository = repository ?? throw new ArgumentNullException(nameof(repository)); + } - public ProductPriceChangedIntegrationEventHandler( - ILogger logger, - IBasketRepository repository) + public async Task Handle(ProductPriceChangedIntegrationEvent @event) + { + using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) { - _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - _repository = repository ?? throw new ArgumentNullException(nameof(repository)); - } + _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); - public async Task Handle(ProductPriceChangedIntegrationEvent @event) - { - using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) + var userIds = _repository.GetUsers(); + + foreach (var id in userIds) { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); + var basket = await _repository.GetBasketAsync(id); - var userIds = _repository.GetUsers(); - - foreach (var id in userIds) - { - var basket = await _repository.GetBasketAsync(id); - - await UpdatePriceInBasketItems(@event.ProductId, @event.NewPrice, @event.OldPrice, basket); - } - } - } - - private async Task UpdatePriceInBasketItems(int productId, decimal newPrice, decimal oldPrice, CustomerBasket basket) - { - var itemsToUpdate = basket?.Items?.Where(x => x.ProductId == productId).ToList(); - - if (itemsToUpdate != null) - { - _logger.LogInformation("----- ProductPriceChangedIntegrationEventHandler - Updating items in basket for user: {BuyerId} ({@Items})", basket.BuyerId, itemsToUpdate); - - foreach (var item in itemsToUpdate) - { - if (item.UnitPrice == oldPrice) - { - var originalPrice = item.UnitPrice; - item.UnitPrice = newPrice; - item.OldUnitPrice = originalPrice; - } - } - await _repository.UpdateBasketAsync(basket); + await UpdatePriceInBasketItems(@event.ProductId, @event.NewPrice, @event.OldPrice, basket); } } } -} + private async Task UpdatePriceInBasketItems(int productId, decimal newPrice, decimal oldPrice, CustomerBasket basket) + { + var itemsToUpdate = basket?.Items?.Where(x => x.ProductId == productId).ToList(); + + if (itemsToUpdate != null) + { + _logger.LogInformation("----- ProductPriceChangedIntegrationEventHandler - Updating items in basket for user: {BuyerId} ({@Items})", basket.BuyerId, itemsToUpdate); + + foreach (var item in itemsToUpdate) + { + if (item.UnitPrice == oldPrice) + { + var originalPrice = item.UnitPrice; + item.UnitPrice = newPrice; + item.OldUnitPrice = originalPrice; + } + } + await _repository.UpdateBasketAsync(basket); + } + } +} diff --git a/src/Services/Basket/Basket.API/IntegrationEvents/Events/OrderStartedIntegrationEvent.cs b/src/Services/Basket/Basket.API/IntegrationEvents/Events/OrderStartedIntegrationEvent.cs index e0567b54e..06954890e 100644 --- a/src/Services/Basket/Basket.API/IntegrationEvents/Events/OrderStartedIntegrationEvent.cs +++ b/src/Services/Basket/Basket.API/IntegrationEvents/Events/OrderStartedIntegrationEvent.cs @@ -1,15 +1,13 @@ -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; +namespace Basket.API.IntegrationEvents.Events; -namespace Basket.API.IntegrationEvents.Events +// Integration Events notes: +// An Event is "something that has happened in the past", therefore its name has to be +// An Integration Event is an event that can cause side effects to other microsrvices, Bounded-Contexts or external systems. +public record OrderStartedIntegrationEvent : IntegrationEvent { - // Integration Events notes: - // An Event is “something that has happened in the past”, therefore its name has to be - // An Integration Event is an event that can cause side effects to other microsrvices, Bounded-Contexts or external systems. - public record OrderStartedIntegrationEvent : IntegrationEvent - { - public string UserId { get; init; } + public string UserId { get; init; } - public OrderStartedIntegrationEvent(string userId) - => UserId = userId; - } + public OrderStartedIntegrationEvent(string userId) + => UserId = userId; } + diff --git a/src/Services/Basket/Basket.API/IntegrationEvents/Events/ProductPriceChangedIntegrationEvent.cs b/src/Services/Basket/Basket.API/IntegrationEvents/Events/ProductPriceChangedIntegrationEvent.cs index c69fe0f72..b0f87f58a 100644 --- a/src/Services/Basket/Basket.API/IntegrationEvents/Events/ProductPriceChangedIntegrationEvent.cs +++ b/src/Services/Basket/Basket.API/IntegrationEvents/Events/ProductPriceChangedIntegrationEvent.cs @@ -1,23 +1,21 @@ -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; +namespace Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.Events; -namespace Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.Events +// Integration Events notes: +// An Event is "something that has happened in the past", therefore its name has to be +// An Integration Event is an event that can cause side effects to other microsrvices, Bounded-Contexts or external systems. +public record ProductPriceChangedIntegrationEvent : IntegrationEvent { - // Integration Events notes: - // An Event is “something that has happened in the past”, therefore its name has to be - // An Integration Event is an event that can cause side effects to other microsrvices, Bounded-Contexts or external systems. - public record ProductPriceChangedIntegrationEvent : IntegrationEvent + public int ProductId { get; private init; } + + public decimal NewPrice { get; private init; } + + public decimal OldPrice { get; private init; } + + public ProductPriceChangedIntegrationEvent(int productId, decimal newPrice, decimal oldPrice) { - public int ProductId { get; private init; } - - public decimal NewPrice { get; private init; } - - public decimal OldPrice { get; private init; } - - public ProductPriceChangedIntegrationEvent(int productId, decimal newPrice, decimal oldPrice) - { - ProductId = productId; - NewPrice = newPrice; - OldPrice = oldPrice; - } + ProductId = productId; + NewPrice = newPrice; + OldPrice = oldPrice; } } + diff --git a/src/Services/Basket/Basket.API/IntegrationEvents/Events/UserCheckoutAcceptedIntegrationEvent.cs b/src/Services/Basket/Basket.API/IntegrationEvents/Events/UserCheckoutAcceptedIntegrationEvent.cs index e79e0fbdd..d57a32c25 100644 --- a/src/Services/Basket/Basket.API/IntegrationEvents/Events/UserCheckoutAcceptedIntegrationEvent.cs +++ b/src/Services/Basket/Basket.API/IntegrationEvents/Events/UserCheckoutAcceptedIntegrationEvent.cs @@ -1,64 +1,59 @@ -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; -using Microsoft.eShopOnContainers.Services.Basket.API.Model; -using System; +namespace Basket.API.IntegrationEvents.Events; -namespace Basket.API.IntegrationEvents.Events +public record UserCheckoutAcceptedIntegrationEvent : IntegrationEvent { - public record UserCheckoutAcceptedIntegrationEvent : IntegrationEvent + public string UserId { get; } + + public string UserName { get; } + + public int OrderNumber { get; init; } + + public string City { get; init; } + + public string Street { get; init; } + + public string State { get; init; } + + public string Country { get; init; } + + public string ZipCode { get; init; } + + public string CardNumber { get; init; } + + public string CardHolderName { get; init; } + + public DateTime CardExpiration { get; init; } + + public string CardSecurityNumber { get; init; } + + public int CardTypeId { get; init; } + + public string Buyer { get; init; } + + public Guid RequestId { get; init; } + + public CustomerBasket Basket { get; } + + public UserCheckoutAcceptedIntegrationEvent(string userId, string userName, string city, string street, + string state, string country, string zipCode, string cardNumber, string cardHolderName, + DateTime cardExpiration, string cardSecurityNumber, int cardTypeId, string buyer, Guid requestId, + CustomerBasket basket) { - public string UserId { get; } - - public string UserName { get; } - - public int OrderNumber { get; init; } - - public string City { get; init; } - - public string Street { get; init; } - - public string State { get; init; } - - public string Country { get; init; } - - public string ZipCode { get; init; } - - public string CardNumber { get; init; } - - public string CardHolderName { get; init; } - - public DateTime CardExpiration { get; init; } - - public string CardSecurityNumber { get; init; } - - public int CardTypeId { get; init; } - - public string Buyer { get; init; } - - public Guid RequestId { get; init; } - - public CustomerBasket Basket { get; } - - public UserCheckoutAcceptedIntegrationEvent(string userId, string userName, string city, string street, - string state, string country, string zipCode, string cardNumber, string cardHolderName, - DateTime cardExpiration, string cardSecurityNumber, int cardTypeId, string buyer, Guid requestId, - CustomerBasket basket) - { - UserId = userId; - UserName = userName; - City = city; - Street = street; - State = state; - Country = country; - ZipCode = zipCode; - CardNumber = cardNumber; - CardHolderName = cardHolderName; - CardExpiration = cardExpiration; - CardSecurityNumber = cardSecurityNumber; - CardTypeId = cardTypeId; - Buyer = buyer; - Basket = basket; - RequestId = requestId; - } - + UserId = userId; + UserName = userName; + City = city; + Street = street; + State = state; + Country = country; + ZipCode = zipCode; + CardNumber = cardNumber; + CardHolderName = cardHolderName; + CardExpiration = cardExpiration; + CardSecurityNumber = cardSecurityNumber; + CardTypeId = cardTypeId; + Buyer = buyer; + Basket = basket; + RequestId = requestId; } + } diff --git a/src/Services/Basket/Basket.API/Model/BasketCheckout.cs b/src/Services/Basket/Basket.API/Model/BasketCheckout.cs index 410700773..5340444d7 100644 --- a/src/Services/Basket/Basket.API/Model/BasketCheckout.cs +++ b/src/Services/Basket/Basket.API/Model/BasketCheckout.cs @@ -1,32 +1,28 @@ -using System; +namespace Basket.API.Model; -namespace Basket.API.Model +public class BasketCheckout { - public class BasketCheckout - { - public string City { get; set; } + public string City { get; set; } - public string Street { get; set; } + public string Street { get; set; } - public string State { get; set; } + public string State { get; set; } - public string Country { get; set; } + public string Country { get; set; } - public string ZipCode { get; set; } + public string ZipCode { get; set; } - public string CardNumber { get; set; } + public string CardNumber { get; set; } - public string CardHolderName { get; set; } + public string CardHolderName { get; set; } - public DateTime CardExpiration { get; set; } + public DateTime CardExpiration { get; set; } - public string CardSecurityNumber { get; set; } + public string CardSecurityNumber { get; set; } - public int CardTypeId { get; set; } + public int CardTypeId { get; set; } - public string Buyer { get; set; } + public string Buyer { get; set; } - public Guid RequestId { get; set; } - } + public Guid RequestId { get; set; } } - diff --git a/src/Services/Basket/Basket.API/Model/BasketItem.cs b/src/Services/Basket/Basket.API/Model/BasketItem.cs index f781d5a60..85ebdb9a4 100644 --- a/src/Services/Basket/Basket.API/Model/BasketItem.cs +++ b/src/Services/Basket/Basket.API/Model/BasketItem.cs @@ -1,27 +1,24 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +namespace Microsoft.eShopOnContainers.Services.Basket.API.Model; -namespace Microsoft.eShopOnContainers.Services.Basket.API.Model +public class BasketItem : IValidatableObject { - public class BasketItem : IValidatableObject + public string Id { get; set; } + public int ProductId { get; set; } + public string ProductName { get; set; } + public decimal UnitPrice { get; set; } + public decimal OldUnitPrice { get; set; } + public int Quantity { get; set; } + public string PictureUrl { get; set; } + + public IEnumerable Validate(ValidationContext validationContext) { - public string Id { get; set; } - public int ProductId { get; set; } - public string ProductName { get; set; } - public decimal UnitPrice { get; set; } - public decimal OldUnitPrice { get; set; } - public int Quantity { get; set; } - public string PictureUrl { get; set; } - public IEnumerable Validate(ValidationContext validationContext) + var results = new List(); + + if (Quantity < 1) { - var results = new List(); - - if (Quantity < 1) - { - results.Add(new ValidationResult("Invalid number of units", new[] { "Quantity" })); - } - - return results; + results.Add(new ValidationResult("Invalid number of units", new[] { "Quantity" })); } + + return results; } } diff --git a/src/Services/Basket/Basket.API/Model/CustomerBasket.cs b/src/Services/Basket/Basket.API/Model/CustomerBasket.cs index 9ae495d4f..2ca370be8 100644 --- a/src/Services/Basket/Basket.API/Model/CustomerBasket.cs +++ b/src/Services/Basket/Basket.API/Model/CustomerBasket.cs @@ -1,21 +1,19 @@ -using System.Collections.Generic; +namespace Microsoft.eShopOnContainers.Services.Basket.API.Model; -namespace Microsoft.eShopOnContainers.Services.Basket.API.Model +public class CustomerBasket { - public class CustomerBasket + public string BuyerId { get; set; } + + public List Items { get; set; } = new(); + + public CustomerBasket() { - public string BuyerId { get; set; } - public List Items { get; set; } = new List(); + } - public CustomerBasket() - { - - } - - public CustomerBasket(string customerId) - { - BuyerId = customerId; - } + public CustomerBasket(string customerId) + { + BuyerId = customerId; } } + diff --git a/src/Services/Basket/Basket.API/Model/IBasketRepository.cs b/src/Services/Basket/Basket.API/Model/IBasketRepository.cs index 850b5b637..6081919fa 100644 --- a/src/Services/Basket/Basket.API/Model/IBasketRepository.cs +++ b/src/Services/Basket/Basket.API/Model/IBasketRepository.cs @@ -1,13 +1,10 @@ -using System.Collections.Generic; -using System.Threading.Tasks; +namespace Microsoft.eShopOnContainers.Services.Basket.API.Model; -namespace Microsoft.eShopOnContainers.Services.Basket.API.Model +public interface IBasketRepository { - public interface IBasketRepository - { - Task GetBasketAsync(string customerId); - IEnumerable GetUsers(); - Task UpdateBasketAsync(CustomerBasket basket); - Task DeleteBasketAsync(string id); - } + Task GetBasketAsync(string customerId); + IEnumerable GetUsers(); + Task UpdateBasketAsync(CustomerBasket basket); + Task DeleteBasketAsync(string id); } + diff --git a/src/Services/Basket/Basket.API/Program.cs b/src/Services/Basket/Basket.API/Program.cs index 040b115b5..ce09dfce1 100644 --- a/src/Services/Basket/Basket.API/Program.cs +++ b/src/Services/Basket/Basket.API/Program.cs @@ -1,18 +1,4 @@ -using Basket.API.Infrastructure.Middlewares; -using Microsoft.AspNetCore; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Server.Kestrel.Core; -using Microsoft.eShopOnContainers.Services.Basket.API; -using Microsoft.Extensions.Configuration; -using Azure.Identity; -using Serilog; -using System; -using System.IO; -using System.Net; -using Azure.Core; - -var configuration = GetConfiguration(); +var configuration = GetConfiguration(); Log.Logger = CreateSerilogLogger(configuration); diff --git a/src/Services/Basket/Basket.API/Services/IIdentityService.cs b/src/Services/Basket/Basket.API/Services/IIdentityService.cs index fe84e23d5..2e4d395e9 100644 --- a/src/Services/Basket/Basket.API/Services/IIdentityService.cs +++ b/src/Services/Basket/Basket.API/Services/IIdentityService.cs @@ -1,7 +1,7 @@ -namespace Microsoft.eShopOnContainers.Services.Basket.API.Services +namespace Microsoft.eShopOnContainers.Services.Basket.API.Services; + +public interface IIdentityService { - public interface IIdentityService - { - string GetUserIdentity(); - } + string GetUserIdentity(); } + diff --git a/src/Services/Basket/Basket.API/Services/IdentityService.cs b/src/Services/Basket/Basket.API/Services/IdentityService.cs index bc6b2faf4..9dded4ea3 100644 --- a/src/Services/Basket/Basket.API/Services/IdentityService.cs +++ b/src/Services/Basket/Basket.API/Services/IdentityService.cs @@ -1,21 +1,17 @@ - -using Microsoft.AspNetCore.Http; -using System; +namespace Microsoft.eShopOnContainers.Services.Basket.API.Services; -namespace Microsoft.eShopOnContainers.Services.Basket.API.Services +public class IdentityService : IIdentityService { - public class IdentityService : IIdentityService + private IHttpContextAccessor _context; + + public IdentityService(IHttpContextAccessor context) { - private IHttpContextAccessor _context; + _context = context ?? throw new ArgumentNullException(nameof(context)); + } - public IdentityService(IHttpContextAccessor context) - { - _context = context ?? throw new ArgumentNullException(nameof(context)); - } - - public string GetUserIdentity() - { - return _context.HttpContext.User.FindFirst("sub").Value; - } + public string GetUserIdentity() + { + return _context.HttpContext.User.FindFirst("sub").Value; } } + diff --git a/src/Services/Basket/Basket.API/Startup.cs b/src/Services/Basket/Basket.API/Startup.cs index 45adb5f66..b55845277 100644 --- a/src/Services/Basket/Basket.API/Startup.cs +++ b/src/Services/Basket/Basket.API/Startup.cs @@ -1,363 +1,325 @@ -using Autofac; -using Autofac.Extensions.DependencyInjection; -using Basket.API.Infrastructure.Filters; -using Basket.API.IntegrationEvents.EventHandling; -using Basket.API.IntegrationEvents.Events; -using GrpcBasket; -using HealthChecks.UI.Client; -using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Diagnostics.HealthChecks; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.Azure.ServiceBus; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ; -using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus; -using Microsoft.eShopOnContainers.Services.Basket.API.Controllers; -using Microsoft.eShopOnContainers.Services.Basket.API.Infrastructure.Repositories; -using Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.EventHandling; -using Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.Events; -using Microsoft.eShopOnContainers.Services.Basket.API.Model; -using Microsoft.eShopOnContainers.Services.Basket.API.Services; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Diagnostics.HealthChecks; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using Microsoft.OpenApi.Models; -using RabbitMQ.Client; -using StackExchange.Redis; -using System; -using System.Collections.Generic; -using System.IdentityModel.Tokens.Jwt; -using System.IO; +namespace Microsoft.eShopOnContainers.Services.Basket.API; -namespace Microsoft.eShopOnContainers.Services.Basket.API +public class Startup { - public class Startup + public Startup(IConfiguration configuration) { - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - public IConfiguration Configuration { get; } - - // This method gets called by the runtime. Use this method to add services to the container. - public virtual IServiceProvider ConfigureServices(IServiceCollection services) - { - services.AddGrpc(options => - { - options.EnableDetailedErrors = true; - }); - - RegisterAppInsights(services); - - services.AddControllers(options => - { - options.Filters.Add(typeof(HttpGlobalExceptionFilter)); - options.Filters.Add(typeof(ValidateModelStateFilter)); - - }) // Added for functional tests - .AddApplicationPart(typeof(BasketController).Assembly) - .AddJsonOptions(options => options.JsonSerializerOptions.WriteIndented = true); - - services.AddSwaggerGen(options => - { - options.DescribeAllEnumsAsStrings(); - options.SwaggerDoc("v1", new OpenApiInfo - { - Title = "eShopOnContainers - Basket HTTP API", - Version = "v1", - Description = "The Basket Service HTTP API" - }); - - options.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme - { - Type = SecuritySchemeType.OAuth2, - Flows = new OpenApiOAuthFlows() - { - Implicit = new OpenApiOAuthFlow() - { - AuthorizationUrl = new Uri($"{Configuration.GetValue("IdentityUrlExternal")}/connect/authorize"), - TokenUrl = new Uri($"{Configuration.GetValue("IdentityUrlExternal")}/connect/token"), - Scopes = new Dictionary() - { - { "basket", "Basket API" } - } - } - } - }); - - options.OperationFilter(); - }); - - ConfigureAuthService(services); - - services.AddCustomHealthCheck(Configuration); - - services.Configure(Configuration); - - //By connecting here we are making sure that our service - //cannot start until redis is ready. This might slow down startup, - //but given that there is a delay on resolving the ip address - //and then creating the connection it seems reasonable to move - //that cost to startup instead of having the first request pay the - //penalty. - services.AddSingleton(sp => - { - var settings = sp.GetRequiredService>().Value; - var configuration = ConfigurationOptions.Parse(settings.ConnectionString, true); - - configuration.ResolveDns = true; - - return ConnectionMultiplexer.Connect(configuration); - }); - - - if (Configuration.GetValue("AzureServiceBusEnabled")) - { - services.AddSingleton(sp => - { - var serviceBusConnectionString = Configuration["EventBusConnection"]; - var serviceBusConnection = new ServiceBusConnectionStringBuilder(serviceBusConnectionString); - - var subscriptionClientName = Configuration["SubscriptionClientName"]; - return new DefaultServiceBusPersisterConnection(serviceBusConnection, subscriptionClientName); - }); - } - else - { - services.AddSingleton(sp => - { - var logger = sp.GetRequiredService>(); - - var factory = new ConnectionFactory() - { - HostName = Configuration["EventBusConnection"], - DispatchConsumersAsync = true - }; - - if (!string.IsNullOrEmpty(Configuration["EventBusUserName"])) - { - factory.UserName = Configuration["EventBusUserName"]; - } - - if (!string.IsNullOrEmpty(Configuration["EventBusPassword"])) - { - factory.Password = Configuration["EventBusPassword"]; - } - - var retryCount = 5; - if (!string.IsNullOrEmpty(Configuration["EventBusRetryCount"])) - { - retryCount = int.Parse(Configuration["EventBusRetryCount"]); - } - - return new DefaultRabbitMQPersistentConnection(factory, logger, retryCount); - }); - } - - RegisterEventBus(services); - - - services.AddCors(options => - { - options.AddPolicy("CorsPolicy", - builder => builder - .SetIsOriginAllowed((host) => true) - .AllowAnyMethod() - .AllowAnyHeader() - .AllowCredentials()); - }); - services.AddSingleton(); - services.AddTransient(); - services.AddTransient(); - - services.AddOptions(); - - var container = new ContainerBuilder(); - container.Populate(services); - - return new AutofacServiceProvider(container.Build()); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) - { - //loggerFactory.AddAzureWebAppDiagnostics(); - //loggerFactory.AddApplicationInsights(app.ApplicationServices, LogLevel.Trace); - - var pathBase = Configuration["PATH_BASE"]; - if (!string.IsNullOrEmpty(pathBase)) - { - app.UsePathBase(pathBase); - } - - app.UseSwagger() - .UseSwaggerUI(setup => - { - setup.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "Basket.API V1"); - setup.OAuthClientId("basketswaggerui"); - setup.OAuthAppName("Basket Swagger UI"); - }); - - app.UseRouting(); - app.UseCors("CorsPolicy"); - ConfigureAuth(app); - - app.UseStaticFiles(); - - app.UseEndpoints(endpoints => - { - endpoints.MapGrpcService(); - endpoints.MapDefaultControllerRoute(); - endpoints.MapControllers(); - endpoints.MapGet("/_proto/", async ctx => - { - ctx.Response.ContentType = "text/plain"; - using var fs = new FileStream(Path.Combine(env.ContentRootPath, "Proto", "basket.proto"), FileMode.Open, FileAccess.Read); - using var sr = new StreamReader(fs); - while (!sr.EndOfStream) - { - var line = await sr.ReadLineAsync(); - if (line != "/* >>" || line != "<< */") - { - await ctx.Response.WriteAsync(line); - } - } - }); - endpoints.MapHealthChecks("/hc", new HealthCheckOptions() - { - Predicate = _ => true, - ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse - }); - endpoints.MapHealthChecks("/liveness", new HealthCheckOptions - { - Predicate = r => r.Name.Contains("self") - }); - }); - - ConfigureEventBus(app); - } - - private void RegisterAppInsights(IServiceCollection services) - { - services.AddApplicationInsightsTelemetry(Configuration); - services.AddApplicationInsightsKubernetesEnricher(); - } - - private void ConfigureAuthService(IServiceCollection services) - { - // prevent from mapping "sub" claim to nameidentifier. - JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Remove("sub"); - - 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(); - app.UseAuthorization(); - } - - private void RegisterEventBus(IServiceCollection services) - { - if (Configuration.GetValue("AzureServiceBusEnabled")) - { - services.AddSingleton(sp => - { - var serviceBusPersisterConnection = sp.GetRequiredService(); - var iLifetimeScope = sp.GetRequiredService(); - var logger = sp.GetRequiredService>(); - var eventBusSubcriptionsManager = sp.GetRequiredService(); - - return new EventBusServiceBus(serviceBusPersisterConnection, logger, - eventBusSubcriptionsManager, iLifetimeScope); - }); - } - else - { - services.AddSingleton(sp => - { - var subscriptionClientName = Configuration["SubscriptionClientName"]; - var rabbitMQPersistentConnection = sp.GetRequiredService(); - var iLifetimeScope = sp.GetRequiredService(); - var logger = sp.GetRequiredService>(); - var eventBusSubcriptionsManager = sp.GetRequiredService(); - - var retryCount = 5; - if (!string.IsNullOrEmpty(Configuration["EventBusRetryCount"])) - { - retryCount = int.Parse(Configuration["EventBusRetryCount"]); - } - - return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount); - }); - } - - services.AddSingleton(); - - services.AddTransient(); - services.AddTransient(); - } - - private void ConfigureEventBus(IApplicationBuilder app) - { - var eventBus = app.ApplicationServices.GetRequiredService(); - - eventBus.Subscribe(); - eventBus.Subscribe(); - } + Configuration = configuration; } - public static class CustomExtensionMethods + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public virtual IServiceProvider ConfigureServices(IServiceCollection services) { - public static IServiceCollection AddCustomHealthCheck(this IServiceCollection services, IConfiguration configuration) + services.AddGrpc(options => { - var hcBuilder = services.AddHealthChecks(); + options.EnableDetailedErrors = true; + }); - hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy()); + RegisterAppInsights(services); - hcBuilder - .AddRedis( - configuration["ConnectionString"], - name: "redis-check", - tags: new string[] { "redis" }); - - if (configuration.GetValue("AzureServiceBusEnabled")) + services.AddControllers(options => { - hcBuilder - .AddAzureServiceBusTopic( - configuration["EventBusConnection"], - topicName: "eshop_event_bus", - name: "basket-servicebus-check", - tags: new string[] { "servicebus" }); - } - else - { - hcBuilder - .AddRabbitMQ( - $"amqp://{configuration["EventBusConnection"]}", - name: "basket-rabbitmqbus-check", - tags: new string[] { "rabbitmqbus" }); - } + options.Filters.Add(typeof(HttpGlobalExceptionFilter)); + options.Filters.Add(typeof(ValidateModelStateFilter)); - return services; + }) // Added for functional tests + .AddApplicationPart(typeof(BasketController).Assembly) + .AddJsonOptions(options => options.JsonSerializerOptions.WriteIndented = true); + + services.AddSwaggerGen(options => + { + options.SwaggerDoc("v1", new OpenApiInfo + { + Title = "eShopOnContainers - Basket HTTP API", + Version = "v1", + Description = "The Basket Service HTTP API" + }); + + options.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme + { + Type = SecuritySchemeType.OAuth2, + Flows = new OpenApiOAuthFlows() + { + Implicit = new OpenApiOAuthFlow() + { + AuthorizationUrl = new Uri($"{Configuration.GetValue("IdentityUrlExternal")}/connect/authorize"), + TokenUrl = new Uri($"{Configuration.GetValue("IdentityUrlExternal")}/connect/token"), + Scopes = new Dictionary() + { + { "basket", "Basket API" } + } + } + } + }); + + options.OperationFilter(); + }); + + ConfigureAuthService(services); + + services.AddCustomHealthCheck(Configuration); + + services.Configure(Configuration); + + //By connecting here we are making sure that our service + //cannot start until redis is ready. This might slow down startup, + //but given that there is a delay on resolving the ip address + //and then creating the connection it seems reasonable to move + //that cost to startup instead of having the first request pay the + //penalty. + services.AddSingleton(sp => + { + var settings = sp.GetRequiredService>().Value; + var configuration = ConfigurationOptions.Parse(settings.ConnectionString, true); + + configuration.ResolveDns = true; + + return ConnectionMultiplexer.Connect(configuration); + }); + + + if (Configuration.GetValue("AzureServiceBusEnabled")) + { + services.AddSingleton(sp => + { + var serviceBusConnectionString = Configuration["EventBusConnection"]; + var serviceBusConnection = new ServiceBusConnectionStringBuilder(serviceBusConnectionString); + + var subscriptionClientName = Configuration["SubscriptionClientName"]; + return new DefaultServiceBusPersisterConnection(serviceBusConnection, subscriptionClientName); + }); } + else + { + services.AddSingleton(sp => + { + var logger = sp.GetRequiredService>(); + + var factory = new ConnectionFactory() + { + HostName = Configuration["EventBusConnection"], + DispatchConsumersAsync = true + }; + + if (!string.IsNullOrEmpty(Configuration["EventBusUserName"])) + { + factory.UserName = Configuration["EventBusUserName"]; + } + + if (!string.IsNullOrEmpty(Configuration["EventBusPassword"])) + { + factory.Password = Configuration["EventBusPassword"]; + } + + var retryCount = 5; + if (!string.IsNullOrEmpty(Configuration["EventBusRetryCount"])) + { + retryCount = int.Parse(Configuration["EventBusRetryCount"]); + } + + return new DefaultRabbitMQPersistentConnection(factory, logger, retryCount); + }); + } + + RegisterEventBus(services); + + + services.AddCors(options => + { + options.AddPolicy("CorsPolicy", + builder => builder + .SetIsOriginAllowed((host) => true) + .AllowAnyMethod() + .AllowAnyHeader() + .AllowCredentials()); + }); + services.AddSingleton(); + services.AddTransient(); + services.AddTransient(); + + services.AddOptions(); + + var container = new ContainerBuilder(); + container.Populate(services); + + return new AutofacServiceProvider(container.Build()); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) + { + //loggerFactory.AddAzureWebAppDiagnostics(); + //loggerFactory.AddApplicationInsights(app.ApplicationServices, LogLevel.Trace); + + var pathBase = Configuration["PATH_BASE"]; + if (!string.IsNullOrEmpty(pathBase)) + { + app.UsePathBase(pathBase); + } + + app.UseSwagger() + .UseSwaggerUI(setup => + { + setup.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "Basket.API V1"); + setup.OAuthClientId("basketswaggerui"); + setup.OAuthAppName("Basket Swagger UI"); + }); + + app.UseRouting(); + app.UseCors("CorsPolicy"); + ConfigureAuth(app); + + app.UseStaticFiles(); + + app.UseEndpoints(endpoints => + { + endpoints.MapGrpcService(); + endpoints.MapDefaultControllerRoute(); + endpoints.MapControllers(); + endpoints.MapGet("/_proto/", async ctx => + { + ctx.Response.ContentType = "text/plain"; + using var fs = new FileStream(Path.Combine(env.ContentRootPath, "Proto", "basket.proto"), FileMode.Open, FileAccess.Read); + using var sr = new StreamReader(fs); + while (!sr.EndOfStream) + { + var line = await sr.ReadLineAsync(); + if (line != "/* >>" || line != "<< */") + { + await ctx.Response.WriteAsync(line); + } + } + }); + endpoints.MapHealthChecks("/hc", new HealthCheckOptions() + { + Predicate = _ => true, + ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse + }); + endpoints.MapHealthChecks("/liveness", new HealthCheckOptions + { + Predicate = r => r.Name.Contains("self") + }); + }); + + ConfigureEventBus(app); + } + + private void RegisterAppInsights(IServiceCollection services) + { + services.AddApplicationInsightsTelemetry(Configuration); + services.AddApplicationInsightsKubernetesEnricher(); + } + + private void ConfigureAuthService(IServiceCollection services) + { + // prevent from mapping "sub" claim to nameidentifier. + JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Remove("sub"); + + 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(); + app.UseAuthorization(); + } + + private void RegisterEventBus(IServiceCollection services) + { + if (Configuration.GetValue("AzureServiceBusEnabled")) + { + services.AddSingleton(sp => + { + var serviceBusPersisterConnection = sp.GetRequiredService(); + var iLifetimeScope = sp.GetRequiredService(); + var logger = sp.GetRequiredService>(); + var eventBusSubcriptionsManager = sp.GetRequiredService(); + + return new EventBusServiceBus(serviceBusPersisterConnection, logger, + eventBusSubcriptionsManager, iLifetimeScope); + }); + } + else + { + services.AddSingleton(sp => + { + var subscriptionClientName = Configuration["SubscriptionClientName"]; + var rabbitMQPersistentConnection = sp.GetRequiredService(); + var iLifetimeScope = sp.GetRequiredService(); + var logger = sp.GetRequiredService>(); + var eventBusSubcriptionsManager = sp.GetRequiredService(); + + var retryCount = 5; + if (!string.IsNullOrEmpty(Configuration["EventBusRetryCount"])) + { + retryCount = int.Parse(Configuration["EventBusRetryCount"]); + } + + return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount); + }); + } + + services.AddSingleton(); + + services.AddTransient(); + services.AddTransient(); + } + + private void ConfigureEventBus(IApplicationBuilder app) + { + var eventBus = app.ApplicationServices.GetRequiredService(); + + eventBus.Subscribe(); + eventBus.Subscribe(); + } +} + +public static class CustomExtensionMethods +{ + public static IServiceCollection AddCustomHealthCheck(this IServiceCollection services, IConfiguration configuration) + { + var hcBuilder = services.AddHealthChecks(); + + hcBuilder.AddCheck("self", () => HealthCheckResult.Healthy()); + + hcBuilder + .AddRedis( + configuration["ConnectionString"], + name: "redis-check", + tags: new string[] { "redis" }); + + if (configuration.GetValue("AzureServiceBusEnabled")) + { + hcBuilder + .AddAzureServiceBusTopic( + configuration["EventBusConnection"], + topicName: "eshop_event_bus", + name: "basket-servicebus-check", + tags: new string[] { "servicebus" }); + } + else + { + hcBuilder + .AddRabbitMQ( + $"amqp://{configuration["EventBusConnection"]}", + name: "basket-rabbitmqbus-check", + tags: new string[] { "rabbitmqbus" }); + } + + return services; } } diff --git a/src/Services/Basket/Basket.API/TestHttpResponseTrailersFeature.cs b/src/Services/Basket/Basket.API/TestHttpResponseTrailersFeature.cs index 7cab5a07b..b1cfef87b 100644 --- a/src/Services/Basket/Basket.API/TestHttpResponseTrailersFeature.cs +++ b/src/Services/Basket/Basket.API/TestHttpResponseTrailersFeature.cs @@ -1,10 +1,6 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Features; +namespace Microsoft.eShopOnContainers.Services.Basket.API; -namespace Microsoft.eShopOnContainers.Services.Basket.API +internal class TestHttpResponseTrailersFeature : IHttpResponseTrailersFeature { - internal class TestHttpResponseTrailersFeature : IHttpResponseTrailersFeature - { - public IHeaderDictionary Trailers { get; set; } - } -} \ No newline at end of file + public IHeaderDictionary Trailers { get; set; } +} diff --git a/src/Services/Catalog/Catalog.API/Dockerfile b/src/Services/Catalog/Catalog.API/Dockerfile index 35cd836d0..7dc0c09ae 100644 --- a/src/Services/Catalog/Catalog.API/Dockerfile +++ b/src/Services/Catalog/Catalog.API/Dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.6 AS base +FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.7 AS base WORKDIR /app EXPOSE 80 EXPOSE 443 -FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.6 AS build +FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.7 AS build WORKDIR /src # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles diff --git a/src/Services/Identity/Identity.API/Certificate/Certificate.cs b/src/Services/Identity/Identity.API/Certificate/Certificate.cs index d20726d12..4bb0155b5 100644 --- a/src/Services/Identity/Identity.API/Certificate/Certificate.cs +++ b/src/Services/Identity/Identity.API/Certificate/Certificate.cs @@ -1,8 +1,4 @@ -using System.IO; -using System.Reflection; -using System.Security.Cryptography.X509Certificates; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Certificates +namespace Microsoft.eShopOnContainers.Services.Identity.API.Certificates { static class Certificate { diff --git a/src/Services/Identity/Identity.API/Configuration/Config.cs b/src/Services/Identity/Identity.API/Configuration/Config.cs index 22c3c9b7b..6d5393bde 100644 --- a/src/Services/Identity/Identity.API/Configuration/Config.cs +++ b/src/Services/Identity/Identity.API/Configuration/Config.cs @@ -1,6 +1,4 @@ -using IdentityServer4; -using IdentityServer4.Models; -using System.Collections.Generic; +using IdentityServer4.Models; namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration { @@ -8,7 +6,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration { // ApiResources define the apis in your system public static IEnumerable GetApis() - { + { return new List { new ApiResource("orders", "Orders Service"), @@ -65,7 +63,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration AllowedGrantTypes = GrantTypes.Hybrid, //Used to retrieve the access token on the back channel. ClientSecrets = - { + { new Secret("secret".Sha256()) }, RedirectUris = { clientsUrl["Xamarin"] }, @@ -93,6 +91,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration ClientName = "MVC Client", ClientSecrets = new List { + new Secret("secret".Sha256()) }, ClientUri = $"{clientsUrl["Mvc"]}", // public uri of the client diff --git a/src/Services/Identity/Identity.API/Controllers/AccountController.cs b/src/Services/Identity/Identity.API/Controllers/AccountController.cs index fd041cf7b..22e347fb9 100644 --- a/src/Services/Identity/Identity.API/Controllers/AccountController.cs +++ b/src/Services/Identity/Identity.API/Controllers/AccountController.cs @@ -1,23 +1,4 @@ -using IdentityModel; -using IdentityServer4; -using IdentityServer4.Models; -using IdentityServer4.Services; -using IdentityServer4.Stores; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.eShopOnContainers.Services.Identity.API.Models; -using Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels; -using Microsoft.eShopOnContainers.Services.Identity.API.Services; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; -using System; -using System.Linq; -using System.Security.Claims; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Controllers +namespace Microsoft.eShopOnContainers.Services.Identity.API.Controllers { /// /// This sample controller implements a typical login/logout/provision workflow for local accounts. diff --git a/src/Services/Identity/Identity.API/Controllers/ConsentController.cs b/src/Services/Identity/Identity.API/Controllers/ConsentController.cs index b8a11fb1c..6ce04db57 100644 --- a/src/Services/Identity/Identity.API/Controllers/ConsentController.cs +++ b/src/Services/Identity/Identity.API/Controllers/ConsentController.cs @@ -1,13 +1,4 @@ -using IdentityServer4.Models; -using IdentityServer4.Services; -using IdentityServer4.Stores; -using Microsoft.AspNetCore.Mvc; -using Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels; -using Microsoft.Extensions.Logging; -using System.Linq; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Controllers +namespace Microsoft.eShopOnContainers.Services.Identity.API.Controllers { /// /// This controller implements the consent logic diff --git a/src/Services/Identity/Identity.API/Controllers/HomeController.cs b/src/Services/Identity/Identity.API/Controllers/HomeController.cs index 30edd16b3..3c31c4ab1 100644 --- a/src/Services/Identity/Identity.API/Controllers/HomeController.cs +++ b/src/Services/Identity/Identity.API/Controllers/HomeController.cs @@ -1,12 +1,4 @@ - -using IdentityServer4.Services; -using Microsoft.AspNetCore.Mvc; -using Microsoft.eShopOnContainers.Services.Identity.API.Models; -using Microsoft.eShopOnContainers.Services.Identity.API.Services; -using Microsoft.Extensions.Options; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Controllers +namespace Microsoft.eShopOnContainers.Services.Identity.API.Controllers { public class HomeController : Controller { diff --git a/src/Services/Identity/Identity.API/Data/ApplicationDbContext.cs b/src/Services/Identity/Identity.API/Data/ApplicationDbContext.cs index aec67258c..227406008 100644 --- a/src/Services/Identity/Identity.API/Data/ApplicationDbContext.cs +++ b/src/Services/Identity/Identity.API/Data/ApplicationDbContext.cs @@ -1,8 +1,4 @@ -using Microsoft.AspNetCore.Identity.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore; -using Microsoft.eShopOnContainers.Services.Identity.API.Models; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Data +namespace Microsoft.eShopOnContainers.Services.Identity.API.Data { public class ApplicationDbContext : IdentityDbContext { diff --git a/src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs b/src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs index b80f506a9..1ce33daa3 100644 --- a/src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs +++ b/src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs @@ -1,18 +1,4 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Identity; -using Microsoft.eShopOnContainers.Services.Identity.API.Extensions; -using Microsoft.eShopOnContainers.Services.Identity.API.Models; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -using System.Linq; -using System.Text.RegularExpressions; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Data +namespace Microsoft.eShopOnContainers.Services.Identity.API.Data { @@ -58,7 +44,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data } } - private IEnumerable GetUsersFromFile(string contentRootPath, ILogger logger) + private IEnumerable GetUsersFromFile(string contentRootPath, Microsoft.Extensions.Logging.ILogger logger) { string csvFileUsers = Path.Combine(contentRootPath, "Setup", "Users.csv"); @@ -192,7 +178,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data return csvheaders; } - static void GetPreconfiguredImages(string contentRootPath, string webroot, ILogger logger) + static void GetPreconfiguredImages(string contentRootPath, string webroot, Microsoft.Extensions.Logging.ILogger logger) { try { diff --git a/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs b/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs index 6c49106bb..e3df90fdd 100644 --- a/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs +++ b/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs @@ -1,12 +1,4 @@ -using IdentityServer4.EntityFramework.DbContexts; -using IdentityServer4.EntityFramework.Entities; -using IdentityServer4.EntityFramework.Mappers; -using Microsoft.EntityFrameworkCore; -using Microsoft.eShopOnContainers.Services.Identity.API.Configuration; -using Microsoft.Extensions.Configuration; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using IdentityServer4.EntityFramework.Entities; namespace Microsoft.eShopOnContainers.Services.Identity.API.Data { diff --git a/src/Services/Identity/Identity.API/Devspaces/DevspacesRedirectUriValidator.cs b/src/Services/Identity/Identity.API/Devspaces/DevspacesRedirectUriValidator.cs index d43a9ab15..aed143f22 100644 --- a/src/Services/Identity/Identity.API/Devspaces/DevspacesRedirectUriValidator.cs +++ b/src/Services/Identity/Identity.API/Devspaces/DevspacesRedirectUriValidator.cs @@ -1,27 +1,21 @@ -using IdentityServer4.Models; -using IdentityServer4.Validation; -using Microsoft.Extensions.Logging; -using System.Threading.Tasks; - - namespace Microsoft.eShopOnContainers.Services.Identity.API.Devspaces { public class DevspacesRedirectUriValidator : IRedirectUriValidator { - private readonly ILogger _logger; + private readonly Microsoft.Extensions.Logging.ILogger _logger; public DevspacesRedirectUriValidator(ILogger logger) { _logger = logger; } - public Task IsPostLogoutRedirectUriValidAsync(string requestedUri, Client client) + public Task IsPostLogoutRedirectUriValidAsync(string requestedUri, IdentityServer4.Models.Client client) { _logger.LogInformation("Client {ClientName} used post logout uri {RequestedUri}.", client.ClientName, requestedUri); return Task.FromResult(true); } - public Task IsRedirectUriValidAsync(string requestedUri, Client client) + public Task IsRedirectUriValidAsync(string requestedUri, IdentityServer4.Models.Client client) { _logger.LogInformation("Client {ClientName} used post logout uri {RequestedUri}.", client.ClientName, requestedUri); return Task.FromResult(true); diff --git a/src/Services/Identity/Identity.API/Devspaces/IdentityDevspacesBuilderExtensions.cs b/src/Services/Identity/Identity.API/Devspaces/IdentityDevspacesBuilderExtensions.cs index 5294177c7..201c85ab2 100644 --- a/src/Services/Identity/Identity.API/Devspaces/IdentityDevspacesBuilderExtensions.cs +++ b/src/Services/Identity/Identity.API/Devspaces/IdentityDevspacesBuilderExtensions.cs @@ -1,6 +1,4 @@ -using Microsoft.Extensions.DependencyInjection; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Devspaces +namespace Microsoft.eShopOnContainers.Services.Identity.API.Devspaces { static class IdentityDevspacesBuilderExtensions { diff --git a/src/Services/Identity/Identity.API/Dockerfile b/src/Services/Identity/Identity.API/Dockerfile index c0a254bf0..0d7a78513 100644 --- a/src/Services/Identity/Identity.API/Dockerfile +++ b/src/Services/Identity/Identity.API/Dockerfile @@ -1,8 +1,8 @@ -FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.6 AS base +FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.7 AS base WORKDIR /app EXPOSE 80 -FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.6 AS build +FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.7 AS build WORKDIR /src # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles diff --git a/src/Services/Identity/Identity.API/Extensions/LinqSelectExtensions.cs b/src/Services/Identity/Identity.API/Extensions/LinqSelectExtensions.cs index 1061881af..0e2c4c72b 100644 --- a/src/Services/Identity/Identity.API/Extensions/LinqSelectExtensions.cs +++ b/src/Services/Identity/Identity.API/Extensions/LinqSelectExtensions.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Extensions +namespace Microsoft.eShopOnContainers.Services.Identity.API.Extensions { public static class LinqSelectExtensions { diff --git a/src/Services/Identity/Identity.API/Factories/ApplicationDbContextFactory.cs b/src/Services/Identity/Identity.API/Factories/ApplicationDbContextFactory.cs index bb3f7bfe2..c1fb0198c 100644 --- a/src/Services/Identity/Identity.API/Factories/ApplicationDbContextFactory.cs +++ b/src/Services/Identity/Identity.API/Factories/ApplicationDbContextFactory.cs @@ -1,10 +1,4 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; -using Microsoft.eShopOnContainers.Services.Identity.API.Data; -using Microsoft.Extensions.Configuration; -using System.IO; - -namespace Identity.API.Factories +namespace Identity.API.Factories { public class ApplicationDbContextFactory : IDesignTimeDbContextFactory { diff --git a/src/Services/Identity/Identity.API/Factories/ConfigurationDbContextFactory.cs b/src/Services/Identity/Identity.API/Factories/ConfigurationDbContextFactory.cs index e304f50a8..0fdbe8598 100644 --- a/src/Services/Identity/Identity.API/Factories/ConfigurationDbContextFactory.cs +++ b/src/Services/Identity/Identity.API/Factories/ConfigurationDbContextFactory.cs @@ -1,11 +1,4 @@ -using IdentityServer4.EntityFramework.DbContexts; -using IdentityServer4.EntityFramework.Options; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; -using Microsoft.Extensions.Configuration; -using System.IO; - -namespace Identity.API.Factories +namespace Identity.API.Factories { public class ConfigurationDbContextFactory : IDesignTimeDbContextFactory { diff --git a/src/Services/Identity/Identity.API/Factories/PersistedGrantDbContextFactory.cs b/src/Services/Identity/Identity.API/Factories/PersistedGrantDbContextFactory.cs index b3dff8d9a..83380dfd0 100644 --- a/src/Services/Identity/Identity.API/Factories/PersistedGrantDbContextFactory.cs +++ b/src/Services/Identity/Identity.API/Factories/PersistedGrantDbContextFactory.cs @@ -1,11 +1,4 @@ -using IdentityServer4.EntityFramework.DbContexts; -using IdentityServer4.EntityFramework.Options; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; -using Microsoft.Extensions.Configuration; -using System.IO; - -namespace Identity.API.Factories +namespace Identity.API.Factories { public class PersistedGrantDbContextFactory : IDesignTimeDbContextFactory { diff --git a/src/Services/Identity/Identity.API/GlobalUsings.cs b/src/Services/Identity/Identity.API/GlobalUsings.cs new file mode 100644 index 000000000..bfbb354db --- /dev/null +++ b/src/Services/Identity/Identity.API/GlobalUsings.cs @@ -0,0 +1,183 @@ +global using Microsoft.eShopOnContainers.Services.Identity.API.Extensions; +global using System.IO.Compression; +global using Autofac.Extensions.DependencyInjection; +global using Autofac; +global using Azure.Core; +global using Azure.Identity; +global using HealthChecks.UI.Client; +global using IdentityModel; +global using IdentityServer4.EntityFramework.DbContexts; +global using IdentityServer4.EntityFramework.Mappers; +global using IdentityServer4.EntityFramework.Options; +global using IdentityServer4.Models; +global using IdentityServer4.Services; +global using IdentityServer4.Stores; +global using IdentityServer4.Validation; +global using IdentityServer4; +global using Microsoft.AspNetCore.Authentication; +global using Microsoft.AspNetCore.Authorization; +global using Microsoft.AspNetCore.Builder; +global using Microsoft.AspNetCore.Diagnostics.HealthChecks; +global using Microsoft.AspNetCore.Hosting; +global using Microsoft.AspNetCore.Identity.EntityFrameworkCore; +global using Microsoft.AspNetCore.Identity; +global using Microsoft.AspNetCore.Mvc.Rendering; +global using Microsoft.AspNetCore.Mvc; +global using Microsoft.AspNetCore; +global using Microsoft.EntityFrameworkCore.Design; +global using Microsoft.EntityFrameworkCore.Infrastructure; +global using Microsoft.EntityFrameworkCore.Metadata; +global using Microsoft.EntityFrameworkCore.Migrations; +global using Microsoft.EntityFrameworkCore; +global using Microsoft.eShopOnContainers.Services.Identity.API.Certificates; +global using Microsoft.eShopOnContainers.Services.Identity.API.Configuration; +global using Microsoft.eShopOnContainers.Services.Identity.API.Data; +global using Microsoft.eShopOnContainers.Services.Identity.API.Devspaces; +global using Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels; +global using Microsoft.eShopOnContainers.Services.Identity.API.Models; +global using Microsoft.eShopOnContainers.Services.Identity.API.Services; +global using Microsoft.eShopOnContainers.Services.Identity.API; +global using Microsoft.Extensions.Configuration; +global using Microsoft.Extensions.DependencyInjection; +global using Microsoft.Extensions.Diagnostics.HealthChecks; +global using Microsoft.Extensions.Hosting; +global using Microsoft.Extensions.Logging; +global using Microsoft.Extensions.Options; +global using Polly; +global using Serilog; +global using StackExchange.Redis; +global using System.Collections.Generic; +global using System.ComponentModel.DataAnnotations; +global using System.Data.SqlClient; +global using System.IdentityModel.Tokens.Jwt; +global using System.IO; +global using System.Linq; +global using System.Reflection; +global using System.Security.Claims; +global using System.Security.Cryptography.X509Certificates; +global using System.Text.RegularExpressions; +global using System.Threading.Tasks; +global using System; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Services/Identity/Identity.API/IWebHostExtensions.cs b/src/Services/Identity/Identity.API/IWebHostExtensions.cs index aff262b73..c6c0cd4b7 100644 --- a/src/Services/Identity/Identity.API/IWebHostExtensions.cs +++ b/src/Services/Identity/Identity.API/IWebHostExtensions.cs @@ -1,11 +1,3 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Polly; -using System; -using System.Data.SqlClient; - namespace Microsoft.AspNetCore.Hosting { public static class IWebHostExtensions diff --git a/src/Services/Identity/Identity.API/Identity.API.csproj b/src/Services/Identity/Identity.API/Identity.API.csproj index 59395fe34..bdf899a07 100644 --- a/src/Services/Identity/Identity.API/Identity.API.csproj +++ b/src/Services/Identity/Identity.API/Identity.API.csproj @@ -16,41 +16,44 @@ - + - - - + - - - - - + + + + + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + + + - - - - - - - - - + + + + + + + + + + + + diff --git a/src/Services/Identity/Identity.API/Migrations/20190729091724_InitialMigration.Designer.cs b/src/Services/Identity/Identity.API/Migrations/20210813072445_InitialMigration.Designer.cs similarity index 54% rename from src/Services/Identity/Identity.API/Migrations/20190729091724_InitialMigration.Designer.cs rename to src/Services/Identity/Identity.API/Migrations/20210813072445_InitialMigration.Designer.cs index 5ad802992..d0a6d3f81 100644 --- a/src/Services/Identity/Identity.API/Migrations/20190729091724_InitialMigration.Designer.cs +++ b/src/Services/Identity/Identity.API/Migrations/20210813072445_InitialMigration.Designer.cs @@ -10,209 +10,258 @@ using Microsoft.eShopOnContainers.Services.Identity.API.Data; namespace Identity.API.Migrations { [DbContext(typeof(ApplicationDbContext))] - [Migration("20190729091724_InitialMigration")] + [Migration("20210813072445_InitialMigration")] partial class InitialMigration { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "3.0.0-preview7.19362.6") .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("ProductVersion", "6.0.0-preview.7.21378.4") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => { - b.Property("Id"); + b.Property("Id") + .HasColumnType("nvarchar(450)"); b.Property("ConcurrencyStamp") - .IsConcurrencyToken(); + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); b.Property("Name") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); b.Property("NormalizedName") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); b.HasKey("Id"); b.HasIndex("NormalizedName") .IsUnique() - .HasName("RoleNameIndex") + .HasDatabaseName("RoleNameIndex") .HasFilter("[NormalizedName] IS NOT NULL"); - b.ToTable("AspNetRoles"); + b.ToTable("AspNetRoles", (string)null); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClaimType"); + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); - b.Property("ClaimValue"); + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); b.Property("RoleId") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(450)"); b.HasKey("Id"); b.HasIndex("RoleId"); - b.ToTable("AspNetRoleClaims"); + b.ToTable("AspNetRoleClaims", (string)null); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClaimType"); + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); - b.Property("ClaimValue"); + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); b.Property("UserId") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(450)"); b.HasKey("Id"); b.HasIndex("UserId"); - b.ToTable("AspNetUserClaims"); + b.ToTable("AspNetUserClaims", (string)null); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { - b.Property("LoginProvider"); + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); - b.Property("ProviderKey"); + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); - b.Property("ProviderDisplayName"); + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); b.Property("UserId") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(450)"); b.HasKey("LoginProvider", "ProviderKey"); b.HasIndex("UserId"); - b.ToTable("AspNetUserLogins"); + b.ToTable("AspNetUserLogins", (string)null); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => { - b.Property("UserId"); + b.Property("UserId") + .HasColumnType("nvarchar(450)"); - b.Property("RoleId"); + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); b.HasKey("UserId", "RoleId"); b.HasIndex("RoleId"); - b.ToTable("AspNetUserRoles"); + b.ToTable("AspNetUserRoles", (string)null); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => { - b.Property("UserId"); + b.Property("UserId") + .HasColumnType("nvarchar(450)"); - b.Property("LoginProvider"); + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); - b.Property("Name"); + b.Property("Name") + .HasColumnType("nvarchar(450)"); - b.Property("Value"); + b.Property("Value") + .HasColumnType("nvarchar(max)"); b.HasKey("UserId", "LoginProvider", "Name"); - b.ToTable("AspNetUserTokens"); + b.ToTable("AspNetUserTokens", (string)null); }); modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Identity.API.Models.ApplicationUser", b => { - b.Property("Id"); + b.Property("Id") + .HasColumnType("nvarchar(450)"); - b.Property("AccessFailedCount"); + b.Property("AccessFailedCount") + .HasColumnType("int"); b.Property("CardHolderName") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); b.Property("CardNumber") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("CardType"); + b.Property("CardType") + .HasColumnType("int"); b.Property("City") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); b.Property("ConcurrencyStamp") - .IsConcurrencyToken(); + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); b.Property("Country") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); b.Property("Email") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); - b.Property("EmailConfirmed"); + b.Property("EmailConfirmed") + .HasColumnType("bit"); b.Property("Expiration") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); b.Property("LastName") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("LockoutEnabled"); + b.Property("LockoutEnabled") + .HasColumnType("bit"); - b.Property("LockoutEnd"); + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); b.Property("Name") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); b.Property("NormalizedEmail") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); b.Property("NormalizedUserName") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); - b.Property("PasswordHash"); + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); - b.Property("PhoneNumber"); + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); - b.Property("PhoneNumberConfirmed"); + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); b.Property("SecurityNumber") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("SecurityStamp"); + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); b.Property("State") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); b.Property("Street") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("TwoFactorEnabled"); + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); b.Property("UserName") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); b.Property("ZipCode") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); b.HasIndex("NormalizedEmail") - .HasName("EmailIndex"); + .HasDatabaseName("EmailIndex"); b.HasIndex("NormalizedUserName") .IsUnique() - .HasName("UserNameIndex") + .HasDatabaseName("UserNameIndex") .HasFilter("[NormalizedUserName] IS NOT NULL"); - b.ToTable("AspNetUsers"); + b.ToTable("AspNetUsers", (string)null); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => diff --git a/src/Services/Identity/Identity.API/Migrations/20190729091724_InitialMigration.cs b/src/Services/Identity/Identity.API/Migrations/20210813072445_InitialMigration.cs similarity index 57% rename from src/Services/Identity/Identity.API/Migrations/20190729091724_InitialMigration.cs rename to src/Services/Identity/Identity.API/Migrations/20210813072445_InitialMigration.cs index 58c80842b..88587a677 100644 --- a/src/Services/Identity/Identity.API/Migrations/20190729091724_InitialMigration.cs +++ b/src/Services/Identity/Identity.API/Migrations/20210813072445_InitialMigration.cs @@ -1,6 +1,5 @@ -using Microsoft.EntityFrameworkCore.Metadata; +using System; using Microsoft.EntityFrameworkCore.Migrations; -using System; namespace Identity.API.Migrations { @@ -12,10 +11,10 @@ namespace Identity.API.Migrations name: "AspNetRoles", columns: table => new { - Id = table.Column(nullable: false), - Name = table.Column(maxLength: 256, nullable: true), - NormalizedName = table.Column(maxLength: 256, nullable: true), - ConcurrencyStamp = table.Column(nullable: true) + Id = table.Column(type: "nvarchar(450)", nullable: false), + Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { @@ -26,33 +25,33 @@ namespace Identity.API.Migrations name: "AspNetUsers", columns: table => new { - Id = table.Column(nullable: false), - UserName = table.Column(maxLength: 256, nullable: true), - NormalizedUserName = table.Column(maxLength: 256, nullable: true), - Email = table.Column(maxLength: 256, nullable: true), - NormalizedEmail = table.Column(maxLength: 256, nullable: true), - EmailConfirmed = table.Column(nullable: false), - PasswordHash = table.Column(nullable: true), - SecurityStamp = table.Column(nullable: true), - ConcurrencyStamp = table.Column(nullable: true), - PhoneNumber = table.Column(nullable: true), - PhoneNumberConfirmed = table.Column(nullable: false), - TwoFactorEnabled = table.Column(nullable: false), - LockoutEnd = table.Column(nullable: true), - LockoutEnabled = table.Column(nullable: false), - AccessFailedCount = table.Column(nullable: false), - CardNumber = table.Column(nullable: false), - SecurityNumber = table.Column(nullable: false), - Expiration = table.Column(nullable: false), - CardHolderName = table.Column(nullable: false), - CardType = table.Column(nullable: false), - Street = table.Column(nullable: false), - City = table.Column(nullable: false), - State = table.Column(nullable: false), - Country = table.Column(nullable: false), - ZipCode = table.Column(nullable: false), - Name = table.Column(nullable: false), - LastName = table.Column(nullable: false) + Id = table.Column(type: "nvarchar(450)", nullable: false), + CardNumber = table.Column(type: "nvarchar(max)", nullable: false), + SecurityNumber = table.Column(type: "nvarchar(max)", nullable: false), + Expiration = table.Column(type: "nvarchar(max)", nullable: false), + CardHolderName = table.Column(type: "nvarchar(max)", nullable: false), + CardType = table.Column(type: "int", nullable: false), + Street = table.Column(type: "nvarchar(max)", nullable: false), + City = table.Column(type: "nvarchar(max)", nullable: false), + State = table.Column(type: "nvarchar(max)", nullable: false), + Country = table.Column(type: "nvarchar(max)", nullable: false), + ZipCode = table.Column(type: "nvarchar(max)", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + LastName = table.Column(type: "nvarchar(max)", nullable: false), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + NormalizedEmail = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + EmailConfirmed = table.Column(type: "bit", nullable: false), + PasswordHash = table.Column(type: "nvarchar(max)", nullable: true), + SecurityStamp = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true), + PhoneNumber = table.Column(type: "nvarchar(max)", nullable: true), + PhoneNumberConfirmed = table.Column(type: "bit", nullable: false), + TwoFactorEnabled = table.Column(type: "bit", nullable: false), + LockoutEnd = table.Column(type: "datetimeoffset", nullable: true), + LockoutEnabled = table.Column(type: "bit", nullable: false), + AccessFailedCount = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -63,11 +62,11 @@ namespace Identity.API.Migrations name: "AspNetRoleClaims", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - RoleId = table.Column(nullable: false), - ClaimType = table.Column(nullable: true), - ClaimValue = table.Column(nullable: true) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + RoleId = table.Column(type: "nvarchar(450)", nullable: false), + ClaimType = table.Column(type: "nvarchar(max)", nullable: true), + ClaimValue = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { @@ -84,11 +83,11 @@ namespace Identity.API.Migrations name: "AspNetUserClaims", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - UserId = table.Column(nullable: false), - ClaimType = table.Column(nullable: true), - ClaimValue = table.Column(nullable: true) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "nvarchar(450)", nullable: false), + ClaimType = table.Column(type: "nvarchar(max)", nullable: true), + ClaimValue = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { @@ -105,10 +104,10 @@ namespace Identity.API.Migrations name: "AspNetUserLogins", columns: table => new { - LoginProvider = table.Column(nullable: false), - ProviderKey = table.Column(nullable: false), - ProviderDisplayName = table.Column(nullable: true), - UserId = table.Column(nullable: false) + LoginProvider = table.Column(type: "nvarchar(450)", nullable: false), + ProviderKey = table.Column(type: "nvarchar(450)", nullable: false), + ProviderDisplayName = table.Column(type: "nvarchar(max)", nullable: true), + UserId = table.Column(type: "nvarchar(450)", nullable: false) }, constraints: table => { @@ -125,8 +124,8 @@ namespace Identity.API.Migrations name: "AspNetUserRoles", columns: table => new { - UserId = table.Column(nullable: false), - RoleId = table.Column(nullable: false) + UserId = table.Column(type: "nvarchar(450)", nullable: false), + RoleId = table.Column(type: "nvarchar(450)", nullable: false) }, constraints: table => { @@ -149,10 +148,10 @@ namespace Identity.API.Migrations name: "AspNetUserTokens", columns: table => new { - UserId = table.Column(nullable: false), - LoginProvider = table.Column(nullable: false), - Name = table.Column(nullable: false), - Value = table.Column(nullable: true) + UserId = table.Column(type: "nvarchar(450)", nullable: false), + LoginProvider = table.Column(type: "nvarchar(450)", nullable: false), + Name = table.Column(type: "nvarchar(450)", nullable: false), + Value = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { diff --git a/src/Services/Identity/Identity.API/Migrations/ApplicationDbContextModelSnapshot.cs b/src/Services/Identity/Identity.API/Migrations/ApplicationDbContextModelSnapshot.cs index 2819cd6eb..3c3a8e502 100644 --- a/src/Services/Identity/Identity.API/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/Services/Identity/Identity.API/Migrations/ApplicationDbContextModelSnapshot.cs @@ -15,202 +15,251 @@ namespace Identity.API.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "3.0.0-preview7.19362.6") .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("ProductVersion", "6.0.0-preview.7.21378.4") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => { - b.Property("Id"); + b.Property("Id") + .HasColumnType("nvarchar(450)"); b.Property("ConcurrencyStamp") - .IsConcurrencyToken(); + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); b.Property("Name") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); b.Property("NormalizedName") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); b.HasKey("Id"); b.HasIndex("NormalizedName") .IsUnique() - .HasName("RoleNameIndex") + .HasDatabaseName("RoleNameIndex") .HasFilter("[NormalizedName] IS NOT NULL"); - b.ToTable("AspNetRoles"); + b.ToTable("AspNetRoles", (string)null); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClaimType"); + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); - b.Property("ClaimValue"); + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); b.Property("RoleId") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(450)"); b.HasKey("Id"); b.HasIndex("RoleId"); - b.ToTable("AspNetRoleClaims"); + b.ToTable("AspNetRoleClaims", (string)null); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClaimType"); + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); - b.Property("ClaimValue"); + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); b.Property("UserId") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(450)"); b.HasKey("Id"); b.HasIndex("UserId"); - b.ToTable("AspNetUserClaims"); + b.ToTable("AspNetUserClaims", (string)null); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { - b.Property("LoginProvider"); + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); - b.Property("ProviderKey"); + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); - b.Property("ProviderDisplayName"); + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); b.Property("UserId") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(450)"); b.HasKey("LoginProvider", "ProviderKey"); b.HasIndex("UserId"); - b.ToTable("AspNetUserLogins"); + b.ToTable("AspNetUserLogins", (string)null); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => { - b.Property("UserId"); + b.Property("UserId") + .HasColumnType("nvarchar(450)"); - b.Property("RoleId"); + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); b.HasKey("UserId", "RoleId"); b.HasIndex("RoleId"); - b.ToTable("AspNetUserRoles"); + b.ToTable("AspNetUserRoles", (string)null); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => { - b.Property("UserId"); + b.Property("UserId") + .HasColumnType("nvarchar(450)"); - b.Property("LoginProvider"); + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); - b.Property("Name"); + b.Property("Name") + .HasColumnType("nvarchar(450)"); - b.Property("Value"); + b.Property("Value") + .HasColumnType("nvarchar(max)"); b.HasKey("UserId", "LoginProvider", "Name"); - b.ToTable("AspNetUserTokens"); + b.ToTable("AspNetUserTokens", (string)null); }); modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Identity.API.Models.ApplicationUser", b => { - b.Property("Id"); + b.Property("Id") + .HasColumnType("nvarchar(450)"); - b.Property("AccessFailedCount"); + b.Property("AccessFailedCount") + .HasColumnType("int"); b.Property("CardHolderName") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); b.Property("CardNumber") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("CardType"); + b.Property("CardType") + .HasColumnType("int"); b.Property("City") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); b.Property("ConcurrencyStamp") - .IsConcurrencyToken(); + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); b.Property("Country") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); b.Property("Email") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); - b.Property("EmailConfirmed"); + b.Property("EmailConfirmed") + .HasColumnType("bit"); b.Property("Expiration") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); b.Property("LastName") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("LockoutEnabled"); + b.Property("LockoutEnabled") + .HasColumnType("bit"); - b.Property("LockoutEnd"); + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); b.Property("Name") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); b.Property("NormalizedEmail") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); b.Property("NormalizedUserName") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); - b.Property("PasswordHash"); + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); - b.Property("PhoneNumber"); + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); - b.Property("PhoneNumberConfirmed"); + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); b.Property("SecurityNumber") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("SecurityStamp"); + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); b.Property("State") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); b.Property("Street") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("TwoFactorEnabled"); + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); b.Property("UserName") - .HasMaxLength(256); + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); b.Property("ZipCode") - .IsRequired(); + .IsRequired() + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); b.HasIndex("NormalizedEmail") - .HasName("EmailIndex"); + .HasDatabaseName("EmailIndex"); b.HasIndex("NormalizedUserName") .IsUnique() - .HasName("UserNameIndex") + .HasDatabaseName("UserNameIndex") .HasFilter("[NormalizedUserName] IS NOT NULL"); - b.ToTable("AspNetUsers"); + b.ToTable("AspNetUsers", (string)null); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => diff --git a/src/Services/Identity/Identity.API/Migrations/ConfigurationDb/20190729092011_InitialConfigurationMigration.Designer.cs b/src/Services/Identity/Identity.API/Migrations/ConfigurationDb/20210813072543_InitialMigration.Designer.cs similarity index 57% rename from src/Services/Identity/Identity.API/Migrations/ConfigurationDb/20190729092011_InitialConfigurationMigration.Designer.cs rename to src/Services/Identity/Identity.API/Migrations/ConfigurationDb/20210813072543_InitialMigration.Designer.cs index 5e801b306..4be46cc60 100644 --- a/src/Services/Identity/Identity.API/Migrations/ConfigurationDb/20190729092011_InitialConfigurationMigration.Designer.cs +++ b/src/Services/Identity/Identity.API/Migrations/ConfigurationDb/20210813072543_InitialMigration.Designer.cs @@ -10,116 +10,140 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Identity.API.Migrations.ConfigurationDb { [DbContext(typeof(ConfigurationDbContext))] - [Migration("20190729092011_InitialConfigurationMigration")] - partial class InitialConfigurationMigration + [Migration("20210813072543_InitialMigration")] + partial class InitialMigration { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "3.0.0-preview7.19362.6") .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("ProductVersion", "6.0.0-preview.7.21378.4") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResource", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("Created"); + b.Property("Created") + .HasColumnType("datetime2"); b.Property("Description") - .HasMaxLength(1000); + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); b.Property("DisplayName") - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); - b.Property("Enabled"); + b.Property("Enabled") + .HasColumnType("bit"); - b.Property("LastAccessed"); + b.Property("LastAccessed") + .HasColumnType("datetime2"); b.Property("Name") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); - b.Property("NonEditable"); + b.Property("NonEditable") + .HasColumnType("bit"); - b.Property("Updated"); + b.Property("Updated") + .HasColumnType("datetime2"); b.HasKey("Id"); b.HasIndex("Name") .IsUnique(); - b.ToTable("ApiResources"); + b.ToTable("ApiResources", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResourceClaim", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ApiResourceId"); + b.Property("ApiResourceId") + .HasColumnType("int"); b.Property("Type") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.HasKey("Id"); b.HasIndex("ApiResourceId"); - b.ToTable("ApiClaims"); + b.ToTable("ApiClaims", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResourceProperty", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ApiResourceId"); + b.Property("ApiResourceId") + .HasColumnType("int"); b.Property("Key") .IsRequired() - .HasMaxLength(250); + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); b.Property("Value") .IsRequired() - .HasMaxLength(2000); + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); b.HasKey("Id"); b.HasIndex("ApiResourceId"); - b.ToTable("ApiProperties"); + b.ToTable("ApiProperties", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiScope", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ApiResourceId"); + b.Property("ApiResourceId") + .HasColumnType("int"); b.Property("Description") - .HasMaxLength(1000); + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); b.Property("DisplayName") - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); - b.Property("Emphasize"); + b.Property("Emphasize") + .HasColumnType("bit"); b.Property("Name") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); - b.Property("Required"); + b.Property("Required") + .HasColumnType("bit"); - b.Property("ShowInDiscoveryDocument"); + b.Property("ShowInDiscoveryDocument") + .HasColumnType("bit"); b.HasKey("Id"); @@ -128,435 +152,538 @@ namespace Identity.API.Migrations.ConfigurationDb b.HasIndex("Name") .IsUnique(); - b.ToTable("ApiScopes"); + b.ToTable("ApiScopes", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiScopeClaim", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ApiScopeId"); + b.Property("ApiScopeId") + .HasColumnType("int"); b.Property("Type") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.HasKey("Id"); b.HasIndex("ApiScopeId"); - b.ToTable("ApiScopeClaims"); + b.ToTable("ApiScopeClaims", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiSecret", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ApiResourceId"); + b.Property("ApiResourceId") + .HasColumnType("int"); - b.Property("Created"); + b.Property("Created") + .HasColumnType("datetime2"); b.Property("Description") - .HasMaxLength(1000); + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); - b.Property("Expiration"); + b.Property("Expiration") + .HasColumnType("datetime2"); b.Property("Type") .IsRequired() - .HasMaxLength(250); + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); b.Property("Value") .IsRequired() - .HasMaxLength(4000); + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); b.HasKey("Id"); b.HasIndex("ApiResourceId"); - b.ToTable("ApiSecrets"); + b.ToTable("ApiSecrets", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.Client", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("AbsoluteRefreshTokenLifetime"); + b.Property("AbsoluteRefreshTokenLifetime") + .HasColumnType("int"); - b.Property("AccessTokenLifetime"); + b.Property("AccessTokenLifetime") + .HasColumnType("int"); - b.Property("AccessTokenType"); + b.Property("AccessTokenType") + .HasColumnType("int"); - b.Property("AllowAccessTokensViaBrowser"); + b.Property("AllowAccessTokensViaBrowser") + .HasColumnType("bit"); - b.Property("AllowOfflineAccess"); + b.Property("AllowOfflineAccess") + .HasColumnType("bit"); - b.Property("AllowPlainTextPkce"); + b.Property("AllowPlainTextPkce") + .HasColumnType("bit"); - b.Property("AllowRememberConsent"); + b.Property("AllowRememberConsent") + .HasColumnType("bit"); - b.Property("AlwaysIncludeUserClaimsInIdToken"); + b.Property("AlwaysIncludeUserClaimsInIdToken") + .HasColumnType("bit"); - b.Property("AlwaysSendClientClaims"); + b.Property("AlwaysSendClientClaims") + .HasColumnType("bit"); - b.Property("AuthorizationCodeLifetime"); + b.Property("AuthorizationCodeLifetime") + .HasColumnType("int"); - b.Property("BackChannelLogoutSessionRequired"); + b.Property("BackChannelLogoutSessionRequired") + .HasColumnType("bit"); b.Property("BackChannelLogoutUri") - .HasMaxLength(2000); + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); b.Property("ClientClaimsPrefix") - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.Property("ClientId") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.Property("ClientName") - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.Property("ClientUri") - .HasMaxLength(2000); + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); - b.Property("ConsentLifetime"); + b.Property("ConsentLifetime") + .HasColumnType("int"); - b.Property("Created"); + b.Property("Created") + .HasColumnType("datetime2"); b.Property("Description") - .HasMaxLength(1000); + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); - b.Property("DeviceCodeLifetime"); + b.Property("DeviceCodeLifetime") + .HasColumnType("int"); - b.Property("EnableLocalLogin"); + b.Property("EnableLocalLogin") + .HasColumnType("bit"); - b.Property("Enabled"); + b.Property("Enabled") + .HasColumnType("bit"); - b.Property("FrontChannelLogoutSessionRequired"); + b.Property("FrontChannelLogoutSessionRequired") + .HasColumnType("bit"); b.Property("FrontChannelLogoutUri") - .HasMaxLength(2000); + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); - b.Property("IdentityTokenLifetime"); + b.Property("IdentityTokenLifetime") + .HasColumnType("int"); - b.Property("IncludeJwtId"); + b.Property("IncludeJwtId") + .HasColumnType("bit"); - b.Property("LastAccessed"); + b.Property("LastAccessed") + .HasColumnType("datetime2"); b.Property("LogoUri") - .HasMaxLength(2000); + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); - b.Property("NonEditable"); + b.Property("NonEditable") + .HasColumnType("bit"); b.Property("PairWiseSubjectSalt") - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.Property("ProtocolType") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); - b.Property("RefreshTokenExpiration"); + b.Property("RefreshTokenExpiration") + .HasColumnType("int"); - b.Property("RefreshTokenUsage"); + b.Property("RefreshTokenUsage") + .HasColumnType("int"); - b.Property("RequireClientSecret"); + b.Property("RequireClientSecret") + .HasColumnType("bit"); - b.Property("RequireConsent"); + b.Property("RequireConsent") + .HasColumnType("bit"); - b.Property("RequirePkce"); + b.Property("RequirePkce") + .HasColumnType("bit"); - b.Property("SlidingRefreshTokenLifetime"); + b.Property("SlidingRefreshTokenLifetime") + .HasColumnType("int"); - b.Property("UpdateAccessTokenClaimsOnRefresh"); + b.Property("UpdateAccessTokenClaimsOnRefresh") + .HasColumnType("bit"); - b.Property("Updated"); + b.Property("Updated") + .HasColumnType("datetime2"); b.Property("UserCodeType") - .HasMaxLength(100); + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); - b.Property("UserSsoLifetime"); + b.Property("UserSsoLifetime") + .HasColumnType("int"); b.HasKey("Id"); b.HasIndex("ClientId") .IsUnique(); - b.ToTable("Clients"); + b.ToTable("Clients", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientClaim", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("int"); b.Property("Type") .IsRequired() - .HasMaxLength(250); + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); b.Property("Value") .IsRequired() - .HasMaxLength(250); + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); b.HasKey("Id"); b.HasIndex("ClientId"); - b.ToTable("ClientClaims"); + b.ToTable("ClientClaims", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientCorsOrigin", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("int"); b.Property("Origin") .IsRequired() - .HasMaxLength(150); + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); b.HasKey("Id"); b.HasIndex("ClientId"); - b.ToTable("ClientCorsOrigins"); + b.ToTable("ClientCorsOrigins", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientGrantType", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("int"); b.Property("GrantType") .IsRequired() - .HasMaxLength(250); + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); b.HasKey("Id"); b.HasIndex("ClientId"); - b.ToTable("ClientGrantTypes"); + b.ToTable("ClientGrantTypes", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientIdPRestriction", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("int"); b.Property("Provider") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.HasKey("Id"); b.HasIndex("ClientId"); - b.ToTable("ClientIdPRestrictions"); + b.ToTable("ClientIdPRestrictions", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientPostLogoutRedirectUri", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("int"); b.Property("PostLogoutRedirectUri") .IsRequired() - .HasMaxLength(2000); + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); b.HasKey("Id"); b.HasIndex("ClientId"); - b.ToTable("ClientPostLogoutRedirectUris"); + b.ToTable("ClientPostLogoutRedirectUris", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientProperty", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("int"); b.Property("Key") .IsRequired() - .HasMaxLength(250); + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); b.Property("Value") .IsRequired() - .HasMaxLength(2000); + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); b.HasKey("Id"); b.HasIndex("ClientId"); - b.ToTable("ClientProperties"); + b.ToTable("ClientProperties", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientRedirectUri", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("int"); b.Property("RedirectUri") .IsRequired() - .HasMaxLength(2000); + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); b.HasKey("Id"); b.HasIndex("ClientId"); - b.ToTable("ClientRedirectUris"); + b.ToTable("ClientRedirectUris", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientScope", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("int"); b.Property("Scope") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.HasKey("Id"); b.HasIndex("ClientId"); - b.ToTable("ClientScopes"); + b.ToTable("ClientScopes", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientSecret", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("int"); - b.Property("Created"); + b.Property("Created") + .HasColumnType("datetime2"); b.Property("Description") - .HasMaxLength(2000); + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); - b.Property("Expiration"); + b.Property("Expiration") + .HasColumnType("datetime2"); b.Property("Type") .IsRequired() - .HasMaxLength(250); + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); b.Property("Value") .IsRequired() - .HasMaxLength(4000); + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); b.HasKey("Id"); b.HasIndex("ClientId"); - b.ToTable("ClientSecrets"); + b.ToTable("ClientSecrets", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityClaim", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("IdentityResourceId"); + b.Property("IdentityResourceId") + .HasColumnType("int"); b.Property("Type") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.HasKey("Id"); b.HasIndex("IdentityResourceId"); - b.ToTable("IdentityClaims"); + b.ToTable("IdentityClaims", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityResource", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("Created"); + b.Property("Created") + .HasColumnType("datetime2"); b.Property("Description") - .HasMaxLength(1000); + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); b.Property("DisplayName") - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); - b.Property("Emphasize"); + b.Property("Emphasize") + .HasColumnType("bit"); - b.Property("Enabled"); + b.Property("Enabled") + .HasColumnType("bit"); b.Property("Name") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); - b.Property("NonEditable"); + b.Property("NonEditable") + .HasColumnType("bit"); - b.Property("Required"); + b.Property("Required") + .HasColumnType("bit"); - b.Property("ShowInDiscoveryDocument"); + b.Property("ShowInDiscoveryDocument") + .HasColumnType("bit"); - b.Property("Updated"); + b.Property("Updated") + .HasColumnType("datetime2"); b.HasKey("Id"); b.HasIndex("Name") .IsUnique(); - b.ToTable("IdentityResources"); + b.ToTable("IdentityResources", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityResourceProperty", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("IdentityResourceId"); + b.Property("IdentityResourceId") + .HasColumnType("int"); b.Property("Key") .IsRequired() - .HasMaxLength(250); + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); b.Property("Value") .IsRequired() - .HasMaxLength(2000); + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); b.HasKey("Id"); b.HasIndex("IdentityResourceId"); - b.ToTable("IdentityProperties"); + b.ToTable("IdentityProperties", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResourceClaim", b => @@ -566,6 +693,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ApiResourceId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("ApiResource"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResourceProperty", b => @@ -575,6 +704,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ApiResourceId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("ApiResource"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiScope", b => @@ -584,6 +715,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ApiResourceId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("ApiResource"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiScopeClaim", b => @@ -593,6 +726,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ApiScopeId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("ApiScope"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiSecret", b => @@ -602,6 +737,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ApiResourceId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("ApiResource"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientClaim", b => @@ -611,6 +748,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ClientId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Client"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientCorsOrigin", b => @@ -620,6 +759,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ClientId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Client"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientGrantType", b => @@ -629,6 +770,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ClientId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Client"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientIdPRestriction", b => @@ -638,6 +781,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ClientId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Client"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientPostLogoutRedirectUri", b => @@ -647,6 +792,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ClientId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Client"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientProperty", b => @@ -656,6 +803,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ClientId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Client"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientRedirectUri", b => @@ -665,6 +814,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ClientId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Client"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientScope", b => @@ -674,6 +825,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ClientId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Client"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientSecret", b => @@ -683,6 +836,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ClientId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Client"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityClaim", b => @@ -692,6 +847,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("IdentityResourceId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("IdentityResource"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityResourceProperty", b => @@ -701,6 +858,52 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("IdentityResourceId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("IdentityResource"); + }); + + modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResource", b => + { + b.Navigation("Properties"); + + b.Navigation("Scopes"); + + b.Navigation("Secrets"); + + b.Navigation("UserClaims"); + }); + + modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiScope", b => + { + b.Navigation("UserClaims"); + }); + + modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.Client", b => + { + b.Navigation("AllowedCorsOrigins"); + + b.Navigation("AllowedGrantTypes"); + + b.Navigation("AllowedScopes"); + + b.Navigation("Claims"); + + b.Navigation("ClientSecrets"); + + b.Navigation("IdentityProviderRestrictions"); + + b.Navigation("PostLogoutRedirectUris"); + + b.Navigation("Properties"); + + b.Navigation("RedirectUris"); + }); + + modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityResource", b => + { + b.Navigation("Properties"); + + b.Navigation("UserClaims"); }); #pragma warning restore 612, 618 } diff --git a/src/Services/Identity/Identity.API/Migrations/ConfigurationDb/20190729092011_InitialConfigurationMigration.cs b/src/Services/Identity/Identity.API/Migrations/ConfigurationDb/20210813072543_InitialMigration.cs similarity index 59% rename from src/Services/Identity/Identity.API/Migrations/ConfigurationDb/20190729092011_InitialConfigurationMigration.cs rename to src/Services/Identity/Identity.API/Migrations/ConfigurationDb/20210813072543_InitialMigration.cs index 8eb69adad..57f508711 100644 --- a/src/Services/Identity/Identity.API/Migrations/ConfigurationDb/20190729092011_InitialConfigurationMigration.cs +++ b/src/Services/Identity/Identity.API/Migrations/ConfigurationDb/20210813072543_InitialMigration.cs @@ -1,10 +1,9 @@ -using Microsoft.EntityFrameworkCore.Metadata; +using System; using Microsoft.EntityFrameworkCore.Migrations; -using System; namespace Identity.API.Migrations.ConfigurationDb { - public partial class InitialConfigurationMigration : Migration + public partial class InitialMigration : Migration { protected override void Up(MigrationBuilder migrationBuilder) { @@ -12,16 +11,16 @@ namespace Identity.API.Migrations.ConfigurationDb name: "ApiResources", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - Enabled = table.Column(nullable: false), - Name = table.Column(maxLength: 200, nullable: false), - DisplayName = table.Column(maxLength: 200, nullable: true), - Description = table.Column(maxLength: 1000, nullable: true), - Created = table.Column(nullable: false), - Updated = table.Column(nullable: true), - LastAccessed = table.Column(nullable: true), - NonEditable = table.Column(nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Enabled = table.Column(type: "bit", nullable: false), + Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + DisplayName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + Created = table.Column(type: "datetime2", nullable: false), + Updated = table.Column(type: "datetime2", nullable: true), + LastAccessed = table.Column(type: "datetime2", nullable: true), + NonEditable = table.Column(type: "bit", nullable: false) }, constraints: table => { @@ -32,49 +31,49 @@ namespace Identity.API.Migrations.ConfigurationDb name: "Clients", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - Enabled = table.Column(nullable: false), - ClientId = table.Column(maxLength: 200, nullable: false), - ProtocolType = table.Column(maxLength: 200, nullable: false), - RequireClientSecret = table.Column(nullable: false), - ClientName = table.Column(maxLength: 200, nullable: true), - Description = table.Column(maxLength: 1000, nullable: true), - ClientUri = table.Column(maxLength: 2000, nullable: true), - LogoUri = table.Column(maxLength: 2000, nullable: true), - RequireConsent = table.Column(nullable: false), - AllowRememberConsent = table.Column(nullable: false), - AlwaysIncludeUserClaimsInIdToken = table.Column(nullable: false), - RequirePkce = table.Column(nullable: false), - AllowPlainTextPkce = table.Column(nullable: false), - AllowAccessTokensViaBrowser = table.Column(nullable: false), - FrontChannelLogoutUri = table.Column(maxLength: 2000, nullable: true), - FrontChannelLogoutSessionRequired = table.Column(nullable: false), - BackChannelLogoutUri = table.Column(maxLength: 2000, nullable: true), - BackChannelLogoutSessionRequired = table.Column(nullable: false), - AllowOfflineAccess = table.Column(nullable: false), - IdentityTokenLifetime = table.Column(nullable: false), - AccessTokenLifetime = table.Column(nullable: false), - AuthorizationCodeLifetime = table.Column(nullable: false), - ConsentLifetime = table.Column(nullable: true), - AbsoluteRefreshTokenLifetime = table.Column(nullable: false), - SlidingRefreshTokenLifetime = table.Column(nullable: false), - RefreshTokenUsage = table.Column(nullable: false), - UpdateAccessTokenClaimsOnRefresh = table.Column(nullable: false), - RefreshTokenExpiration = table.Column(nullable: false), - AccessTokenType = table.Column(nullable: false), - EnableLocalLogin = table.Column(nullable: false), - IncludeJwtId = table.Column(nullable: false), - AlwaysSendClientClaims = table.Column(nullable: false), - ClientClaimsPrefix = table.Column(maxLength: 200, nullable: true), - PairWiseSubjectSalt = table.Column(maxLength: 200, nullable: true), - Created = table.Column(nullable: false), - Updated = table.Column(nullable: true), - LastAccessed = table.Column(nullable: true), - UserSsoLifetime = table.Column(nullable: true), - UserCodeType = table.Column(maxLength: 100, nullable: true), - DeviceCodeLifetime = table.Column(nullable: false), - NonEditable = table.Column(nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Enabled = table.Column(type: "bit", nullable: false), + ClientId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + ProtocolType = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + RequireClientSecret = table.Column(type: "bit", nullable: false), + ClientName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + ClientUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + LogoUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + RequireConsent = table.Column(type: "bit", nullable: false), + AllowRememberConsent = table.Column(type: "bit", nullable: false), + AlwaysIncludeUserClaimsInIdToken = table.Column(type: "bit", nullable: false), + RequirePkce = table.Column(type: "bit", nullable: false), + AllowPlainTextPkce = table.Column(type: "bit", nullable: false), + AllowAccessTokensViaBrowser = table.Column(type: "bit", nullable: false), + FrontChannelLogoutUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + FrontChannelLogoutSessionRequired = table.Column(type: "bit", nullable: false), + BackChannelLogoutUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + BackChannelLogoutSessionRequired = table.Column(type: "bit", nullable: false), + AllowOfflineAccess = table.Column(type: "bit", nullable: false), + IdentityTokenLifetime = table.Column(type: "int", nullable: false), + AccessTokenLifetime = table.Column(type: "int", nullable: false), + AuthorizationCodeLifetime = table.Column(type: "int", nullable: false), + ConsentLifetime = table.Column(type: "int", nullable: true), + AbsoluteRefreshTokenLifetime = table.Column(type: "int", nullable: false), + SlidingRefreshTokenLifetime = table.Column(type: "int", nullable: false), + RefreshTokenUsage = table.Column(type: "int", nullable: false), + UpdateAccessTokenClaimsOnRefresh = table.Column(type: "bit", nullable: false), + RefreshTokenExpiration = table.Column(type: "int", nullable: false), + AccessTokenType = table.Column(type: "int", nullable: false), + EnableLocalLogin = table.Column(type: "bit", nullable: false), + IncludeJwtId = table.Column(type: "bit", nullable: false), + AlwaysSendClientClaims = table.Column(type: "bit", nullable: false), + ClientClaimsPrefix = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + PairWiseSubjectSalt = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Created = table.Column(type: "datetime2", nullable: false), + Updated = table.Column(type: "datetime2", nullable: true), + LastAccessed = table.Column(type: "datetime2", nullable: true), + UserSsoLifetime = table.Column(type: "int", nullable: true), + UserCodeType = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + DeviceCodeLifetime = table.Column(type: "int", nullable: false), + NonEditable = table.Column(type: "bit", nullable: false) }, constraints: table => { @@ -85,18 +84,18 @@ namespace Identity.API.Migrations.ConfigurationDb name: "IdentityResources", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - Enabled = table.Column(nullable: false), - Name = table.Column(maxLength: 200, nullable: false), - DisplayName = table.Column(maxLength: 200, nullable: true), - Description = table.Column(maxLength: 1000, nullable: true), - Required = table.Column(nullable: false), - Emphasize = table.Column(nullable: false), - ShowInDiscoveryDocument = table.Column(nullable: false), - Created = table.Column(nullable: false), - Updated = table.Column(nullable: true), - NonEditable = table.Column(nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Enabled = table.Column(type: "bit", nullable: false), + Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + DisplayName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + Required = table.Column(type: "bit", nullable: false), + Emphasize = table.Column(type: "bit", nullable: false), + ShowInDiscoveryDocument = table.Column(type: "bit", nullable: false), + Created = table.Column(type: "datetime2", nullable: false), + Updated = table.Column(type: "datetime2", nullable: true), + NonEditable = table.Column(type: "bit", nullable: false) }, constraints: table => { @@ -107,10 +106,10 @@ namespace Identity.API.Migrations.ConfigurationDb name: "ApiClaims", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - Type = table.Column(maxLength: 200, nullable: false), - ApiResourceId = table.Column(nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ApiResourceId = table.Column(type: "int", nullable: false), + Type = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) }, constraints: table => { @@ -127,11 +126,11 @@ namespace Identity.API.Migrations.ConfigurationDb name: "ApiProperties", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - Key = table.Column(maxLength: 250, nullable: false), - Value = table.Column(maxLength: 2000, nullable: false), - ApiResourceId = table.Column(nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ApiResourceId = table.Column(type: "int", nullable: false), + Key = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) }, constraints: table => { @@ -148,15 +147,15 @@ namespace Identity.API.Migrations.ConfigurationDb name: "ApiScopes", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - Name = table.Column(maxLength: 200, nullable: false), - DisplayName = table.Column(maxLength: 200, nullable: true), - Description = table.Column(maxLength: 1000, nullable: true), - Required = table.Column(nullable: false), - Emphasize = table.Column(nullable: false), - ShowInDiscoveryDocument = table.Column(nullable: false), - ApiResourceId = table.Column(nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + DisplayName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + Required = table.Column(type: "bit", nullable: false), + Emphasize = table.Column(type: "bit", nullable: false), + ShowInDiscoveryDocument = table.Column(type: "bit", nullable: false), + ApiResourceId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -173,14 +172,14 @@ namespace Identity.API.Migrations.ConfigurationDb name: "ApiSecrets", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - Description = table.Column(maxLength: 1000, nullable: true), - Value = table.Column(maxLength: 4000, nullable: false), - Expiration = table.Column(nullable: true), - Type = table.Column(maxLength: 250, nullable: false), - Created = table.Column(nullable: false), - ApiResourceId = table.Column(nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ApiResourceId = table.Column(type: "int", nullable: false), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + Value = table.Column(type: "nvarchar(4000)", maxLength: 4000, nullable: false), + Expiration = table.Column(type: "datetime2", nullable: true), + Type = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Created = table.Column(type: "datetime2", nullable: false) }, constraints: table => { @@ -197,11 +196,11 @@ namespace Identity.API.Migrations.ConfigurationDb name: "ClientClaims", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - Type = table.Column(maxLength: 250, nullable: false), - Value = table.Column(maxLength: 250, nullable: false), - ClientId = table.Column(nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Type = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Value = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + ClientId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -218,10 +217,10 @@ namespace Identity.API.Migrations.ConfigurationDb name: "ClientCorsOrigins", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - Origin = table.Column(maxLength: 150, nullable: false), - ClientId = table.Column(nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Origin = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: false), + ClientId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -238,10 +237,10 @@ namespace Identity.API.Migrations.ConfigurationDb name: "ClientGrantTypes", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - GrantType = table.Column(maxLength: 250, nullable: false), - ClientId = table.Column(nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + GrantType = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + ClientId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -258,10 +257,10 @@ namespace Identity.API.Migrations.ConfigurationDb name: "ClientIdPRestrictions", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - Provider = table.Column(maxLength: 200, nullable: false), - ClientId = table.Column(nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Provider = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + ClientId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -278,10 +277,10 @@ namespace Identity.API.Migrations.ConfigurationDb name: "ClientPostLogoutRedirectUris", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - PostLogoutRedirectUri = table.Column(maxLength: 2000, nullable: false), - ClientId = table.Column(nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + PostLogoutRedirectUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false), + ClientId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -298,11 +297,11 @@ namespace Identity.API.Migrations.ConfigurationDb name: "ClientProperties", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - Key = table.Column(maxLength: 250, nullable: false), - Value = table.Column(maxLength: 2000, nullable: false), - ClientId = table.Column(nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ClientId = table.Column(type: "int", nullable: false), + Key = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) }, constraints: table => { @@ -319,10 +318,10 @@ namespace Identity.API.Migrations.ConfigurationDb name: "ClientRedirectUris", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - RedirectUri = table.Column(maxLength: 2000, nullable: false), - ClientId = table.Column(nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + RedirectUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false), + ClientId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -339,10 +338,10 @@ namespace Identity.API.Migrations.ConfigurationDb name: "ClientScopes", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - Scope = table.Column(maxLength: 200, nullable: false), - ClientId = table.Column(nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Scope = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + ClientId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -359,14 +358,14 @@ namespace Identity.API.Migrations.ConfigurationDb name: "ClientSecrets", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - Description = table.Column(maxLength: 2000, nullable: true), - Value = table.Column(maxLength: 4000, nullable: false), - Expiration = table.Column(nullable: true), - Type = table.Column(maxLength: 250, nullable: false), - Created = table.Column(nullable: false), - ClientId = table.Column(nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ClientId = table.Column(type: "int", nullable: false), + Description = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + Value = table.Column(type: "nvarchar(4000)", maxLength: 4000, nullable: false), + Expiration = table.Column(type: "datetime2", nullable: true), + Type = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Created = table.Column(type: "datetime2", nullable: false) }, constraints: table => { @@ -383,10 +382,10 @@ namespace Identity.API.Migrations.ConfigurationDb name: "IdentityClaims", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - Type = table.Column(maxLength: 200, nullable: false), - IdentityResourceId = table.Column(nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + IdentityResourceId = table.Column(type: "int", nullable: false), + Type = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) }, constraints: table => { @@ -403,11 +402,11 @@ namespace Identity.API.Migrations.ConfigurationDb name: "IdentityProperties", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - Key = table.Column(maxLength: 250, nullable: false), - Value = table.Column(maxLength: 2000, nullable: false), - IdentityResourceId = table.Column(nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + IdentityResourceId = table.Column(type: "int", nullable: false), + Key = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) }, constraints: table => { @@ -424,10 +423,10 @@ namespace Identity.API.Migrations.ConfigurationDb name: "ApiScopeClaims", columns: table => new { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - Type = table.Column(maxLength: 200, nullable: false), - ApiScopeId = table.Column(nullable: false) + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ApiScopeId = table.Column(type: "int", nullable: false), + Type = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) }, constraints: table => { diff --git a/src/Services/Identity/Identity.API/Migrations/ConfigurationDb/ConfigurationDbContextModelSnapshot.cs b/src/Services/Identity/Identity.API/Migrations/ConfigurationDb/ConfigurationDbContextModelSnapshot.cs index ec91a8841..077a8df9f 100644 --- a/src/Services/Identity/Identity.API/Migrations/ConfigurationDb/ConfigurationDbContextModelSnapshot.cs +++ b/src/Services/Identity/Identity.API/Migrations/ConfigurationDb/ConfigurationDbContextModelSnapshot.cs @@ -15,109 +15,133 @@ namespace Identity.API.Migrations.ConfigurationDb { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "3.0.0-preview7.19362.6") .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("ProductVersion", "6.0.0-preview.7.21378.4") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResource", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("Created"); + b.Property("Created") + .HasColumnType("datetime2"); b.Property("Description") - .HasMaxLength(1000); + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); b.Property("DisplayName") - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); - b.Property("Enabled"); + b.Property("Enabled") + .HasColumnType("bit"); - b.Property("LastAccessed"); + b.Property("LastAccessed") + .HasColumnType("datetime2"); b.Property("Name") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); - b.Property("NonEditable"); + b.Property("NonEditable") + .HasColumnType("bit"); - b.Property("Updated"); + b.Property("Updated") + .HasColumnType("datetime2"); b.HasKey("Id"); b.HasIndex("Name") .IsUnique(); - b.ToTable("ApiResources"); + b.ToTable("ApiResources", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResourceClaim", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ApiResourceId"); + b.Property("ApiResourceId") + .HasColumnType("int"); b.Property("Type") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.HasKey("Id"); b.HasIndex("ApiResourceId"); - b.ToTable("ApiClaims"); + b.ToTable("ApiClaims", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResourceProperty", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ApiResourceId"); + b.Property("ApiResourceId") + .HasColumnType("int"); b.Property("Key") .IsRequired() - .HasMaxLength(250); + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); b.Property("Value") .IsRequired() - .HasMaxLength(2000); + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); b.HasKey("Id"); b.HasIndex("ApiResourceId"); - b.ToTable("ApiProperties"); + b.ToTable("ApiProperties", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiScope", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ApiResourceId"); + b.Property("ApiResourceId") + .HasColumnType("int"); b.Property("Description") - .HasMaxLength(1000); + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); b.Property("DisplayName") - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); - b.Property("Emphasize"); + b.Property("Emphasize") + .HasColumnType("bit"); b.Property("Name") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); - b.Property("Required"); + b.Property("Required") + .HasColumnType("bit"); - b.Property("ShowInDiscoveryDocument"); + b.Property("ShowInDiscoveryDocument") + .HasColumnType("bit"); b.HasKey("Id"); @@ -126,435 +150,538 @@ namespace Identity.API.Migrations.ConfigurationDb b.HasIndex("Name") .IsUnique(); - b.ToTable("ApiScopes"); + b.ToTable("ApiScopes", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiScopeClaim", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ApiScopeId"); + b.Property("ApiScopeId") + .HasColumnType("int"); b.Property("Type") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.HasKey("Id"); b.HasIndex("ApiScopeId"); - b.ToTable("ApiScopeClaims"); + b.ToTable("ApiScopeClaims", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiSecret", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ApiResourceId"); + b.Property("ApiResourceId") + .HasColumnType("int"); - b.Property("Created"); + b.Property("Created") + .HasColumnType("datetime2"); b.Property("Description") - .HasMaxLength(1000); + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); - b.Property("Expiration"); + b.Property("Expiration") + .HasColumnType("datetime2"); b.Property("Type") .IsRequired() - .HasMaxLength(250); + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); b.Property("Value") .IsRequired() - .HasMaxLength(4000); + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); b.HasKey("Id"); b.HasIndex("ApiResourceId"); - b.ToTable("ApiSecrets"); + b.ToTable("ApiSecrets", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.Client", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("AbsoluteRefreshTokenLifetime"); + b.Property("AbsoluteRefreshTokenLifetime") + .HasColumnType("int"); - b.Property("AccessTokenLifetime"); + b.Property("AccessTokenLifetime") + .HasColumnType("int"); - b.Property("AccessTokenType"); + b.Property("AccessTokenType") + .HasColumnType("int"); - b.Property("AllowAccessTokensViaBrowser"); + b.Property("AllowAccessTokensViaBrowser") + .HasColumnType("bit"); - b.Property("AllowOfflineAccess"); + b.Property("AllowOfflineAccess") + .HasColumnType("bit"); - b.Property("AllowPlainTextPkce"); + b.Property("AllowPlainTextPkce") + .HasColumnType("bit"); - b.Property("AllowRememberConsent"); + b.Property("AllowRememberConsent") + .HasColumnType("bit"); - b.Property("AlwaysIncludeUserClaimsInIdToken"); + b.Property("AlwaysIncludeUserClaimsInIdToken") + .HasColumnType("bit"); - b.Property("AlwaysSendClientClaims"); + b.Property("AlwaysSendClientClaims") + .HasColumnType("bit"); - b.Property("AuthorizationCodeLifetime"); + b.Property("AuthorizationCodeLifetime") + .HasColumnType("int"); - b.Property("BackChannelLogoutSessionRequired"); + b.Property("BackChannelLogoutSessionRequired") + .HasColumnType("bit"); b.Property("BackChannelLogoutUri") - .HasMaxLength(2000); + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); b.Property("ClientClaimsPrefix") - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.Property("ClientId") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.Property("ClientName") - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.Property("ClientUri") - .HasMaxLength(2000); + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); - b.Property("ConsentLifetime"); + b.Property("ConsentLifetime") + .HasColumnType("int"); - b.Property("Created"); + b.Property("Created") + .HasColumnType("datetime2"); b.Property("Description") - .HasMaxLength(1000); + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); - b.Property("DeviceCodeLifetime"); + b.Property("DeviceCodeLifetime") + .HasColumnType("int"); - b.Property("EnableLocalLogin"); + b.Property("EnableLocalLogin") + .HasColumnType("bit"); - b.Property("Enabled"); + b.Property("Enabled") + .HasColumnType("bit"); - b.Property("FrontChannelLogoutSessionRequired"); + b.Property("FrontChannelLogoutSessionRequired") + .HasColumnType("bit"); b.Property("FrontChannelLogoutUri") - .HasMaxLength(2000); + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); - b.Property("IdentityTokenLifetime"); + b.Property("IdentityTokenLifetime") + .HasColumnType("int"); - b.Property("IncludeJwtId"); + b.Property("IncludeJwtId") + .HasColumnType("bit"); - b.Property("LastAccessed"); + b.Property("LastAccessed") + .HasColumnType("datetime2"); b.Property("LogoUri") - .HasMaxLength(2000); + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); - b.Property("NonEditable"); + b.Property("NonEditable") + .HasColumnType("bit"); b.Property("PairWiseSubjectSalt") - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.Property("ProtocolType") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); - b.Property("RefreshTokenExpiration"); + b.Property("RefreshTokenExpiration") + .HasColumnType("int"); - b.Property("RefreshTokenUsage"); + b.Property("RefreshTokenUsage") + .HasColumnType("int"); - b.Property("RequireClientSecret"); + b.Property("RequireClientSecret") + .HasColumnType("bit"); - b.Property("RequireConsent"); + b.Property("RequireConsent") + .HasColumnType("bit"); - b.Property("RequirePkce"); + b.Property("RequirePkce") + .HasColumnType("bit"); - b.Property("SlidingRefreshTokenLifetime"); + b.Property("SlidingRefreshTokenLifetime") + .HasColumnType("int"); - b.Property("UpdateAccessTokenClaimsOnRefresh"); + b.Property("UpdateAccessTokenClaimsOnRefresh") + .HasColumnType("bit"); - b.Property("Updated"); + b.Property("Updated") + .HasColumnType("datetime2"); b.Property("UserCodeType") - .HasMaxLength(100); + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); - b.Property("UserSsoLifetime"); + b.Property("UserSsoLifetime") + .HasColumnType("int"); b.HasKey("Id"); b.HasIndex("ClientId") .IsUnique(); - b.ToTable("Clients"); + b.ToTable("Clients", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientClaim", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("int"); b.Property("Type") .IsRequired() - .HasMaxLength(250); + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); b.Property("Value") .IsRequired() - .HasMaxLength(250); + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); b.HasKey("Id"); b.HasIndex("ClientId"); - b.ToTable("ClientClaims"); + b.ToTable("ClientClaims", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientCorsOrigin", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("int"); b.Property("Origin") .IsRequired() - .HasMaxLength(150); + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); b.HasKey("Id"); b.HasIndex("ClientId"); - b.ToTable("ClientCorsOrigins"); + b.ToTable("ClientCorsOrigins", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientGrantType", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("int"); b.Property("GrantType") .IsRequired() - .HasMaxLength(250); + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); b.HasKey("Id"); b.HasIndex("ClientId"); - b.ToTable("ClientGrantTypes"); + b.ToTable("ClientGrantTypes", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientIdPRestriction", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("int"); b.Property("Provider") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.HasKey("Id"); b.HasIndex("ClientId"); - b.ToTable("ClientIdPRestrictions"); + b.ToTable("ClientIdPRestrictions", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientPostLogoutRedirectUri", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("int"); b.Property("PostLogoutRedirectUri") .IsRequired() - .HasMaxLength(2000); + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); b.HasKey("Id"); b.HasIndex("ClientId"); - b.ToTable("ClientPostLogoutRedirectUris"); + b.ToTable("ClientPostLogoutRedirectUris", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientProperty", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("int"); b.Property("Key") .IsRequired() - .HasMaxLength(250); + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); b.Property("Value") .IsRequired() - .HasMaxLength(2000); + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); b.HasKey("Id"); b.HasIndex("ClientId"); - b.ToTable("ClientProperties"); + b.ToTable("ClientProperties", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientRedirectUri", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("int"); b.Property("RedirectUri") .IsRequired() - .HasMaxLength(2000); + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); b.HasKey("Id"); b.HasIndex("ClientId"); - b.ToTable("ClientRedirectUris"); + b.ToTable("ClientRedirectUris", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientScope", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("int"); b.Property("Scope") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.HasKey("Id"); b.HasIndex("ClientId"); - b.ToTable("ClientScopes"); + b.ToTable("ClientScopes", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientSecret", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("int"); - b.Property("Created"); + b.Property("Created") + .HasColumnType("datetime2"); b.Property("Description") - .HasMaxLength(2000); + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); - b.Property("Expiration"); + b.Property("Expiration") + .HasColumnType("datetime2"); b.Property("Type") .IsRequired() - .HasMaxLength(250); + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); b.Property("Value") .IsRequired() - .HasMaxLength(4000); + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); b.HasKey("Id"); b.HasIndex("ClientId"); - b.ToTable("ClientSecrets"); + b.ToTable("ClientSecrets", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityClaim", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("IdentityResourceId"); + b.Property("IdentityResourceId") + .HasColumnType("int"); b.Property("Type") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.HasKey("Id"); b.HasIndex("IdentityResourceId"); - b.ToTable("IdentityClaims"); + b.ToTable("IdentityClaims", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityResource", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("Created"); + b.Property("Created") + .HasColumnType("datetime2"); b.Property("Description") - .HasMaxLength(1000); + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); b.Property("DisplayName") - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); - b.Property("Emphasize"); + b.Property("Emphasize") + .HasColumnType("bit"); - b.Property("Enabled"); + b.Property("Enabled") + .HasColumnType("bit"); b.Property("Name") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); - b.Property("NonEditable"); + b.Property("NonEditable") + .HasColumnType("bit"); - b.Property("Required"); + b.Property("Required") + .HasColumnType("bit"); - b.Property("ShowInDiscoveryDocument"); + b.Property("ShowInDiscoveryDocument") + .HasColumnType("bit"); - b.Property("Updated"); + b.Property("Updated") + .HasColumnType("datetime2"); b.HasKey("Id"); b.HasIndex("Name") .IsUnique(); - b.ToTable("IdentityResources"); + b.ToTable("IdentityResources", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityResourceProperty", b => { b.Property("Id") .ValueGeneratedOnAdd() + .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("IdentityResourceId"); + b.Property("IdentityResourceId") + .HasColumnType("int"); b.Property("Key") .IsRequired() - .HasMaxLength(250); + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); b.Property("Value") .IsRequired() - .HasMaxLength(2000); + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); b.HasKey("Id"); b.HasIndex("IdentityResourceId"); - b.ToTable("IdentityProperties"); + b.ToTable("IdentityProperties", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResourceClaim", b => @@ -564,6 +691,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ApiResourceId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("ApiResource"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResourceProperty", b => @@ -573,6 +702,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ApiResourceId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("ApiResource"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiScope", b => @@ -582,6 +713,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ApiResourceId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("ApiResource"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiScopeClaim", b => @@ -591,6 +724,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ApiScopeId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("ApiScope"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiSecret", b => @@ -600,6 +735,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ApiResourceId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("ApiResource"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientClaim", b => @@ -609,6 +746,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ClientId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Client"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientCorsOrigin", b => @@ -618,6 +757,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ClientId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Client"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientGrantType", b => @@ -627,6 +768,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ClientId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Client"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientIdPRestriction", b => @@ -636,6 +779,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ClientId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Client"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientPostLogoutRedirectUri", b => @@ -645,6 +790,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ClientId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Client"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientProperty", b => @@ -654,6 +801,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ClientId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Client"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientRedirectUri", b => @@ -663,6 +812,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ClientId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Client"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientScope", b => @@ -672,6 +823,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ClientId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Client"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ClientSecret", b => @@ -681,6 +834,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("ClientId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("Client"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityClaim", b => @@ -690,6 +845,8 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("IdentityResourceId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("IdentityResource"); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityResourceProperty", b => @@ -699,6 +856,52 @@ namespace Identity.API.Migrations.ConfigurationDb .HasForeignKey("IdentityResourceId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.Navigation("IdentityResource"); + }); + + modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiResource", b => + { + b.Navigation("Properties"); + + b.Navigation("Scopes"); + + b.Navigation("Secrets"); + + b.Navigation("UserClaims"); + }); + + modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.ApiScope", b => + { + b.Navigation("UserClaims"); + }); + + modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.Client", b => + { + b.Navigation("AllowedCorsOrigins"); + + b.Navigation("AllowedGrantTypes"); + + b.Navigation("AllowedScopes"); + + b.Navigation("Claims"); + + b.Navigation("ClientSecrets"); + + b.Navigation("IdentityProviderRestrictions"); + + b.Navigation("PostLogoutRedirectUris"); + + b.Navigation("Properties"); + + b.Navigation("RedirectUris"); + }); + + modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.IdentityResource", b => + { + b.Navigation("Properties"); + + b.Navigation("UserClaims"); }); #pragma warning restore 612, 618 } diff --git a/src/Services/Identity/Identity.API/Migrations/PersistedGrantDb/20190729092100_InitialPersistedGrantMigration.cs b/src/Services/Identity/Identity.API/Migrations/PersistedGrantDb/20190729092100_InitialPersistedGrantMigration.cs deleted file mode 100644 index ac19250a6..000000000 --- a/src/Services/Identity/Identity.API/Migrations/PersistedGrantDb/20190729092100_InitialPersistedGrantMigration.cs +++ /dev/null @@ -1,65 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; -using System; - -namespace Identity.API.Migrations.PersistedGrantDb -{ - public partial class InitialPersistedGrantMigration : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "DeviceCodes", - columns: table => new - { - UserCode = table.Column(maxLength: 200, nullable: false), - DeviceCode = table.Column(maxLength: 200, nullable: false), - SubjectId = table.Column(maxLength: 200, nullable: true), - ClientId = table.Column(maxLength: 200, nullable: false), - CreationTime = table.Column(nullable: false), - Expiration = table.Column(nullable: false), - Data = table.Column(maxLength: 50000, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_DeviceCodes", x => x.UserCode); - }); - - migrationBuilder.CreateTable( - name: "PersistedGrants", - columns: table => new - { - Key = table.Column(maxLength: 200, nullable: false), - Type = table.Column(maxLength: 50, nullable: false), - SubjectId = table.Column(maxLength: 200, nullable: true), - ClientId = table.Column(maxLength: 200, nullable: false), - CreationTime = table.Column(nullable: false), - Expiration = table.Column(nullable: true), - Data = table.Column(maxLength: 50000, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_PersistedGrants", x => x.Key); - }); - - migrationBuilder.CreateIndex( - name: "IX_DeviceCodes_DeviceCode", - table: "DeviceCodes", - column: "DeviceCode", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_PersistedGrants_SubjectId_ClientId_Type", - table: "PersistedGrants", - columns: new[] { "SubjectId", "ClientId", "Type" }); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "DeviceCodes"); - - migrationBuilder.DropTable( - name: "PersistedGrants"); - } - } -} diff --git a/src/Services/Identity/Identity.API/Migrations/PersistedGrantDb/20190729092100_InitialPersistedGrantMigration.Designer.cs b/src/Services/Identity/Identity.API/Migrations/PersistedGrantDb/20210813072513_InitialMigration.Designer.cs similarity index 54% rename from src/Services/Identity/Identity.API/Migrations/PersistedGrantDb/20190729092100_InitialPersistedGrantMigration.Designer.cs rename to src/Services/Identity/Identity.API/Migrations/PersistedGrantDb/20210813072513_InitialMigration.Designer.cs index 0518894dc..a8563a9be 100644 --- a/src/Services/Identity/Identity.API/Migrations/PersistedGrantDb/20190729092100_InitialPersistedGrantMigration.Designer.cs +++ b/src/Services/Identity/Identity.API/Migrations/PersistedGrantDb/20210813072513_InitialMigration.Designer.cs @@ -10,79 +10,97 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Identity.API.Migrations.PersistedGrantDb { [DbContext(typeof(PersistedGrantDbContext))] - [Migration("20190729092100_InitialPersistedGrantMigration")] - partial class InitialPersistedGrantMigration + [Migration("20210813072513_InitialMigration")] + partial class InitialMigration { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "3.0.0-preview7.19362.6") .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("ProductVersion", "6.0.0-preview.7.21378.4") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.DeviceFlowCodes", b => { b.Property("UserCode") - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.Property("ClientId") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); - b.Property("CreationTime"); + b.Property("CreationTime") + .HasColumnType("datetime2"); b.Property("Data") .IsRequired() - .HasMaxLength(50000); + .HasMaxLength(50000) + .HasColumnType("nvarchar(max)"); b.Property("DeviceCode") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.Property("Expiration") - .IsRequired(); + .IsRequired() + .HasColumnType("datetime2"); b.Property("SubjectId") - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.HasKey("UserCode"); b.HasIndex("DeviceCode") .IsUnique(); - b.ToTable("DeviceCodes"); + b.HasIndex("Expiration"); + + b.ToTable("DeviceCodes", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.PersistedGrant", b => { b.Property("Key") - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.Property("ClientId") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); - b.Property("CreationTime"); + b.Property("CreationTime") + .HasColumnType("datetime2"); b.Property("Data") .IsRequired() - .HasMaxLength(50000); + .HasMaxLength(50000) + .HasColumnType("nvarchar(max)"); - b.Property("Expiration"); + b.Property("Expiration") + .HasColumnType("datetime2"); b.Property("SubjectId") - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.Property("Type") .IsRequired() - .HasMaxLength(50); + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); b.HasKey("Key"); + b.HasIndex("Expiration"); + b.HasIndex("SubjectId", "ClientId", "Type"); - b.ToTable("PersistedGrants"); + b.ToTable("PersistedGrants", (string)null); }); #pragma warning restore 612, 618 } diff --git a/src/Services/Identity/Identity.API/Migrations/PersistedGrantDb/20210813072513_InitialMigration.cs b/src/Services/Identity/Identity.API/Migrations/PersistedGrantDb/20210813072513_InitialMigration.cs new file mode 100644 index 000000000..e81f8a197 --- /dev/null +++ b/src/Services/Identity/Identity.API/Migrations/PersistedGrantDb/20210813072513_InitialMigration.cs @@ -0,0 +1,75 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Identity.API.Migrations.PersistedGrantDb +{ + public partial class InitialMigration : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "DeviceCodes", + columns: table => new + { + UserCode = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + DeviceCode = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + SubjectId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + ClientId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + CreationTime = table.Column(type: "datetime2", nullable: false), + Expiration = table.Column(type: "datetime2", nullable: false), + Data = table.Column(type: "nvarchar(max)", maxLength: 50000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DeviceCodes", x => x.UserCode); + }); + + migrationBuilder.CreateTable( + name: "PersistedGrants", + columns: table => new + { + Key = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + Type = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + SubjectId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + ClientId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + CreationTime = table.Column(type: "datetime2", nullable: false), + Expiration = table.Column(type: "datetime2", nullable: true), + Data = table.Column(type: "nvarchar(max)", maxLength: 50000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PersistedGrants", x => x.Key); + }); + + migrationBuilder.CreateIndex( + name: "IX_DeviceCodes_DeviceCode", + table: "DeviceCodes", + column: "DeviceCode", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_DeviceCodes_Expiration", + table: "DeviceCodes", + column: "Expiration"); + + migrationBuilder.CreateIndex( + name: "IX_PersistedGrants_Expiration", + table: "PersistedGrants", + column: "Expiration"); + + migrationBuilder.CreateIndex( + name: "IX_PersistedGrants_SubjectId_ClientId_Type", + table: "PersistedGrants", + columns: new[] { "SubjectId", "ClientId", "Type" }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "DeviceCodes"); + + migrationBuilder.DropTable( + name: "PersistedGrants"); + } + } +} diff --git a/src/Services/Identity/Identity.API/Migrations/PersistedGrantDb/PersistedGrantDbContextModelSnapshot.cs b/src/Services/Identity/Identity.API/Migrations/PersistedGrantDb/PersistedGrantDbContextModelSnapshot.cs index 3188904ef..49b3f2996 100644 --- a/src/Services/Identity/Identity.API/Migrations/PersistedGrantDb/PersistedGrantDbContextModelSnapshot.cs +++ b/src/Services/Identity/Identity.API/Migrations/PersistedGrantDb/PersistedGrantDbContextModelSnapshot.cs @@ -15,72 +15,90 @@ namespace Identity.API.Migrations.PersistedGrantDb { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "3.0.0-preview7.19362.6") .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("ProductVersion", "6.0.0-preview.7.21378.4") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.DeviceFlowCodes", b => { b.Property("UserCode") - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.Property("ClientId") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); - b.Property("CreationTime"); + b.Property("CreationTime") + .HasColumnType("datetime2"); b.Property("Data") .IsRequired() - .HasMaxLength(50000); + .HasMaxLength(50000) + .HasColumnType("nvarchar(max)"); b.Property("DeviceCode") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.Property("Expiration") - .IsRequired(); + .IsRequired() + .HasColumnType("datetime2"); b.Property("SubjectId") - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.HasKey("UserCode"); b.HasIndex("DeviceCode") .IsUnique(); - b.ToTable("DeviceCodes"); + b.HasIndex("Expiration"); + + b.ToTable("DeviceCodes", (string)null); }); modelBuilder.Entity("IdentityServer4.EntityFramework.Entities.PersistedGrant", b => { b.Property("Key") - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.Property("ClientId") .IsRequired() - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); - b.Property("CreationTime"); + b.Property("CreationTime") + .HasColumnType("datetime2"); b.Property("Data") .IsRequired() - .HasMaxLength(50000); + .HasMaxLength(50000) + .HasColumnType("nvarchar(max)"); - b.Property("Expiration"); + b.Property("Expiration") + .HasColumnType("datetime2"); b.Property("SubjectId") - .HasMaxLength(200); + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); b.Property("Type") .IsRequired() - .HasMaxLength(50); + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); b.HasKey("Key"); + b.HasIndex("Expiration"); + b.HasIndex("SubjectId", "ClientId", "Type"); - b.ToTable("PersistedGrants"); + b.ToTable("PersistedGrants", (string)null); }); #pragma warning restore 612, 618 } diff --git a/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentInputModel.cs b/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentInputModel.cs index 739d833aa..fd4e524cf 100644 --- a/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentInputModel.cs +++ b/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentInputModel.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels +namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels { public record ConsentInputModel { diff --git a/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentViewModel.cs b/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentViewModel.cs index 07dbd05c3..6e9e46fe6 100644 --- a/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentViewModel.cs @@ -1,6 +1,4 @@ using IdentityServer4.Models; -using System.Collections.Generic; -using System.Linq; namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels { diff --git a/src/Services/Identity/Identity.API/Models/AccountViewModels/ForgotPasswordViewModel.cs b/src/Services/Identity/Identity.API/Models/AccountViewModels/ForgotPasswordViewModel.cs index ad661c65f..6cade4c6e 100644 --- a/src/Services/Identity/Identity.API/Models/AccountViewModels/ForgotPasswordViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/AccountViewModels/ForgotPasswordViewModel.cs @@ -1,6 +1,4 @@ -using System.ComponentModel.DataAnnotations; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels +namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels { public record ForgotPasswordViewModel { diff --git a/src/Services/Identity/Identity.API/Models/AccountViewModels/LoginViewModel.cs b/src/Services/Identity/Identity.API/Models/AccountViewModels/LoginViewModel.cs index 97ef19aba..15fedcca6 100644 --- a/src/Services/Identity/Identity.API/Models/AccountViewModels/LoginViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/AccountViewModels/LoginViewModel.cs @@ -1,6 +1,4 @@ -using System.ComponentModel.DataAnnotations; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels +namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels { public record LoginViewModel { diff --git a/src/Services/Identity/Identity.API/Models/AccountViewModels/RegisterViewModel.cs b/src/Services/Identity/Identity.API/Models/AccountViewModels/RegisterViewModel.cs index 00fc05d4b..652df6fc7 100644 --- a/src/Services/Identity/Identity.API/Models/AccountViewModels/RegisterViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/AccountViewModels/RegisterViewModel.cs @@ -1,6 +1,4 @@ -using System.ComponentModel.DataAnnotations; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels +namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels { public record RegisterViewModel { diff --git a/src/Services/Identity/Identity.API/Models/AccountViewModels/ResetPasswordViewModel.cs b/src/Services/Identity/Identity.API/Models/AccountViewModels/ResetPasswordViewModel.cs index 50c5b585f..9aad9104d 100644 --- a/src/Services/Identity/Identity.API/Models/AccountViewModels/ResetPasswordViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/AccountViewModels/ResetPasswordViewModel.cs @@ -1,6 +1,4 @@ -using System.ComponentModel.DataAnnotations; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels +namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels { public record ResetPasswordViewModel { diff --git a/src/Services/Identity/Identity.API/Models/AccountViewModels/SendCodeViewModel.cs b/src/Services/Identity/Identity.API/Models/AccountViewModels/SendCodeViewModel.cs index 35429e9e5..207d34ba9 100644 --- a/src/Services/Identity/Identity.API/Models/AccountViewModels/SendCodeViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/AccountViewModels/SendCodeViewModel.cs @@ -1,7 +1,4 @@ -using Microsoft.AspNetCore.Mvc.Rendering; -using System.Collections.Generic; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels +namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels { public record SendCodeViewModel { diff --git a/src/Services/Identity/Identity.API/Models/AccountViewModels/VerifyCodeViewModel.cs b/src/Services/Identity/Identity.API/Models/AccountViewModels/VerifyCodeViewModel.cs index e54d6c05b..d4c15e605 100644 --- a/src/Services/Identity/Identity.API/Models/AccountViewModels/VerifyCodeViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/AccountViewModels/VerifyCodeViewModel.cs @@ -1,6 +1,4 @@ -using System.ComponentModel.DataAnnotations; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels +namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels { public record VerifyCodeViewModel { diff --git a/src/Services/Identity/Identity.API/Models/ApplicationUser.cs b/src/Services/Identity/Identity.API/Models/ApplicationUser.cs index fa43017fc..ee5e8d089 100644 --- a/src/Services/Identity/Identity.API/Models/ApplicationUser.cs +++ b/src/Services/Identity/Identity.API/Models/ApplicationUser.cs @@ -1,7 +1,4 @@ -using Microsoft.AspNetCore.Identity; -using System.ComponentModel.DataAnnotations; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Models +namespace Microsoft.eShopOnContainers.Services.Identity.API.Models { // Add profile data for application users by adding properties to the ApplicationUser class public class ApplicationUser : IdentityUser diff --git a/src/Services/Identity/Identity.API/Models/ErrorViewModel.cs b/src/Services/Identity/Identity.API/Models/ErrorViewModel.cs index a327e7b08..5076b6c1c 100644 --- a/src/Services/Identity/Identity.API/Models/ErrorViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/ErrorViewModel.cs @@ -1,9 +1,5 @@ // Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. - - -using IdentityServer4.Models; - namespace Microsoft.eShopOnContainers.Services.Identity.API.Models { public record ErrorViewModel diff --git a/src/Services/Identity/Identity.API/Models/ManageViewModels/AddPhoneNumberViewModel.cs b/src/Services/Identity/Identity.API/Models/ManageViewModels/AddPhoneNumberViewModel.cs index 878b0440b..b01252e03 100644 --- a/src/Services/Identity/Identity.API/Models/ManageViewModels/AddPhoneNumberViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/ManageViewModels/AddPhoneNumberViewModel.cs @@ -1,6 +1,4 @@ -using System.ComponentModel.DataAnnotations; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels +namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels { public record AddPhoneNumberViewModel { diff --git a/src/Services/Identity/Identity.API/Models/ManageViewModels/ChangePasswordViewModel.cs b/src/Services/Identity/Identity.API/Models/ManageViewModels/ChangePasswordViewModel.cs index 65521429f..e94987e74 100644 --- a/src/Services/Identity/Identity.API/Models/ManageViewModels/ChangePasswordViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/ManageViewModels/ChangePasswordViewModel.cs @@ -1,6 +1,4 @@ -using System.ComponentModel.DataAnnotations; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels +namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels { public record ChangePasswordViewModel { diff --git a/src/Services/Identity/Identity.API/Models/ManageViewModels/ConfigureTwoFactorViewModel.cs b/src/Services/Identity/Identity.API/Models/ManageViewModels/ConfigureTwoFactorViewModel.cs index a0a7f30bf..61dbc52e3 100644 --- a/src/Services/Identity/Identity.API/Models/ManageViewModels/ConfigureTwoFactorViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/ManageViewModels/ConfigureTwoFactorViewModel.cs @@ -1,7 +1,4 @@ -using Microsoft.AspNetCore.Mvc.Rendering; -using System.Collections.Generic; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels +namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels { public record ConfigureTwoFactorViewModel { diff --git a/src/Services/Identity/Identity.API/Models/ManageViewModels/IndexViewModel.cs b/src/Services/Identity/Identity.API/Models/ManageViewModels/IndexViewModel.cs index 8d32c8e69..d6b20556b 100644 --- a/src/Services/Identity/Identity.API/Models/ManageViewModels/IndexViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/ManageViewModels/IndexViewModel.cs @@ -1,7 +1,4 @@ -using Microsoft.AspNetCore.Identity; -using System.Collections.Generic; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels +namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels { public record IndexViewModel { diff --git a/src/Services/Identity/Identity.API/Models/ManageViewModels/SetPasswordViewModel.cs b/src/Services/Identity/Identity.API/Models/ManageViewModels/SetPasswordViewModel.cs index e2f048054..51a2758bc 100644 --- a/src/Services/Identity/Identity.API/Models/ManageViewModels/SetPasswordViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/ManageViewModels/SetPasswordViewModel.cs @@ -1,6 +1,4 @@ -using System.ComponentModel.DataAnnotations; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels +namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels { public record SetPasswordViewModel { diff --git a/src/Services/Identity/Identity.API/Models/ManageViewModels/VerifyPhoneNumberViewModel.cs b/src/Services/Identity/Identity.API/Models/ManageViewModels/VerifyPhoneNumberViewModel.cs index a3c8e5c65..86859a2e0 100644 --- a/src/Services/Identity/Identity.API/Models/ManageViewModels/VerifyPhoneNumberViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/ManageViewModels/VerifyPhoneNumberViewModel.cs @@ -1,6 +1,4 @@ -using System.ComponentModel.DataAnnotations; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels +namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels { public record VerifyPhoneNumberViewModel { diff --git a/src/Services/Identity/Identity.API/Program.cs b/src/Services/Identity/Identity.API/Program.cs index a6f7ec9ee..7c021c7a4 100644 --- a/src/Services/Identity/Identity.API/Program.cs +++ b/src/Services/Identity/Identity.API/Program.cs @@ -1,20 +1,4 @@ -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; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using Serilog; -using System; -using System.IO; -using Azure.Identity; -using Azure.Core; - -string Namespace = typeof(Startup).Namespace; +string Namespace = typeof(Startup).Namespace; string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1); var configuration = GetConfiguration(); diff --git a/src/Services/Identity/Identity.API/Services/EFLoginService.cs b/src/Services/Identity/Identity.API/Services/EFLoginService.cs index 6cee1e7c8..81a5f6a3e 100644 --- a/src/Services/Identity/Identity.API/Services/EFLoginService.cs +++ b/src/Services/Identity/Identity.API/Services/EFLoginService.cs @@ -1,9 +1,4 @@ -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Identity; -using Microsoft.eShopOnContainers.Services.Identity.API.Models; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Services +namespace Microsoft.eShopOnContainers.Services.Identity.API.Services { public class EFLoginService : ILoginService { diff --git a/src/Services/Identity/Identity.API/Services/ILoginService.cs b/src/Services/Identity/Identity.API/Services/ILoginService.cs index 8b5ba8939..e35b07d6f 100644 --- a/src/Services/Identity/Identity.API/Services/ILoginService.cs +++ b/src/Services/Identity/Identity.API/Services/ILoginService.cs @@ -1,7 +1,4 @@ -using Microsoft.AspNetCore.Authentication; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Services +namespace Microsoft.eShopOnContainers.Services.Identity.API.Services { public interface ILoginService { diff --git a/src/Services/Identity/Identity.API/Services/ProfileService.cs b/src/Services/Identity/Identity.API/Services/ProfileService.cs index b7637fef2..0f0352ad1 100644 --- a/src/Services/Identity/Identity.API/Services/ProfileService.cs +++ b/src/Services/Identity/Identity.API/Services/ProfileService.cs @@ -1,16 +1,4 @@ -using IdentityModel; -using IdentityServer4.Models; -using IdentityServer4.Services; -using Microsoft.AspNetCore.Identity; -using Microsoft.eShopOnContainers.Services.Identity.API.Models; -using System; -using System.Collections.Generic; -using System.IdentityModel.Tokens.Jwt; -using System.Linq; -using System.Security.Claims; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Services +namespace Microsoft.eShopOnContainers.Services.Identity.API.Services { public class ProfileService : IProfileService { diff --git a/src/Services/Identity/Identity.API/Services/RedirectService.cs b/src/Services/Identity/Identity.API/Services/RedirectService.cs index 64a574d78..4f35e1e92 100644 --- a/src/Services/Identity/Identity.API/Services/RedirectService.cs +++ b/src/Services/Identity/Identity.API/Services/RedirectService.cs @@ -1,6 +1,4 @@ -using System.Text.RegularExpressions; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Services +namespace Microsoft.eShopOnContainers.Services.Identity.API.Services { public class RedirectService : IRedirectService { diff --git a/src/Services/Identity/Identity.API/Startup.cs b/src/Services/Identity/Identity.API/Startup.cs index a161729db..2ea47d63a 100644 --- a/src/Services/Identity/Identity.API/Startup.cs +++ b/src/Services/Identity/Identity.API/Startup.cs @@ -1,26 +1,4 @@ -using Autofac; -using Autofac.Extensions.DependencyInjection; -using HealthChecks.UI.Client; -using IdentityServer4.Services; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.DataProtection; -using Microsoft.AspNetCore.Diagnostics.HealthChecks; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Identity; -using Microsoft.EntityFrameworkCore; -using Microsoft.eShopOnContainers.Services.Identity.API.Certificates; -using Microsoft.eShopOnContainers.Services.Identity.API.Data; -using Microsoft.eShopOnContainers.Services.Identity.API.Devspaces; -using Microsoft.eShopOnContainers.Services.Identity.API.Models; -using Microsoft.eShopOnContainers.Services.Identity.API.Services; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Diagnostics.HealthChecks; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using StackExchange.Redis; -using System; -using System.Reflection; +using Microsoft.AspNetCore.DataProtection; namespace Microsoft.eShopOnContainers.Services.Identity.API { @@ -112,7 +90,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API services.AddRazorPages(); var container = new ContainerBuilder(); - container.Populate(services); + container.Populate(services); return new AutofacServiceProvider(container.Build()); } @@ -132,12 +110,12 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API else { app.UseExceptionHandler("/Home/Error"); - } + } var pathBase = Configuration["PATH_BASE"]; if (!string.IsNullOrEmpty(pathBase)) { - loggerFactory.CreateLogger().LogDebug("Using PATH BASE '{pathBase}'", pathBase); + //loggerFactory.CreateLogger().LogDebug("Using PATH BASE '{pathBase}'", pathBase); app.UsePathBase(pathBase); } @@ -159,6 +137,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API // To avoid this problem, the policy of cookies shold be in Lax mode. app.UseCookiePolicy(new CookiePolicyOptions { MinimumSameSitePolicy = AspNetCore.Http.SameSiteMode.Lax }); app.UseRouting(); + app.UseEndpoints(endpoints => { endpoints.MapDefaultControllerRoute(); diff --git a/src/Services/Ordering/Ordering.API/Dockerfile b/src/Services/Ordering/Ordering.API/Dockerfile index 9174e181a..decb8fdac 100644 --- a/src/Services/Ordering/Ordering.API/Dockerfile +++ b/src/Services/Ordering/Ordering.API/Dockerfile @@ -1,8 +1,8 @@ -FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.6 AS base +FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.7 AS base WORKDIR /app EXPOSE 80 -FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.6 AS build +FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.7 AS build WORKDIR /src # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Dockerfile b/src/Services/Ordering/Ordering.BackgroundTasks/Dockerfile index dd7b4924d..c1986b1e5 100644 --- a/src/Services/Ordering/Ordering.BackgroundTasks/Dockerfile +++ b/src/Services/Ordering/Ordering.BackgroundTasks/Dockerfile @@ -1,8 +1,8 @@ -FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.6 AS base +FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.7 AS base WORKDIR /app EXPOSE 80 -FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.6 AS build +FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.7 AS build WORKDIR /src # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles diff --git a/src/Services/Ordering/Ordering.SignalrHub/Dockerfile b/src/Services/Ordering/Ordering.SignalrHub/Dockerfile index 9b67a2b3e..4a2dd243b 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/Dockerfile +++ b/src/Services/Ordering/Ordering.SignalrHub/Dockerfile @@ -1,8 +1,8 @@ -FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.6 AS base +FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.7 AS base WORKDIR /app EXPOSE 80 -FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.6 AS build +FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.7 AS build WORKDIR /src # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles diff --git a/src/Services/Payment/Payment.API/Dockerfile b/src/Services/Payment/Payment.API/Dockerfile index 2ece6db40..32bad55c9 100644 --- a/src/Services/Payment/Payment.API/Dockerfile +++ b/src/Services/Payment/Payment.API/Dockerfile @@ -1,8 +1,8 @@ -FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.6 AS base +FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.7 AS base WORKDIR /app EXPOSE 80 -FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.6 AS build +FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.7 AS build WORKDIR /src # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles diff --git a/src/Services/Webhooks/Webhooks.API/Dockerfile b/src/Services/Webhooks/Webhooks.API/Dockerfile index 3922dad0d..48369f3ab 100644 --- a/src/Services/Webhooks/Webhooks.API/Dockerfile +++ b/src/Services/Webhooks/Webhooks.API/Dockerfile @@ -1,8 +1,8 @@ -FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.6 AS base +FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.7 AS base WORKDIR /app EXPOSE 80 -FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.6 AS build +FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.7 AS build WORKDIR /src # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles diff --git a/src/Web/WebMVC/Dockerfile b/src/Web/WebMVC/Dockerfile index 87b05dcea..663e02c87 100644 --- a/src/Web/WebMVC/Dockerfile +++ b/src/Web/WebMVC/Dockerfile @@ -1,8 +1,8 @@ -FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.6 AS base +FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.7 AS base WORKDIR /app EXPOSE 80 -FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.6 AS build +FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.7 AS build WORKDIR /src # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles diff --git a/src/Web/WebSPA/Dockerfile b/src/Web/WebSPA/Dockerfile index 3f2b375ec..b8c7f97d1 100644 --- a/src/Web/WebSPA/Dockerfile +++ b/src/Web/WebSPA/Dockerfile @@ -1,7 +1,7 @@ #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. ARG NODE_IMAGE=node:12.0 -FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.6 AS base +FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.7 AS base WORKDIR /app EXPOSE 80 @@ -14,7 +14,7 @@ RUN npm install COPY Web/WebSPA/Client . RUN npm run build:prod -FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.6 AS build +FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.7 AS build WORKDIR /src # Create this "restore-solution" section by running ./Create-DockerfileSolutionRestore.ps1, to optimize build cache reuse diff --git a/src/Web/WebhookClient/Dockerfile b/src/Web/WebhookClient/Dockerfile index 9a494b723..79bde3d62 100644 --- a/src/Web/WebhookClient/Dockerfile +++ b/src/Web/WebhookClient/Dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.6 AS base +FROM mcr.microsoft.com/dotnet/nightly/aspnet:6.0.0-preview.7 AS base WORKDIR /app EXPOSE 80 EXPOSE 443 -FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.6 AS build +FROM mcr.microsoft.com/dotnet/nightly/sdk:6.0.100-preview.7 AS build WORKDIR /src # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles