Included global usings for identity project

This commit is contained in:
Sumit Ghosh 2021-08-13 17:03:23 +05:30
parent 7cbbb3c769
commit b678bdd11a
40 changed files with 271 additions and 295 deletions

View File

@ -1,8 +1,4 @@
using System.IO; namespace Microsoft.eShopOnContainers.Services.Identity.API.Certificates
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
namespace Microsoft.eShopOnContainers.Services.Identity.API.Certificates
{ {
static class Certificate static class Certificate
{ {

View File

@ -1,30 +1,26 @@
using IdentityServer4; namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration
using IdentityServer4.Models;
using System.Collections.Generic;
namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration
{ {
public class Config public class Config
{ {
// ApiResources define the apis in your system // ApiResources define the apis in your system
public static IEnumerable<ApiResource> GetApis() public static IEnumerable<IdentityServer4.Models.ApiResource> GetApis()
{ {
return new List<ApiResource> return new List<IdentityServer4.Models.ApiResource>
{ {
new ApiResource("orders", "Orders Service"), new IdentityServer4.Models.ApiResource("orders", "Orders Service"),
new ApiResource("basket", "Basket Service"), new IdentityServer4.Models.ApiResource("basket", "Basket Service"),
new ApiResource("mobileshoppingagg", "Mobile Shopping Aggregator"), new IdentityServer4.Models.ApiResource("mobileshoppingagg", "Mobile Shopping Aggregator"),
new ApiResource("webshoppingagg", "Web Shopping Aggregator"), new IdentityServer4.Models.ApiResource("webshoppingagg", "Web Shopping Aggregator"),
new ApiResource("orders.signalrhub", "Ordering Signalr Hub"), new IdentityServer4.Models.ApiResource("orders.signalrhub", "Ordering Signalr Hub"),
new ApiResource("webhooks", "Webhooks registration Service"), new IdentityServer4.Models.ApiResource("webhooks", "Webhooks registration Service"),
}; };
} }
// Identity resources are data like user ID, name, or email address of a user // Identity resources are data like user ID, name, or email address of a user
// see: http://docs.identityserver.io/en/release/configuration/resources.html // see: http://docs.identityserver.io/en/release/configuration/resources.html
public static IEnumerable<IdentityResource> GetResources() public static IEnumerable<IdentityServer4.Models.IdentityResource> GetResources()
{ {
return new List<IdentityResource> return new List<IdentityServer4.Models.IdentityResource>
{ {
new IdentityResources.OpenId(), new IdentityResources.OpenId(),
new IdentityResources.Profile() new IdentityResources.Profile()
@ -32,12 +28,12 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration
} }
// client want to access resources (aka scopes) // client want to access resources (aka scopes)
public static IEnumerable<Client> GetClients(Dictionary<string, string> clientsUrl) public static IEnumerable<IdentityServer4.Models.Client> GetClients(Dictionary<string, string> clientsUrl)
{ {
return new List<Client> return new List<IdentityServer4.Models.Client>
{ {
// JavaScript Client // JavaScript Client
new Client new IdentityServer4.Models.Client
{ {
ClientId = "js", ClientId = "js",
ClientName = "eShop SPA OpenId Client", ClientName = "eShop SPA OpenId Client",
@ -58,15 +54,15 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration
"webhooks" "webhooks"
}, },
}, },
new Client new IdentityServer4.Models.Client
{ {
ClientId = "xamarin", ClientId = "xamarin",
ClientName = "eShop Xamarin OpenId Client", ClientName = "eShop Xamarin OpenId Client",
AllowedGrantTypes = GrantTypes.Hybrid, AllowedGrantTypes = GrantTypes.Hybrid,
//Used to retrieve the access token on the back channel. //Used to retrieve the access token on the back channel.
ClientSecrets = ClientSecrets =
{ {
new Secret("secret".Sha256()) new IdentityServer4.Models.Secret("secret".Sha256())
}, },
RedirectUris = { clientsUrl["Xamarin"] }, RedirectUris = { clientsUrl["Xamarin"] },
RequireConsent = false, RequireConsent = false,
@ -87,13 +83,14 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration
AllowOfflineAccess = true, AllowOfflineAccess = true,
AllowAccessTokensViaBrowser = true AllowAccessTokensViaBrowser = true
}, },
new Client new IdentityServer4.Models.Client
{ {
ClientId = "mvc", ClientId = "mvc",
ClientName = "MVC Client", ClientName = "MVC Client",
ClientSecrets = new List<Secret> ClientSecrets = new List<IdentityServer4.Models.Secret>
{ {
new Secret("secret".Sha256())
new IdentityServer4.Models.Secret("secret".Sha256())
}, },
ClientUri = $"{clientsUrl["Mvc"]}", // public uri of the client ClientUri = $"{clientsUrl["Mvc"]}", // public uri of the client
AllowedGrantTypes = GrantTypes.Hybrid, AllowedGrantTypes = GrantTypes.Hybrid,
@ -123,13 +120,13 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration
AccessTokenLifetime = 60*60*2, // 2 hours AccessTokenLifetime = 60*60*2, // 2 hours
IdentityTokenLifetime= 60*60*2 // 2 hours IdentityTokenLifetime= 60*60*2 // 2 hours
}, },
new Client new IdentityServer4.Models.Client
{ {
ClientId = "webhooksclient", ClientId = "webhooksclient",
ClientName = "Webhooks Client", ClientName = "Webhooks Client",
ClientSecrets = new List<Secret> ClientSecrets = new List<IdentityServer4.Models.Secret>
{ {
new Secret("secret".Sha256()) new IdentityServer4.Models.Secret("secret".Sha256())
}, },
ClientUri = $"{clientsUrl["WebhooksWeb"]}", // public uri of the client ClientUri = $"{clientsUrl["WebhooksWeb"]}", // public uri of the client
AllowedGrantTypes = GrantTypes.Hybrid, AllowedGrantTypes = GrantTypes.Hybrid,
@ -155,13 +152,13 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration
AccessTokenLifetime = 60*60*2, // 2 hours AccessTokenLifetime = 60*60*2, // 2 hours
IdentityTokenLifetime= 60*60*2 // 2 hours IdentityTokenLifetime= 60*60*2 // 2 hours
}, },
new Client new IdentityServer4.Models.Client
{ {
ClientId = "mvctest", ClientId = "mvctest",
ClientName = "MVC Client Test", ClientName = "MVC Client Test",
ClientSecrets = new List<Secret> ClientSecrets = new List<IdentityServer4.Models.Secret>
{ {
new Secret("secret".Sha256()) new IdentityServer4.Models.Secret("secret".Sha256())
}, },
ClientUri = $"{clientsUrl["Mvc"]}", // public uri of the client ClientUri = $"{clientsUrl["Mvc"]}", // public uri of the client
AllowedGrantTypes = GrantTypes.Hybrid, AllowedGrantTypes = GrantTypes.Hybrid,
@ -187,7 +184,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration
"webhooks" "webhooks"
}, },
}, },
new Client new IdentityServer4.Models.Client
{ {
ClientId = "basketswaggerui", ClientId = "basketswaggerui",
ClientName = "Basket Swagger UI", ClientName = "Basket Swagger UI",
@ -202,7 +199,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration
"basket" "basket"
} }
}, },
new Client new IdentityServer4.Models.Client
{ {
ClientId = "orderingswaggerui", ClientId = "orderingswaggerui",
ClientName = "Ordering Swagger UI", ClientName = "Ordering Swagger UI",
@ -217,7 +214,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration
"orders" "orders"
} }
}, },
new Client new IdentityServer4.Models.Client
{ {
ClientId = "mobileshoppingaggswaggerui", ClientId = "mobileshoppingaggswaggerui",
ClientName = "Mobile Shopping Aggregattor Swagger UI", ClientName = "Mobile Shopping Aggregattor Swagger UI",
@ -232,7 +229,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration
"mobileshoppingagg" "mobileshoppingagg"
} }
}, },
new Client new IdentityServer4.Models.Client
{ {
ClientId = "webshoppingaggswaggerui", ClientId = "webshoppingaggswaggerui",
ClientName = "Web Shopping Aggregattor Swagger UI", ClientName = "Web Shopping Aggregattor Swagger UI",
@ -248,7 +245,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Configuration
"basket" "basket"
} }
}, },
new Client new IdentityServer4.Models.Client
{ {
ClientId = "webhooksswaggerui", ClientId = "webhooksswaggerui",
ClientName = "WebHooks Service Swagger UI", ClientName = "WebHooks Service Swagger UI",

View File

@ -1,23 +1,4 @@
using IdentityModel; namespace Microsoft.eShopOnContainers.Services.Identity.API.Controllers
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
{ {
/// <summary> /// <summary>
/// This sample controller implements a typical login/logout/provision workflow for local accounts. /// This sample controller implements a typical login/logout/provision workflow for local accounts.

View File

@ -1,13 +1,4 @@
using IdentityServer4.Models; namespace Microsoft.eShopOnContainers.Services.Identity.API.Controllers
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
{ {
/// <summary> /// <summary>
/// This controller implements the consent logic /// This controller implements the consent logic

View File

@ -1,12 +1,4 @@
 namespace Microsoft.eShopOnContainers.Services.Identity.API.Controllers
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
{ {
public class HomeController : Controller public class HomeController : Controller
{ {

View File

@ -1,8 +1,4 @@
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; namespace Microsoft.eShopOnContainers.Services.Identity.API.Data
using Microsoft.EntityFrameworkCore;
using Microsoft.eShopOnContainers.Services.Identity.API.Models;
namespace Microsoft.eShopOnContainers.Services.Identity.API.Data
{ {
public class ApplicationDbContext : IdentityDbContext<ApplicationUser> public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{ {

View File

@ -1,18 +1,4 @@
using Microsoft.AspNetCore.Hosting; namespace Microsoft.eShopOnContainers.Services.Identity.API.Data
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
{ {
@ -58,7 +44,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data
} }
} }
private IEnumerable<ApplicationUser> GetUsersFromFile(string contentRootPath, ILogger logger) private IEnumerable<ApplicationUser> GetUsersFromFile(string contentRootPath, Microsoft.Extensions.Logging.ILogger logger)
{ {
string csvFileUsers = Path.Combine(contentRootPath, "Setup", "Users.csv"); string csvFileUsers = Path.Combine(contentRootPath, "Setup", "Users.csv");
@ -192,7 +178,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data
return csvheaders; return csvheaders;
} }
static void GetPreconfiguredImages(string contentRootPath, string webroot, ILogger logger) static void GetPreconfiguredImages(string contentRootPath, string webroot, Microsoft.Extensions.Logging.ILogger logger)
{ {
try try
{ {

View File

@ -1,14 +1,4 @@
using IdentityServer4.EntityFramework.DbContexts; namespace Microsoft.eShopOnContainers.Services.Identity.API.Data
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
{ {
public class ConfigurationDbContextSeed public class ConfigurationDbContextSeed
{ {

View File

@ -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 namespace Microsoft.eShopOnContainers.Services.Identity.API.Devspaces
{ {
public class DevspacesRedirectUriValidator : IRedirectUriValidator public class DevspacesRedirectUriValidator : IRedirectUriValidator
{ {
private readonly ILogger _logger; private readonly Microsoft.Extensions.Logging.ILogger _logger;
public DevspacesRedirectUriValidator(ILogger<DevspacesRedirectUriValidator> logger) public DevspacesRedirectUriValidator(ILogger<DevspacesRedirectUriValidator> logger)
{ {
_logger = logger; _logger = logger;
} }
public Task<bool> IsPostLogoutRedirectUriValidAsync(string requestedUri, Client client) public Task<bool> IsPostLogoutRedirectUriValidAsync(string requestedUri, IdentityServer4.Models.Client client)
{ {
_logger.LogInformation("Client {ClientName} used post logout uri {RequestedUri}.", client.ClientName, requestedUri); _logger.LogInformation("Client {ClientName} used post logout uri {RequestedUri}.", client.ClientName, requestedUri);
return Task.FromResult(true); return Task.FromResult(true);
} }
public Task<bool> IsRedirectUriValidAsync(string requestedUri, Client client) public Task<bool> IsRedirectUriValidAsync(string requestedUri, IdentityServer4.Models.Client client)
{ {
_logger.LogInformation("Client {ClientName} used post logout uri {RequestedUri}.", client.ClientName, requestedUri); _logger.LogInformation("Client {ClientName} used post logout uri {RequestedUri}.", client.ClientName, requestedUri);
return Task.FromResult(true); return Task.FromResult(true);

View File

@ -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 static class IdentityDevspacesBuilderExtensions
{ {

View File

@ -1,8 +1,4 @@
using System; namespace Microsoft.eShopOnContainers.Services.Identity.API.Extensions
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.eShopOnContainers.Services.Identity.API.Extensions
{ {
public static class LinqSelectExtensions public static class LinqSelectExtensions
{ {

View File

@ -1,10 +1,4 @@
using Microsoft.EntityFrameworkCore; namespace Identity.API.Factories
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.eShopOnContainers.Services.Identity.API.Data;
using Microsoft.Extensions.Configuration;
using System.IO;
namespace Identity.API.Factories
{ {
public class ApplicationDbContextFactory : IDesignTimeDbContextFactory<ApplicationDbContext> public class ApplicationDbContextFactory : IDesignTimeDbContextFactory<ApplicationDbContext>
{ {

View File

@ -1,11 +1,4 @@
using IdentityServer4.EntityFramework.DbContexts; namespace Identity.API.Factories
using IdentityServer4.EntityFramework.Options;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
using System.IO;
namespace Identity.API.Factories
{ {
public class ConfigurationDbContextFactory : IDesignTimeDbContextFactory<ConfigurationDbContext> public class ConfigurationDbContextFactory : IDesignTimeDbContextFactory<ConfigurationDbContext>
{ {

View File

@ -1,11 +1,4 @@
using IdentityServer4.EntityFramework.DbContexts; namespace Identity.API.Factories
using IdentityServer4.EntityFramework.Options;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
using System.IO;
namespace Identity.API.Factories
{ {
public class PersistedGrantDbContextFactory : IDesignTimeDbContextFactory<PersistedGrantDbContext> public class PersistedGrantDbContextFactory : IDesignTimeDbContextFactory<PersistedGrantDbContext>
{ {

View File

@ -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;

View File

@ -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 namespace Microsoft.AspNetCore.Hosting
{ {
public static class IWebHostExtensions public static class IWebHostExtensions

View File

@ -30,16 +30,16 @@
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" /> <PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.16.0" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.3" /> <PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.3" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="5.0.2" /> <PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="5.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="5.0.2" /> <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="6.0.0-preview.7.21378.6" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" /> <PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.2" /> <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.0-preview.7.21378.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.2"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0-preview.7.21378.4">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.2" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.0-preview.7.21378.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.2" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0-preview.7.21378.4" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="5.0.2" /> <PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="5.0.2" />
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.1.113" /> <PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.1.113" />
<PackageReference Include="Polly" Version="7.2.1" /> <PackageReference Include="Polly" Version="7.2.1" />

View File

@ -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 public partial class InitialMigration : Migration
{ {

View File

@ -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 public record ConsentInputModel
{ {

View File

@ -1,12 +1,8 @@
using IdentityServer4.Models; namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
{ {
public record ConsentViewModel : ConsentInputModel 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; RememberConsent = model?.RememberConsent ?? true;
ScopesConsented = model?.ScopesConsented ?? Enumerable.Empty<string>(); ScopesConsented = model?.ScopesConsented ?? Enumerable.Empty<string>();
@ -43,7 +39,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewMo
Checked = check || scope.Required; Checked = check || scope.Required;
} }
public ScopeViewModel(IdentityResource identity, bool check) public ScopeViewModel(IdentityServer4.Models.IdentityResource identity, bool check)
{ {
Name = identity.Name; Name = identity.Name;
DisplayName = identity.DisplayName; DisplayName = identity.DisplayName;

View File

@ -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 public record ForgotPasswordViewModel
{ {

View File

@ -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 public record LoginViewModel
{ {

View File

@ -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 public record RegisterViewModel
{ {

View File

@ -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 public record ResetPasswordViewModel
{ {

View File

@ -1,7 +1,4 @@
using Microsoft.AspNetCore.Mvc.Rendering; namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
using System.Collections.Generic;
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
{ {
public record SendCodeViewModel public record SendCodeViewModel
{ {

View File

@ -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 public record VerifyCodeViewModel
{ {

View File

@ -1,7 +1,4 @@
using Microsoft.AspNetCore.Identity; namespace Microsoft.eShopOnContainers.Services.Identity.API.Models
using System.ComponentModel.DataAnnotations;
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models
{ {
// Add profile data for application users by adding properties to the ApplicationUser class // Add profile data for application users by adding properties to the ApplicationUser class
public class ApplicationUser : IdentityUser public class ApplicationUser : IdentityUser

View File

@ -1,9 +1,5 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved. // 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. // 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 namespace Microsoft.eShopOnContainers.Services.Identity.API.Models
{ {
public record ErrorViewModel public record ErrorViewModel

View File

@ -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 public record AddPhoneNumberViewModel
{ {

View File

@ -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 public record ChangePasswordViewModel
{ {

View File

@ -1,7 +1,4 @@
using Microsoft.AspNetCore.Mvc.Rendering; namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels
using System.Collections.Generic;
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels
{ {
public record ConfigureTwoFactorViewModel public record ConfigureTwoFactorViewModel
{ {

View File

@ -1,7 +1,4 @@
using Microsoft.AspNetCore.Identity; namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels
using System.Collections.Generic;
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels
{ {
public record IndexViewModel public record IndexViewModel
{ {

View File

@ -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 public record SetPasswordViewModel
{ {

View File

@ -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 public record VerifyPhoneNumberViewModel
{ {

View File

@ -1,20 +1,4 @@
using IdentityServer4.EntityFramework.DbContexts; string Namespace = typeof(Startup).Namespace;
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 AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1); string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1);
var configuration = GetConfiguration(); var configuration = GetConfiguration();

View File

@ -1,9 +1,4 @@
using Microsoft.AspNetCore.Authentication; namespace Microsoft.eShopOnContainers.Services.Identity.API.Services
using Microsoft.AspNetCore.Identity;
using Microsoft.eShopOnContainers.Services.Identity.API.Models;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Identity.API.Services
{ {
public class EFLoginService : ILoginService<ApplicationUser> public class EFLoginService : ILoginService<ApplicationUser>
{ {

View File

@ -1,7 +1,4 @@
using Microsoft.AspNetCore.Authentication; namespace Microsoft.eShopOnContainers.Services.Identity.API.Services
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Identity.API.Services
{ {
public interface ILoginService<T> public interface ILoginService<T>
{ {

View File

@ -1,16 +1,4 @@
using IdentityModel; namespace Microsoft.eShopOnContainers.Services.Identity.API.Services
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
{ {
public class ProfileService : IProfileService public class ProfileService : IProfileService
{ {

View File

@ -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 public class RedirectService : IRedirectService
{ {

View File

@ -1,28 +1,4 @@
using Autofac; namespace Microsoft.eShopOnContainers.Services.Identity.API
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
{ {
public class Startup public class Startup
{ {
@ -112,7 +88,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API
services.AddRazorPages(); services.AddRazorPages();
var container = new ContainerBuilder(); var container = new ContainerBuilder();
container.Populate(services); container.Populate(services);
return new AutofacServiceProvider(container.Build()); return new AutofacServiceProvider(container.Build());
} }
@ -132,12 +108,12 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API
else else
{ {
app.UseExceptionHandler("/Home/Error"); app.UseExceptionHandler("/Home/Error");
} }
var pathBase = Configuration["PATH_BASE"]; var pathBase = Configuration["PATH_BASE"];
if (!string.IsNullOrEmpty(pathBase)) if (!string.IsNullOrEmpty(pathBase))
{ {
loggerFactory.CreateLogger<Startup>().LogDebug("Using PATH BASE '{pathBase}'", pathBase); //loggerFactory.CreateLogger<Startup>().LogDebug("Using PATH BASE '{pathBase}'", pathBase);
app.UsePathBase(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. // To avoid this problem, the policy of cookies shold be in Lax mode.
app.UseCookiePolicy(new CookiePolicyOptions { MinimumSameSitePolicy = AspNetCore.Http.SameSiteMode.Lax }); app.UseCookiePolicy(new CookiePolicyOptions { MinimumSameSitePolicy = AspNetCore.Http.SameSiteMode.Lax });
app.UseRouting(); app.UseRouting();
app.UseEndpoints(endpoints => app.UseEndpoints(endpoints =>
{ {
endpoints.MapDefaultControllerRoute(); endpoints.MapDefaultControllerRoute();