Browse Source

Included global usings for identity project

pull/1755/head
Sumit Ghosh 3 years ago
parent
commit
b678bdd11a
40 changed files with 271 additions and 295 deletions
  1. +1
    -5
      src/Services/Identity/Identity.API/Certificate/Certificate.cs
  2. +33
    -36
      src/Services/Identity/Identity.API/Configuration/Config.cs
  3. +1
    -20
      src/Services/Identity/Identity.API/Controllers/AccountController.cs
  4. +1
    -10
      src/Services/Identity/Identity.API/Controllers/ConsentController.cs
  5. +1
    -9
      src/Services/Identity/Identity.API/Controllers/HomeController.cs
  6. +1
    -5
      src/Services/Identity/Identity.API/Data/ApplicationDbContext.cs
  7. +3
    -17
      src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs
  8. +1
    -11
      src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs
  9. +3
    -9
      src/Services/Identity/Identity.API/Devspaces/DevspacesRedirectUriValidator.cs
  10. +1
    -3
      src/Services/Identity/Identity.API/Devspaces/IdentityDevspacesBuilderExtensions.cs
  11. +1
    -5
      src/Services/Identity/Identity.API/Extensions/LinqSelectExtensions.cs
  12. +1
    -7
      src/Services/Identity/Identity.API/Factories/ApplicationDbContextFactory.cs
  13. +1
    -8
      src/Services/Identity/Identity.API/Factories/ConfigurationDbContextFactory.cs
  14. +1
    -8
      src/Services/Identity/Identity.API/Factories/PersistedGrantDbContextFactory.cs
  15. +185
    -0
      src/Services/Identity/Identity.API/GlobalUsings.cs
  16. +0
    -8
      src/Services/Identity/Identity.API/IWebHostExtensions.cs
  17. +5
    -5
      src/Services/Identity/Identity.API/Identity.API.csproj
  18. +4
    -1
      src/Services/Identity/Identity.API/Migrations/ConfigurationDb/20210813072543_InitialMigration.cs
  19. +1
    -3
      src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentInputModel.cs
  20. +3
    -7
      src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentViewModel.cs
  21. +1
    -3
      src/Services/Identity/Identity.API/Models/AccountViewModels/ForgotPasswordViewModel.cs
  22. +1
    -3
      src/Services/Identity/Identity.API/Models/AccountViewModels/LoginViewModel.cs
  23. +1
    -3
      src/Services/Identity/Identity.API/Models/AccountViewModels/RegisterViewModel.cs
  24. +1
    -3
      src/Services/Identity/Identity.API/Models/AccountViewModels/ResetPasswordViewModel.cs
  25. +1
    -4
      src/Services/Identity/Identity.API/Models/AccountViewModels/SendCodeViewModel.cs
  26. +1
    -3
      src/Services/Identity/Identity.API/Models/AccountViewModels/VerifyCodeViewModel.cs
  27. +1
    -4
      src/Services/Identity/Identity.API/Models/ApplicationUser.cs
  28. +0
    -4
      src/Services/Identity/Identity.API/Models/ErrorViewModel.cs
  29. +1
    -3
      src/Services/Identity/Identity.API/Models/ManageViewModels/AddPhoneNumberViewModel.cs
  30. +1
    -3
      src/Services/Identity/Identity.API/Models/ManageViewModels/ChangePasswordViewModel.cs
  31. +1
    -4
      src/Services/Identity/Identity.API/Models/ManageViewModels/ConfigureTwoFactorViewModel.cs
  32. +1
    -4
      src/Services/Identity/Identity.API/Models/ManageViewModels/IndexViewModel.cs
  33. +1
    -3
      src/Services/Identity/Identity.API/Models/ManageViewModels/SetPasswordViewModel.cs
  34. +1
    -3
      src/Services/Identity/Identity.API/Models/ManageViewModels/VerifyPhoneNumberViewModel.cs
  35. +1
    -17
      src/Services/Identity/Identity.API/Program.cs
  36. +1
    -6
      src/Services/Identity/Identity.API/Services/EFLoginService.cs
  37. +1
    -4
      src/Services/Identity/Identity.API/Services/ILoginService.cs
  38. +1
    -13
      src/Services/Identity/Identity.API/Services/ProfileService.cs
  39. +1
    -3
      src/Services/Identity/Identity.API/Services/RedirectService.cs
  40. +5
    -28
      src/Services/Identity/Identity.API/Startup.cs

+ 1
- 5
src/Services/Identity/Identity.API/Certificate/Certificate.cs View File

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


+ 33
- 36
src/Services/Identity/Identity.API/Configuration/Config.cs View File

@ -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<ApiResource> GetApis()
{
return new List<ApiResource>
public static IEnumerable<IdentityServer4.Models.ApiResource> GetApis()
{
return new List<IdentityServer4.Models.ApiResource>
{
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<IdentityResource> GetResources()
public static IEnumerable<IdentityServer4.Models.IdentityResource> GetResources()
{
return new List<IdentityResource>
return new List<IdentityServer4.Models.IdentityResource>
{
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<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
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<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
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<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
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<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
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",


+ 1
- 20
src/Services/Identity/Identity.API/Controllers/AccountController.cs View File

@ -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
{
/// <summary>
/// This sample controller implements a typical login/logout/provision workflow for local accounts.


+ 1
- 10
src/Services/Identity/Identity.API/Controllers/ConsentController.cs View File

@ -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
{
/// <summary>
/// This controller implements the consent logic


+ 1
- 9
src/Services/Identity/Identity.API/Controllers/HomeController.cs View File

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


+ 1
- 5
src/Services/Identity/Identity.API/Data/ApplicationDbContext.cs View File

@ -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<ApplicationUser>
{


+ 3
- 17
src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs View File

@ -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<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");
@ -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
{


+ 1
- 11
src/Services/Identity/Identity.API/Data/ConfigurationDbContextSeed.cs View File

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


+ 3
- 9
src/Services/Identity/Identity.API/Devspaces/DevspacesRedirectUriValidator.cs 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
{
public class DevspacesRedirectUriValidator : IRedirectUriValidator
{
private readonly ILogger _logger;
private readonly Microsoft.Extensions.Logging.ILogger _logger;
public DevspacesRedirectUriValidator(ILogger<DevspacesRedirectUriValidator> 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);
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);
return Task.FromResult(true);


+ 1
- 3
src/Services/Identity/Identity.API/Devspaces/IdentityDevspacesBuilderExtensions.cs 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
{


+ 1
- 5
src/Services/Identity/Identity.API/Extensions/LinqSelectExtensions.cs View File

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


+ 1
- 7
src/Services/Identity/Identity.API/Factories/ApplicationDbContextFactory.cs View File

@ -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<ApplicationDbContext>
{


+ 1
- 8
src/Services/Identity/Identity.API/Factories/ConfigurationDbContextFactory.cs View File

@ -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<ConfigurationDbContext>
{


+ 1
- 8
src/Services/Identity/Identity.API/Factories/PersistedGrantDbContextFactory.cs View File

@ -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<PersistedGrantDbContext>
{


+ 185
- 0
src/Services/Identity/Identity.API/GlobalUsings.cs 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;

+ 0
- 8
src/Services/Identity/Identity.API/IWebHostExtensions.cs 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
{
public static class IWebHostExtensions


+ 5
- 5
src/Services/Identity/Identity.API/Identity.API.csproj View File

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


+ 4
- 1
src/Services/Identity/Identity.API/Migrations/ConfigurationDb/20210813072543_InitialMigration.cs 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
{


+ 1
- 3
src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentInputModel.cs 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
{


+ 3
- 7
src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentViewModel.cs View File

@ -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<string>();
@ -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;


+ 1
- 3
src/Services/Identity/Identity.API/Models/AccountViewModels/ForgotPasswordViewModel.cs 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
{


+ 1
- 3
src/Services/Identity/Identity.API/Models/AccountViewModels/LoginViewModel.cs 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
{


+ 1
- 3
src/Services/Identity/Identity.API/Models/AccountViewModels/RegisterViewModel.cs 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
{


+ 1
- 3
src/Services/Identity/Identity.API/Models/AccountViewModels/ResetPasswordViewModel.cs 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
{


+ 1
- 4
src/Services/Identity/Identity.API/Models/AccountViewModels/SendCodeViewModel.cs View File

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


+ 1
- 3
src/Services/Identity/Identity.API/Models/AccountViewModels/VerifyCodeViewModel.cs 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
{


+ 1
- 4
src/Services/Identity/Identity.API/Models/ApplicationUser.cs View File

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


+ 0
- 4
src/Services/Identity/Identity.API/Models/ErrorViewModel.cs View File

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


+ 1
- 3
src/Services/Identity/Identity.API/Models/ManageViewModels/AddPhoneNumberViewModel.cs 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
{


+ 1
- 3
src/Services/Identity/Identity.API/Models/ManageViewModels/ChangePasswordViewModel.cs 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
{


+ 1
- 4
src/Services/Identity/Identity.API/Models/ManageViewModels/ConfigureTwoFactorViewModel.cs View File

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


+ 1
- 4
src/Services/Identity/Identity.API/Models/ManageViewModels/IndexViewModel.cs View File

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


+ 1
- 3
src/Services/Identity/Identity.API/Models/ManageViewModels/SetPasswordViewModel.cs 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
{


+ 1
- 3
src/Services/Identity/Identity.API/Models/ManageViewModels/VerifyPhoneNumberViewModel.cs 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
{


+ 1
- 17
src/Services/Identity/Identity.API/Program.cs View File

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


+ 1
- 6
src/Services/Identity/Identity.API/Services/EFLoginService.cs View File

@ -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<ApplicationUser>
{


+ 1
- 4
src/Services/Identity/Identity.API/Services/ILoginService.cs View File

@ -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<T>
{


+ 1
- 13
src/Services/Identity/Identity.API/Services/ProfileService.cs View File

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


+ 1
- 3
src/Services/Identity/Identity.API/Services/RedirectService.cs 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
{


+ 5
- 28
src/Services/Identity/Identity.API/Startup.cs View File

@ -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<Startup>().LogDebug("Using PATH BASE '{pathBase}'", pathBase);
//loggerFactory.CreateLogger<Startup>().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();


Loading…
Cancel
Save