diff --git a/src/Services/Identity/Identity.API/Configuration/Config.cs b/src/Services/Identity/Identity.API/Configuration/Config.cs index d072028db..6d5393bde 100644 --- a/src/Services/Identity/Identity.API/Configuration/Config.cs +++ b/src/Services/Identity/Identity.API/Configuration/Config.cs @@ -1,26 +1,28 @@ -namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration +using IdentityServer4.Models; + +namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration { public class Config { // ApiResources define the apis in your system - public static IEnumerable GetApis() + public static IEnumerable GetApis() { - return new List + return new List { - 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"), + 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"), }; } // 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() @@ -28,12 +30,12 @@ } // 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 IdentityServer4.Models.Client + new Client { ClientId = "js", ClientName = "eShop SPA OpenId Client", @@ -54,7 +56,7 @@ "webhooks" }, }, - new IdentityServer4.Models.Client + new Client { ClientId = "xamarin", ClientName = "eShop Xamarin OpenId Client", @@ -62,7 +64,7 @@ //Used to retrieve the access token on the back channel. ClientSecrets = { - new IdentityServer4.Models.Secret("secret".Sha256()) + new Secret("secret".Sha256()) }, RedirectUris = { clientsUrl["Xamarin"] }, RequireConsent = false, @@ -83,14 +85,14 @@ AllowOfflineAccess = true, AllowAccessTokensViaBrowser = true }, - new IdentityServer4.Models.Client + new Client { ClientId = "mvc", ClientName = "MVC Client", - ClientSecrets = new List + ClientSecrets = new List { - new IdentityServer4.Models.Secret("secret".Sha256()) + new Secret("secret".Sha256()) }, ClientUri = $"{clientsUrl["Mvc"]}", // public uri of the client AllowedGrantTypes = GrantTypes.Hybrid, @@ -120,13 +122,13 @@ AccessTokenLifetime = 60*60*2, // 2 hours IdentityTokenLifetime= 60*60*2 // 2 hours }, - new IdentityServer4.Models.Client + new Client { ClientId = "webhooksclient", ClientName = "Webhooks Client", - ClientSecrets = new List + ClientSecrets = new List { - new IdentityServer4.Models.Secret("secret".Sha256()) + new Secret("secret".Sha256()) }, ClientUri = $"{clientsUrl["WebhooksWeb"]}", // public uri of the client AllowedGrantTypes = GrantTypes.Hybrid, @@ -152,13 +154,13 @@ AccessTokenLifetime = 60*60*2, // 2 hours IdentityTokenLifetime= 60*60*2 // 2 hours }, - new IdentityServer4.Models.Client + new Client { ClientId = "mvctest", ClientName = "MVC Client Test", - ClientSecrets = new List + ClientSecrets = new List { - new IdentityServer4.Models.Secret("secret".Sha256()) + new Secret("secret".Sha256()) }, ClientUri = $"{clientsUrl["Mvc"]}", // public uri of the client AllowedGrantTypes = GrantTypes.Hybrid, @@ -184,7 +186,7 @@ "webhooks" }, }, - new IdentityServer4.Models.Client + new Client { ClientId = "basketswaggerui", ClientName = "Basket Swagger UI", @@ -199,7 +201,7 @@ "basket" } }, - new IdentityServer4.Models.Client + new Client { ClientId = "orderingswaggerui", ClientName = "Ordering Swagger UI", @@ -214,7 +216,7 @@ "orders" } }, - new IdentityServer4.Models.Client + new Client { ClientId = "mobileshoppingaggswaggerui", ClientName = "Mobile Shopping Aggregattor Swagger UI", @@ -229,7 +231,7 @@ "mobileshoppingagg" } }, - new IdentityServer4.Models.Client + new Client { ClientId = "webshoppingaggswaggerui", ClientName = "Web Shopping Aggregattor Swagger UI", @@ -245,7 +247,7 @@ "basket" } }, - new IdentityServer4.Models.Client + new Client { ClientId = "webhooksswaggerui", ClientName = "WebHooks Service Swagger UI", diff --git a/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs b/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs index 80a83b027..e3df90fdd 100644 --- a/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs +++ b/src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs @@ -1,4 +1,6 @@ -namespace Microsoft.eShopOnContainers.Services.Identity.API.Data +using IdentityServer4.EntityFramework.Entities; + +namespace Microsoft.eShopOnContainers.Services.Identity.API.Data { public class ConfigurationDbContextSeed { diff --git a/src/Services/Identity/Identity.API/GlobalUsings.cs b/src/Services/Identity/Identity.API/GlobalUsings.cs index a18a7da41..bfbb354db 100644 --- a/src/Services/Identity/Identity.API/GlobalUsings.cs +++ b/src/Services/Identity/Identity.API/GlobalUsings.cs @@ -7,7 +7,6 @@ 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; @@ -18,7 +17,6 @@ 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; diff --git a/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentViewModel.cs b/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentViewModel.cs index 6c17662a5..6e9e46fe6 100644 --- a/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentViewModel.cs +++ b/src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentViewModel.cs @@ -1,8 +1,10 @@ -namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels +using IdentityServer4.Models; + +namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels { public record ConsentViewModel : ConsentInputModel { - public ConsentViewModel(ConsentInputModel model, string returnUrl, AuthorizationRequest request, IdentityServer4.Models.Client client, Resources resources) + public ConsentViewModel(ConsentInputModel model, string returnUrl, AuthorizationRequest request, Client client, Resources resources) { RememberConsent = model?.RememberConsent ?? true; ScopesConsented = model?.ScopesConsented ?? Enumerable.Empty(); @@ -39,7 +41,7 @@ Checked = check || scope.Required; } - public ScopeViewModel(IdentityServer4.Models.IdentityResource identity, bool check) + public ScopeViewModel(IdentityResource identity, bool check) { Name = identity.Name; DisplayName = identity.DisplayName; diff --git a/src/Services/Identity/Identity.API/Startup.cs b/src/Services/Identity/Identity.API/Startup.cs index b6e13fd01..2ea47d63a 100644 --- a/src/Services/Identity/Identity.API/Startup.cs +++ b/src/Services/Identity/Identity.API/Startup.cs @@ -1,4 +1,6 @@ -namespace Microsoft.eShopOnContainers.Services.Identity.API +using Microsoft.AspNetCore.DataProtection; + +namespace Microsoft.eShopOnContainers.Services.Identity.API { public class Startup {