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..d072028db 100644 --- a/src/Services/Identity/Identity.API/Configuration/Config.cs +++ b/src/Services/Identity/Identity.API/Configuration/Config.cs @@ -1,30 +1,26 @@ -using IdentityServer4; -using IdentityServer4.Models; -using System.Collections.Generic; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration +namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration { public class Config { // ApiResources define the apis in your system - public static IEnumerable GetApis() - { - return new List + public static IEnumerable GetApis() + { + return new List { - new ApiResource("orders", "Orders Service"), - new ApiResource("basket", "Basket Service"), - new ApiResource("mobileshoppingagg", "Mobile Shopping Aggregator"), - new ApiResource("webshoppingagg", "Web Shopping Aggregator"), - new ApiResource("orders.signalrhub", "Ordering Signalr Hub"), - new ApiResource("webhooks", "Webhooks registration Service"), + new IdentityServer4.Models.ApiResource("orders", "Orders Service"), + new IdentityServer4.Models.ApiResource("basket", "Basket Service"), + new IdentityServer4.Models.ApiResource("mobileshoppingagg", "Mobile Shopping Aggregator"), + new IdentityServer4.Models.ApiResource("webshoppingagg", "Web Shopping Aggregator"), + new IdentityServer4.Models.ApiResource("orders.signalrhub", "Ordering Signalr Hub"), + new IdentityServer4.Models.ApiResource("webhooks", "Webhooks registration Service"), }; } // Identity resources are data like user ID, name, or email address of a user // see: http://docs.identityserver.io/en/release/configuration/resources.html - public static IEnumerable GetResources() + public static IEnumerable GetResources() { - return new List + return new List { new IdentityResources.OpenId(), new IdentityResources.Profile() @@ -32,12 +28,12 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration } // client want to access resources (aka scopes) - public static IEnumerable GetClients(Dictionary clientsUrl) + public static IEnumerable GetClients(Dictionary clientsUrl) { - return new List + return new List { // JavaScript Client - new Client + new IdentityServer4.Models.Client { ClientId = "js", ClientName = "eShop SPA OpenId Client", @@ -58,15 +54,15 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration "webhooks" }, }, - new Client + new IdentityServer4.Models.Client { ClientId = "xamarin", ClientName = "eShop Xamarin OpenId Client", AllowedGrantTypes = GrantTypes.Hybrid, //Used to retrieve the access token on the back channel. ClientSecrets = - { - new Secret("secret".Sha256()) + { + new IdentityServer4.Models.Secret("secret".Sha256()) }, RedirectUris = { clientsUrl["Xamarin"] }, RequireConsent = false, @@ -87,13 +83,14 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration AllowOfflineAccess = true, AllowAccessTokensViaBrowser = true }, - new Client + new IdentityServer4.Models.Client { ClientId = "mvc", ClientName = "MVC Client", - ClientSecrets = new List + ClientSecrets = new List { - new Secret("secret".Sha256()) + + new IdentityServer4.Models.Secret("secret".Sha256()) }, ClientUri = $"{clientsUrl["Mvc"]}", // public uri of the client AllowedGrantTypes = GrantTypes.Hybrid, @@ -123,13 +120,13 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration AccessTokenLifetime = 60*60*2, // 2 hours IdentityTokenLifetime= 60*60*2 // 2 hours }, - new Client + new IdentityServer4.Models.Client { ClientId = "webhooksclient", ClientName = "Webhooks Client", - ClientSecrets = new List + ClientSecrets = new List { - new Secret("secret".Sha256()) + new IdentityServer4.Models.Secret("secret".Sha256()) }, ClientUri = $"{clientsUrl["WebhooksWeb"]}", // public uri of the client AllowedGrantTypes = GrantTypes.Hybrid, @@ -155,13 +152,13 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration AccessTokenLifetime = 60*60*2, // 2 hours IdentityTokenLifetime= 60*60*2 // 2 hours }, - new Client + new IdentityServer4.Models.Client { ClientId = "mvctest", ClientName = "MVC Client Test", - ClientSecrets = new List + ClientSecrets = new List { - new Secret("secret".Sha256()) + new IdentityServer4.Models.Secret("secret".Sha256()) }, ClientUri = $"{clientsUrl["Mvc"]}", // public uri of the client AllowedGrantTypes = GrantTypes.Hybrid, @@ -187,7 +184,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration "webhooks" }, }, - new Client + new IdentityServer4.Models.Client { ClientId = "basketswaggerui", ClientName = "Basket Swagger UI", @@ -202,7 +199,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration "basket" } }, - new Client + new IdentityServer4.Models.Client { ClientId = "orderingswaggerui", ClientName = "Ordering Swagger UI", @@ -217,7 +214,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration "orders" } }, - new Client + new IdentityServer4.Models.Client { ClientId = "mobileshoppingaggswaggerui", ClientName = "Mobile Shopping Aggregattor Swagger UI", @@ -232,7 +229,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration "mobileshoppingagg" } }, - new Client + new IdentityServer4.Models.Client { ClientId = "webshoppingaggswaggerui", ClientName = "Web Shopping Aggregattor Swagger UI", @@ -248,7 +245,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration "basket" } }, - new Client + new IdentityServer4.Models.Client { ClientId = "webhooksswaggerui", ClientName = "WebHooks Service Swagger UI", 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..80a83b027 100644 --- a/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs +++ b/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs @@ -1,14 +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; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Data +namespace Microsoft.eShopOnContainers.Services.Identity.API.Data { public class ConfigurationDbContextSeed { 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/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..a18a7da41 --- /dev/null +++ b/src/Services/Identity/Identity.API/GlobalUsings.cs @@ -0,0 +1,185 @@ +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.Entities; +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.DataProtection; +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..f3c4b8345 100644 --- a/src/Services/Identity/Identity.API/Identity.API.csproj +++ b/src/Services/Identity/Identity.API/Identity.API.csproj @@ -30,16 +30,16 @@ - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/src/Services/Identity/Identity.API/Migrations/ConfigurationDb/20210813072543_InitialMigration.cs b/src/Services/Identity/Identity.API/Migrations/ConfigurationDb/20210813072543_InitialMigration.cs index 982d95bb5..57f508711 100644 --- a/src/Services/Identity/Identity.API/Migrations/ConfigurationDb/20210813072543_InitialMigration.cs +++ b/src/Services/Identity/Identity.API/Migrations/ConfigurationDb/20210813072543_InitialMigration.cs @@ -1,4 +1,7 @@ -namespace Identity.API.Migrations.ConfigurationDb +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Identity.API.Migrations.ConfigurationDb { public partial class InitialMigration : Migration { 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..6c17662a5 100644 --- a/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentViewModel.cs @@ -1,12 +1,8 @@ -using IdentityServer4.Models; -using System.Collections.Generic; -using System.Linq; - -namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels +namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels { public record ConsentViewModel : ConsentInputModel { - public ConsentViewModel(ConsentInputModel model, string returnUrl, AuthorizationRequest request, Client client, Resources resources) + public ConsentViewModel(ConsentInputModel model, string returnUrl, AuthorizationRequest request, IdentityServer4.Models.Client client, Resources resources) { RememberConsent = model?.RememberConsent ?? true; ScopesConsented = model?.ScopesConsented ?? Enumerable.Empty(); @@ -43,7 +39,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewMo Checked = check || scope.Required; } - public ScopeViewModel(IdentityResource identity, bool check) + public ScopeViewModel(IdentityServer4.Models.IdentityResource identity, bool check) { Name = identity.Name; DisplayName = identity.DisplayName; 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..b6e13fd01 100644 --- a/src/Services/Identity/Identity.API/Startup.cs +++ b/src/Services/Identity/Identity.API/Startup.cs @@ -1,28 +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; - -namespace Microsoft.eShopOnContainers.Services.Identity.API +namespace Microsoft.eShopOnContainers.Services.Identity.API { public class Startup { @@ -112,7 +88,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 +108,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 +135,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();