├── .github └── workflows │ └── main.yml ├── .gitignore ├── Cookie-Based-Roles-Claims-MFA └── IdentityNetCore │ ├── Controllers │ ├── HomeController.cs │ └── IdentityController.cs │ ├── Data │ └── ApplicationDBContext.cs │ ├── IdentityNetCore.csproj │ ├── IdentityNetCore.sln │ ├── Migrations │ ├── 20191202035230_Init.Designer.cs │ ├── 20191202035230_Init.cs │ └── ApplicationDBContextModelSnapshot.cs │ ├── Models │ ├── ErrorViewModel.cs │ ├── MFAViewModel.cs │ ├── MNFACheckViewModel.cs │ ├── SigninViewModel.cs │ └── SignupViewModel.cs │ ├── Program.cs │ ├── Service │ ├── IEmailSender.cs │ ├── SmtpEmailSender.cs │ └── SmtpOptions.cs │ ├── Startup.cs │ ├── Views │ ├── Home │ │ ├── Admin.cshtml │ │ ├── Index.cshtml │ │ ├── Member.cshtml │ │ └── Privacy.cshtml │ ├── Identity │ │ ├── AccessDenied.cshtml │ │ ├── MFACheck.cshtml │ │ ├── MFASetup.cshtml │ │ ├── Signin.cshtml │ │ └── Signup.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _Identity.cshtml │ │ ├── _Layout.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ ├── css │ └── site.css │ ├── favicon.ico │ ├── js │ ├── qrcode.js │ └── site.js │ └── lib │ ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map ├── Cookie-Based-Roles-Claims └── IdentityNetCore │ ├── Controllers │ ├── HomeController.cs │ └── IdentityController.cs │ ├── Data │ └── ApplicationDBContext.cs │ ├── IdentityNetCore.csproj │ ├── IdentityNetCore.sln │ ├── Migrations │ ├── 20191202035230_Init.Designer.cs │ ├── 20191202035230_Init.cs │ └── ApplicationDBContextModelSnapshot.cs │ ├── Models │ ├── ErrorViewModel.cs │ ├── SigninViewModel.cs │ └── SignupViewModel.cs │ ├── Program.cs │ ├── Service │ ├── IEmailSender.cs │ ├── SmtpEmailSender.cs │ └── SmtpOptions.cs │ ├── Startup.cs │ ├── Views │ ├── Home │ │ ├── Admin.cshtml │ │ ├── Index.cshtml │ │ ├── Member.cshtml │ │ └── Privacy.cshtml │ ├── Identity │ │ ├── AccessDenied.cshtml │ │ ├── Signin.cshtml │ │ └── Signup.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _Identity.cshtml │ │ ├── _Layout.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ ├── css │ └── site.css │ ├── favicon.ico │ ├── js │ └── site.js │ └── lib │ ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map ├── Cookie-Based-Roles └── IdentityNetCore │ ├── Controllers │ ├── HomeController.cs │ └── IdentityController.cs │ ├── Data │ └── ApplicationDBContext.cs │ ├── IdentityNetCore.csproj │ ├── IdentityNetCore.sln │ ├── Migrations │ ├── 20191202035230_Init.Designer.cs │ ├── 20191202035230_Init.cs │ └── ApplicationDBContextModelSnapshot.cs │ ├── Models │ ├── ErrorViewModel.cs │ ├── SigninViewModel.cs │ └── SignupViewModel.cs │ ├── Program.cs │ ├── Service │ ├── IEmailSender.cs │ ├── SmtpEmailSender.cs │ └── SmtpOptions.cs │ ├── Startup.cs │ ├── Views │ ├── Home │ │ ├── Admin.cshtml │ │ ├── Index.cshtml │ │ ├── Member.cshtml │ │ └── Privacy.cshtml │ ├── Identity │ │ ├── AccessDenied.cshtml │ │ ├── Signin.cshtml │ │ └── Signup.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _Identity.cshtml │ │ ├── _Layout.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ ├── css │ └── site.css │ ├── favicon.ico │ ├── js │ └── site.js │ └── lib │ ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map ├── Cookie-Based └── IdentityNetCore │ ├── Controllers │ ├── HomeController.cs │ └── IdentityController.cs │ ├── Data │ └── ApplicationDBContext.cs │ ├── IdentityNetCore.csproj │ ├── IdentityNetCore.sln │ ├── Migrations │ ├── 20191202035230_Init.Designer.cs │ ├── 20191202035230_Init.cs │ └── ApplicationDBContextModelSnapshot.cs │ ├── Models │ ├── ErrorViewModel.cs │ ├── SigninViewModel.cs │ └── SignupViewModel.cs │ ├── Program.cs │ ├── Service │ ├── IEmailSender.cs │ ├── SmtpEmailSender.cs │ └── SmtpOptions.cs │ ├── Startup.cs │ ├── Views │ ├── Home │ │ ├── Admin.cshtml │ │ ├── Index.cshtml │ │ ├── Member.cshtml │ │ └── Privacy.cshtml │ ├── Identity │ │ ├── Signin.cshtml │ │ └── Signup.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _Layout.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ ├── css │ └── site.css │ ├── favicon.ico │ ├── js │ └── site.js │ └── lib │ ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map ├── Facebook-Auth └── Facebook-Auth │ └── IdentityNetCore │ ├── Controllers │ ├── HomeController.cs │ └── IdentityController.cs │ ├── Data │ └── ApplicationDBContext.cs │ ├── IdentityNetCore.csproj │ ├── IdentityNetCore.sln │ ├── Migrations │ ├── 20191202035230_Init.Designer.cs │ ├── 20191202035230_Init.cs │ └── ApplicationDBContextModelSnapshot.cs │ ├── Models │ ├── ErrorViewModel.cs │ ├── SigninViewModel.cs │ └── SignupViewModel.cs │ ├── Program.cs │ ├── Service │ ├── IEmailSender.cs │ ├── SmtpEmailSender.cs │ └── SmtpOptions.cs │ ├── Startup.cs │ ├── Views │ ├── Home │ │ ├── Admin.cshtml │ │ ├── Index.cshtml │ │ ├── Member.cshtml │ │ └── Privacy.cshtml │ ├── Identity │ │ ├── Signin.cshtml │ │ └── Signup.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _Layout.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ ├── css │ └── site.css │ ├── favicon.ico │ ├── js │ └── site.js │ └── lib │ ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map ├── README.md ├── Starter └── IdentityNetCore │ ├── Controllers │ └── HomeController.cs │ ├── IdentityNetCore.csproj │ ├── IdentityNetCore.sln │ ├── Models │ └── ErrorViewModel.cs │ ├── Program.cs │ ├── Startup.cs │ ├── Views │ ├── Home │ │ ├── Admin.cshtml │ │ ├── Index.cshtml │ │ ├── Member.cshtml │ │ └── Privacy.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _Layout.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ ├── css │ └── site.css │ ├── favicon.ico │ ├── js │ └── site.js │ └── lib │ ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map └── Token-Basewd-Web-API └── IdentityNetCore ├── Controllers ├── ApiSecurityController.cs ├── HomeController.cs ├── IdentityController.cs └── ProductsController.cs ├── Data └── ApplicationDBContext.cs ├── IdentityNetCore.csproj ├── IdentityNetCore.sln ├── Migrations ├── 20191202035230_Init.Designer.cs ├── 20191202035230_Init.cs └── ApplicationDBContextModelSnapshot.cs ├── Models ├── ErrorViewModel.cs ├── Product.cs ├── SigninViewModel.cs └── SignupViewModel.cs ├── Program.cs ├── Service ├── IEmailSender.cs ├── SmtpEmailSender.cs └── SmtpOptions.cs ├── Startup.cs ├── Views ├── Home │ ├── Admin.cshtml │ ├── Index.cshtml │ ├── Member.cshtml │ └── Privacy.cshtml ├── Identity │ ├── Signin.cshtml │ └── Signup.cshtml ├── Shared │ ├── Error.cshtml │ ├── _Layout.cshtml │ └── _ValidationScriptsPartial.cshtml ├── _ViewImports.cshtml └── _ViewStart.cshtml ├── appsettings.Development.json ├── appsettings.json └── wwwroot ├── css └── site.css ├── favicon.ico ├── js └── site.js └── lib ├── bootstrap ├── LICENSE └── dist │ ├── css │ ├── bootstrap-grid.css │ ├── bootstrap-grid.css.map │ ├── bootstrap-grid.min.css │ ├── bootstrap-grid.min.css.map │ ├── bootstrap-reboot.css │ ├── bootstrap-reboot.css.map │ ├── bootstrap-reboot.min.css │ ├── bootstrap-reboot.min.css.map │ ├── bootstrap.css │ ├── bootstrap.css.map │ ├── bootstrap.min.css │ └── bootstrap.min.css.map │ └── js │ ├── bootstrap.bundle.js │ ├── bootstrap.bundle.js.map │ ├── bootstrap.bundle.min.js │ ├── bootstrap.bundle.min.js.map │ ├── bootstrap.js │ ├── bootstrap.js.map │ ├── bootstrap.min.js │ └── bootstrap.min.js.map ├── jquery-validation-unobtrusive ├── LICENSE.txt ├── jquery.validate.unobtrusive.js └── jquery.validate.unobtrusive.min.js ├── jquery-validation ├── LICENSE.md └── dist │ ├── additional-methods.js │ ├── additional-methods.min.js │ ├── jquery.validate.js │ └── jquery.validate.min.js └── jquery ├── LICENSE.txt └── dist ├── jquery.js ├── jquery.min.js └── jquery.min.map /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@master 12 | - uses: actions/setup-dotnet@v1 13 | with: 14 | dotnet-version: '3.0.101' # SDK Version to use. 15 | - run: dotnet build 16 | 17 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.Extensions.Logging; 8 | using IdentityNetCore.Models; 9 | using Microsoft.AspNetCore.Authorization; 10 | 11 | namespace IdentityNetCore.Controllers 12 | { 13 | public class HomeController : Controller 14 | { 15 | private readonly ILogger _logger; 16 | 17 | public HomeController(ILogger logger) 18 | { 19 | _logger = logger; 20 | } 21 | 22 | public IActionResult Index() 23 | { 24 | return View(); 25 | } 26 | 27 | [Authorize] 28 | public IActionResult Member() 29 | { 30 | return View(); 31 | } 32 | 33 | [Authorize] 34 | public IActionResult Admin() 35 | { 36 | return View(); 37 | } 38 | 39 | 40 | public IActionResult Privacy() 41 | { 42 | return View(); 43 | } 44 | 45 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 46 | public IActionResult Error() 47 | { 48 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Data/ApplicationDBContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore; 3 | 4 | namespace IdentityNetCore.Data 5 | { 6 | public class ApplicationDBContext : IdentityDbContext 7 | { 8 | public ApplicationDBContext() 9 | { } 10 | 11 | public ApplicationDBContext(DbContextOptions options) : base(options) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/IdentityNetCore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | runtime; build; native; contentfiles; analyzers; buildtransitive 13 | all 14 | 15 | 16 | 17 | all 18 | runtime; build; native; contentfiles; analyzers; buildtransitive 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/IdentityNetCore.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29519.87 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityNetCore", "IdentityNetCore.csproj", "{3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {0C239C2B-365F-4A1F-8675-03185FF7E083} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Models/MFAViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class MFAViewModel 6 | { 7 | [Required] 8 | public string Token { get; set; } 9 | 10 | [Required] 11 | public string Code { get; set; } 12 | 13 | public string QRCodeUrl { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Models/MNFACheckViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class MNFACheckViewModel 6 | { 7 | [Required] 8 | public string Code { get; set; } 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Models/SigninViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class SigninViewModel 6 | { 7 | [Required(ErrorMessage ="User nanme must be provided.")] 8 | [DataType(DataType.EmailAddress)] 9 | public string Username { get; set; } 10 | 11 | [Required(ErrorMessage ="Password must be provided.")] 12 | [DataType(DataType.Password)] 13 | public string Password { get; set; } 14 | public bool RememberMe { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Models/SignupViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class SignupViewModel 6 | { 7 | [Required] 8 | [DataType(DataType.EmailAddress, ErrorMessage ="Email address is missing or invalid.")] 9 | public string Email { get; set; } 10 | 11 | [Required] 12 | [DataType(DataType.Password, ErrorMessage ="Incorrect or missing password.")] 13 | public string Password { get; set; } 14 | 15 | [Required] 16 | public string Role { get; set; } 17 | 18 | [Required] 19 | public string Department { get; set; } 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace IdentityNetCore 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Service/IEmailSender.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace IdentityNetCore.Service 4 | { 5 | public interface IEmailSender 6 | { 7 | Task SendEmailAsync(string fromAddress, string toAddress, string subject, string message); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Service/SmtpEmailSender.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Options; 2 | using System.Net; 3 | using System.Net.Mail; 4 | using System.Threading.Tasks; 5 | 6 | namespace IdentityNetCore.Service 7 | { 8 | public class SmtpEmailSender : IEmailSender 9 | { 10 | private readonly IOptions options; 11 | 12 | public SmtpEmailSender(IOptions options) 13 | { 14 | this.options = options; 15 | } 16 | public async Task SendEmailAsync(string fromAddress, string toAddress, string subject, string message) 17 | { 18 | var mailMessage = new MailMessage(fromAddress, toAddress, subject, message); 19 | using (var client = new SmtpClient(options.Value.Host, options.Value.Port) 20 | { 21 | Credentials = new NetworkCredential(options.Value.Username, options.Value.Password) 22 | }) 23 | { 24 | await client.SendMailAsync(mailMessage); 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Service/SmtpOptions.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace IdentityNetCore.Service 3 | { 4 | public class SmtpOptions 5 | { 6 | public string Host { get; set; } 7 | public string Username { get; set; } 8 | public string Password { get; set; } 9 | public int Port { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IdentityNetCore.Data; 3 | using Microsoft.AspNetCore.Builder; 4 | using Microsoft.AspNetCore.Hosting; 5 | using Microsoft.EntityFrameworkCore; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.DependencyInjection; 8 | using Microsoft.Extensions.Hosting; 9 | using Microsoft.AspNetCore.Identity; 10 | using IdentityNetCore.Service; 11 | 12 | namespace IdentityNetCore 13 | { 14 | public class Startup 15 | { 16 | public Startup(IConfiguration configuration) 17 | { 18 | Configuration = configuration; 19 | } 20 | 21 | public IConfiguration Configuration { get; } 22 | 23 | // This method gets called by the runtime. Use this method to add services to the container. 24 | public void ConfigureServices(IServiceCollection services) 25 | { 26 | var connString = Configuration["ConnectionStrings:Default"]; 27 | services.AddDbContext(o => o.UseSqlServer(connString)); 28 | services.AddIdentity().AddEntityFrameworkStores().AddDefaultTokenProviders(); 29 | 30 | services.Configure(options => { 31 | 32 | options.Password.RequiredLength = 3; 33 | options.Password.RequireDigit = true; 34 | options.Password.RequireNonAlphanumeric = false; 35 | 36 | options.Lockout.MaxFailedAccessAttempts = 3; 37 | options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(10); 38 | 39 | options.SignIn.RequireConfirmedEmail = false; 40 | 41 | }); 42 | 43 | services.ConfigureApplicationCookie(option=> { 44 | option.LoginPath = "/Identity/Signin"; 45 | option.AccessDeniedPath = "/Identity/AccessDenied"; 46 | option.ExpireTimeSpan = TimeSpan.FromHours(10); 47 | }); 48 | 49 | services.Configure(Configuration.GetSection("Smtp")); 50 | 51 | services.AddSingleton(); 52 | services.AddAuthorization(option=> { 53 | 54 | option.AddPolicy("MemberDep", p=> { 55 | 56 | p.RequireClaim("Department", "Tech").RequireRole("Member"); 57 | }); 58 | 59 | option.AddPolicy("AdminDep", p => { 60 | 61 | p.RequireClaim("Department", "Tech").RequireRole("Admin"); 62 | }); 63 | }); 64 | services.AddControllersWithViews(); 65 | } 66 | 67 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 68 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 69 | { 70 | if (env.IsDevelopment()) 71 | { 72 | app.UseDeveloperExceptionPage(); 73 | } 74 | else 75 | { 76 | app.UseExceptionHandler("/Home/Error"); 77 | } 78 | app.UseStaticFiles(); 79 | 80 | app.UseRouting(); 81 | 82 | app.UseAuthentication(); 83 | app.UseAuthorization(); 84 | 85 | app.UseEndpoints(endpoints => 86 | { 87 | endpoints.MapControllerRoute( 88 | name: "default", 89 | pattern: "{controller=Home}/{action=Index}/{id?}"); 90 | }); 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Views/Home/Admin.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Member"; 4 | } 5 | 6 | 9 |
10 | Go Back 11 |
12 | 13 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
6 |

Welcome to ASP.NET Core Identity Management

7 | 10 | 11 |
12 | Go to Admin Area 13 |
14 |
15 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Views/Home/Member.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Member"; 4 | } 5 | 6 | 9 | 10 |
11 | Go Back 12 |
13 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

@ViewData["Title"]

5 | 6 |

Use this page to detail your site's privacy policy.

7 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Views/Identity/AccessDenied.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "AccessDenied"; 4 | } 5 | 6 |

Access Denied

7 | 8 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Views/Identity/MFACheck.cshtml: -------------------------------------------------------------------------------- 1 | @model MNFACheckViewModel 2 | 3 |
4 | 5 |
6 | Enter Code: 7 |
8 | 9 |
-------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Views/Identity/MFASetup.cshtml: -------------------------------------------------------------------------------- 1 | @model MFAViewModel 2 | 3 |

4 | Please enter the code below in your authenticator application. 5 |

6 |

7 | @Model.Token 8 |

9 |

10 | Alternatively, scan the below QRCode with your mobile phone. 11 |

12 | 13 |
14 | 15 | 16 |
17 | 18 |
19 | Enter Code: 20 |
21 | 22 | 23 |
24 | 25 | @section Scripts 26 | { 27 | 28 | 31 | } -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Views/Identity/Signin.cshtml: -------------------------------------------------------------------------------- 1 | @model SigninViewModel 2 | 3 | @{ 4 | ViewData["Title"] = "Signin"; 5 | } 6 | 7 |
8 | 9 | @Html.ValidationSummary() 10 | 11 |
12 | 13 | 14 |
15 | 16 |
17 | 18 | 19 |
20 |
21 | Remember Me 22 |
23 | 24 | 25 |
26 | 27 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Views/Identity/Signup.cshtml: -------------------------------------------------------------------------------- 1 | @model SignupViewModel 2 | @{ 3 | ViewData["Title"] = "Signup"; 4 | var roles = new List() {"Member" , "Admin" }; 5 | } 6 | 7 |

Signup

8 | 9 |
10 | @Html.ValidationSummary() 11 | 12 |
13 | 14 | 15 |
16 | 17 |
18 | 19 | 20 |
21 | 22 |
23 | 24 | 25 |
26 | 27 |
28 | @Html.DropDownListFor(x => x.Role, roles.Select(s => new SelectListItem { Text = s, Value = s }), "Roles", null) 29 |
30 | 31 | 32 |
33 | 34 |
35 | If you already have an account, pelase sign in 36 |
37 | 38 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Views/Shared/_Identity.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | var loggedIn = User.Identity.IsAuthenticated; 3 | } 4 | 5 | @if (loggedIn) 6 | { 7 | 10 | 13 | } 14 | else 15 | { 16 | 19 | 20 | 23 | } 24 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - IdentityNetCore 7 | 8 | 9 | 10 | 11 |
12 | 26 |
27 |
28 |
29 | @RenderBody() 30 |
31 |
32 | 33 |
34 |
35 | © 2019 - IdentityNetCore - Privacy 36 |
37 |
38 | 39 | 40 | 41 | @RenderSection("Scripts", required: false) 42 | 43 | 44 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using IdentityNetCore 2 | @using IdentityNetCore.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "ConnectionStrings": { 10 | "Default": "Data Source=database.jxtnest.local;Database=AspnetIdentityV2;User ID=admin;Password=Sankimsan1" 11 | }, 12 | "Smtp": { 13 | "Host": "in-v3.mailjet.com", 14 | "Username": "8842993ba6d9d0065e16d718430ddb9a", 15 | "Password": "da9782bab0f04afbd01f6e130c131f44", 16 | "Port": 25 17 | }, 18 | "AllowedHosts": "*" 19 | } 20 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aussiearef/asp-net-core-identity-old/851f90cc2c9cf96d43cf605fb3a360354353876c/Cookie-Based-Roles-Claims-MFA/IdentityNetCore/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims-MFA/IdentityNetCore/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.Extensions.Logging; 8 | using IdentityNetCore.Models; 9 | using Microsoft.AspNetCore.Authorization; 10 | 11 | namespace IdentityNetCore.Controllers 12 | { 13 | public class HomeController : Controller 14 | { 15 | private readonly ILogger _logger; 16 | 17 | public HomeController(ILogger logger) 18 | { 19 | _logger = logger; 20 | } 21 | 22 | public IActionResult Index() 23 | { 24 | return View(); 25 | } 26 | 27 | [Authorize(Policy = "MemberDep")] 28 | public IActionResult Member() 29 | { 30 | return View(); 31 | } 32 | 33 | [Authorize(Policy ="AdminDep")] 34 | public IActionResult Admin() 35 | { 36 | return View(); 37 | } 38 | 39 | 40 | public IActionResult Privacy() 41 | { 42 | return View(); 43 | } 44 | 45 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 46 | public IActionResult Error() 47 | { 48 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Data/ApplicationDBContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore; 3 | 4 | namespace IdentityNetCore.Data 5 | { 6 | public class ApplicationDBContext : IdentityDbContext 7 | { 8 | public ApplicationDBContext() 9 | { } 10 | 11 | public ApplicationDBContext(DbContextOptions options) : base(options) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/IdentityNetCore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | runtime; build; native; contentfiles; analyzers; buildtransitive 13 | all 14 | 15 | 16 | 17 | all 18 | runtime; build; native; contentfiles; analyzers; buildtransitive 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/IdentityNetCore.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29519.87 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityNetCore", "IdentityNetCore.csproj", "{3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {0C239C2B-365F-4A1F-8675-03185FF7E083} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Models/SigninViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class SigninViewModel 6 | { 7 | [Required(ErrorMessage ="User nanme must be provided.")] 8 | [DataType(DataType.EmailAddress)] 9 | public string Username { get; set; } 10 | 11 | [Required(ErrorMessage ="Password must be provided.")] 12 | [DataType(DataType.Password)] 13 | public string Password { get; set; } 14 | public bool RememberMe { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Models/SignupViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class SignupViewModel 6 | { 7 | [Required] 8 | [DataType(DataType.EmailAddress, ErrorMessage ="Email address is missing or invalid.")] 9 | public string Email { get; set; } 10 | 11 | [Required] 12 | [DataType(DataType.Password, ErrorMessage ="Incorrect or missing password.")] 13 | public string Password { get; set; } 14 | 15 | [Required] 16 | public string Role { get; set; } 17 | 18 | [Required] 19 | public string Department { get; set; } 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace IdentityNetCore 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Service/IEmailSender.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace IdentityNetCore.Service 4 | { 5 | public interface IEmailSender 6 | { 7 | Task SendEmailAsync(string fromAddress, string toAddress, string subject, string message); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Service/SmtpEmailSender.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Options; 2 | using System.Net; 3 | using System.Net.Mail; 4 | using System.Threading.Tasks; 5 | 6 | namespace IdentityNetCore.Service 7 | { 8 | public class SmtpEmailSender : IEmailSender 9 | { 10 | private readonly IOptions options; 11 | 12 | public SmtpEmailSender(IOptions options) 13 | { 14 | this.options = options; 15 | } 16 | public async Task SendEmailAsync(string fromAddress, string toAddress, string subject, string message) 17 | { 18 | var mailMessage = new MailMessage(fromAddress, toAddress, subject, message); 19 | using (var client = new SmtpClient(options.Value.Host, options.Value.Port) 20 | { 21 | Credentials = new NetworkCredential(options.Value.Username, options.Value.Password) 22 | }) 23 | { 24 | await client.SendMailAsync(mailMessage); 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Service/SmtpOptions.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace IdentityNetCore.Service 3 | { 4 | public class SmtpOptions 5 | { 6 | public string Host { get; set; } 7 | public string Username { get; set; } 8 | public string Password { get; set; } 9 | public int Port { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IdentityNetCore.Data; 3 | using Microsoft.AspNetCore.Builder; 4 | using Microsoft.AspNetCore.Hosting; 5 | using Microsoft.EntityFrameworkCore; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.DependencyInjection; 8 | using Microsoft.Extensions.Hosting; 9 | using Microsoft.AspNetCore.Identity; 10 | using IdentityNetCore.Service; 11 | 12 | namespace IdentityNetCore 13 | { 14 | public class Startup 15 | { 16 | public Startup(IConfiguration configuration) 17 | { 18 | Configuration = configuration; 19 | } 20 | 21 | public IConfiguration Configuration { get; } 22 | 23 | // This method gets called by the runtime. Use this method to add services to the container. 24 | public void ConfigureServices(IServiceCollection services) 25 | { 26 | var connString = Configuration["ConnectionStrings:Default"]; 27 | services.AddDbContext(o => o.UseSqlServer(connString)); 28 | services.AddIdentity().AddEntityFrameworkStores(); 29 | 30 | services.Configure(options => { 31 | 32 | options.Password.RequiredLength = 3; 33 | options.Password.RequireDigit = true; 34 | options.Password.RequireNonAlphanumeric = false; 35 | 36 | options.Lockout.MaxFailedAccessAttempts = 3; 37 | options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(10); 38 | 39 | options.SignIn.RequireConfirmedEmail = false; 40 | 41 | }); 42 | 43 | services.ConfigureApplicationCookie(option=> { 44 | option.LoginPath = "/Identity/Signin"; 45 | option.AccessDeniedPath = "/Identity/AccessDenied"; 46 | option.ExpireTimeSpan = TimeSpan.FromHours(10); 47 | }); 48 | 49 | services.Configure(Configuration.GetSection("Smtp")); 50 | 51 | services.AddSingleton(); 52 | services.AddAuthorization(option=> { 53 | 54 | option.AddPolicy("MemberDep", p=> { 55 | 56 | p.RequireClaim("Department", "Tech").RequireRole("Member"); 57 | }); 58 | 59 | option.AddPolicy("AdminDep", p => { 60 | 61 | p.RequireClaim("Department", "Tech").RequireRole("Admin"); 62 | }); 63 | }); 64 | services.AddControllersWithViews(); 65 | } 66 | 67 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 68 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 69 | { 70 | if (env.IsDevelopment()) 71 | { 72 | app.UseDeveloperExceptionPage(); 73 | } 74 | else 75 | { 76 | app.UseExceptionHandler("/Home/Error"); 77 | } 78 | app.UseStaticFiles(); 79 | 80 | app.UseRouting(); 81 | 82 | app.UseAuthentication(); 83 | app.UseAuthorization(); 84 | 85 | app.UseEndpoints(endpoints => 86 | { 87 | endpoints.MapControllerRoute( 88 | name: "default", 89 | pattern: "{controller=Home}/{action=Index}/{id?}"); 90 | }); 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Views/Home/Admin.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Member"; 4 | } 5 | 6 | 9 |
10 | Go Back 11 |
12 | 13 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
6 |

Welcome to ASP.NET Core Identity Management

7 | 10 | 11 |
12 | Go to Admin Area 13 |
14 |
15 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Views/Home/Member.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Member"; 4 | } 5 | 6 | 9 | 10 |
11 | Go Back 12 |
13 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

@ViewData["Title"]

5 | 6 |

Use this page to detail your site's privacy policy.

7 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Views/Identity/AccessDenied.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "AccessDenied"; 4 | } 5 | 6 |

Access Denied

7 | 8 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Views/Identity/Signin.cshtml: -------------------------------------------------------------------------------- 1 | @model SigninViewModel 2 | 3 | @{ 4 | ViewData["Title"] = "Signin"; 5 | } 6 | 7 |
8 | 9 | @Html.ValidationSummary() 10 | 11 |
12 | 13 | 14 |
15 | 16 |
17 | 18 | 19 |
20 |
21 | Remember Me 22 |
23 | 24 | 25 |
26 | 27 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Views/Identity/Signup.cshtml: -------------------------------------------------------------------------------- 1 | @model SignupViewModel 2 | @{ 3 | ViewData["Title"] = "Signup"; 4 | var roles = new List() {"Member" , "Admin" }; 5 | } 6 | 7 |

Signup

8 | 9 |
10 | @Html.ValidationSummary() 11 | 12 |
13 | 14 | 15 |
16 | 17 |
18 | 19 | 20 |
21 | 22 |
23 | 24 | 25 |
26 | 27 |
28 | @Html.DropDownListFor(x => x.Role, roles.Select(s => new SelectListItem { Text = s, Value = s }), "Roles", null) 29 |
30 | 31 | 32 |
33 | 34 |
35 | If you already have an account, pelase sign in 36 |
37 | 38 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Views/Shared/_Identity.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | var loggedIn = User.Identity.IsAuthenticated; 3 | } 4 | 5 | @if (loggedIn) 6 | { 7 | 10 | 13 | } 14 | else 15 | { 16 | 19 | 20 | 23 | } 24 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - IdentityNetCore 7 | 8 | 9 | 10 | 11 |
12 | 26 |
27 |
28 |
29 | @RenderBody() 30 |
31 |
32 | 33 |
34 |
35 | © 2019 - IdentityNetCore - Privacy 36 |
37 |
38 | 39 | 40 | 41 | @RenderSection("Scripts", required: false) 42 | 43 | 44 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using IdentityNetCore 2 | @using IdentityNetCore.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "ConnectionStrings": { 10 | "Default": "Data Source=database.jxtnest.local;Database=AspnetIdentityV2;User ID=admin;Password=Sankimsan1" 11 | }, 12 | "Smtp": { 13 | "Host": "in-v3.mailjet.com", 14 | "Username": "8842993ba6d9d0065e16d718430ddb9a", 15 | "Password": "da9782bab0f04afbd01f6e130c131f44", 16 | "Port": 25 17 | }, 18 | "AllowedHosts": "*" 19 | } 20 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aussiearef/asp-net-core-identity-old/851f90cc2c9cf96d43cf605fb3a360354353876c/Cookie-Based-Roles-Claims/IdentityNetCore/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Cookie-Based-Roles-Claims/IdentityNetCore/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.Extensions.Logging; 8 | using IdentityNetCore.Models; 9 | using Microsoft.AspNetCore.Authorization; 10 | 11 | namespace IdentityNetCore.Controllers 12 | { 13 | public class HomeController : Controller 14 | { 15 | private readonly ILogger _logger; 16 | 17 | public HomeController(ILogger logger) 18 | { 19 | _logger = logger; 20 | } 21 | 22 | public IActionResult Index() 23 | { 24 | return View(); 25 | } 26 | 27 | [Authorize(Roles ="Member")] 28 | public IActionResult Member() 29 | { 30 | return View(); 31 | } 32 | 33 | [Authorize(Roles ="Admin")] 34 | public IActionResult Admin() 35 | { 36 | return View(); 37 | } 38 | 39 | 40 | public IActionResult Privacy() 41 | { 42 | return View(); 43 | } 44 | 45 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 46 | public IActionResult Error() 47 | { 48 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Data/ApplicationDBContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore; 3 | 4 | namespace IdentityNetCore.Data 5 | { 6 | public class ApplicationDBContext : IdentityDbContext 7 | { 8 | public ApplicationDBContext() 9 | { } 10 | 11 | public ApplicationDBContext(DbContextOptions options) : base(options) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/IdentityNetCore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | runtime; build; native; contentfiles; analyzers; buildtransitive 13 | all 14 | 15 | 16 | 17 | all 18 | runtime; build; native; contentfiles; analyzers; buildtransitive 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/IdentityNetCore.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29519.87 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityNetCore", "IdentityNetCore.csproj", "{3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {0C239C2B-365F-4A1F-8675-03185FF7E083} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Models/SigninViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class SigninViewModel 6 | { 7 | [Required(ErrorMessage ="User nanme must be provided.")] 8 | [DataType(DataType.EmailAddress)] 9 | public string Username { get; set; } 10 | 11 | [Required(ErrorMessage ="Password must be provided.")] 12 | [DataType(DataType.Password)] 13 | public string Password { get; set; } 14 | public bool RememberMe { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Models/SignupViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class SignupViewModel 6 | { 7 | [Required] 8 | [DataType(DataType.EmailAddress, ErrorMessage ="Email address is missing or invalid.")] 9 | public string Email { get; set; } 10 | 11 | [Required] 12 | [DataType(DataType.Password, ErrorMessage ="Incorrect or missing password.")] 13 | public string Password { get; set; } 14 | 15 | [Required] 16 | public string Role { get; set; } 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace IdentityNetCore 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Service/IEmailSender.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace IdentityNetCore.Service 4 | { 5 | public interface IEmailSender 6 | { 7 | Task SendEmailAsync(string fromAddress, string toAddress, string subject, string message); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Service/SmtpEmailSender.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Options; 2 | using System.Net; 3 | using System.Net.Mail; 4 | using System.Threading.Tasks; 5 | 6 | namespace IdentityNetCore.Service 7 | { 8 | public class SmtpEmailSender : IEmailSender 9 | { 10 | private readonly IOptions options; 11 | 12 | public SmtpEmailSender(IOptions options) 13 | { 14 | this.options = options; 15 | } 16 | public async Task SendEmailAsync(string fromAddress, string toAddress, string subject, string message) 17 | { 18 | var mailMessage = new MailMessage(fromAddress, toAddress, subject, message); 19 | using (var client = new SmtpClient(options.Value.Host, options.Value.Port) 20 | { 21 | Credentials = new NetworkCredential(options.Value.Username, options.Value.Password) 22 | }) 23 | { 24 | await client.SendMailAsync(mailMessage); 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Service/SmtpOptions.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace IdentityNetCore.Service 3 | { 4 | public class SmtpOptions 5 | { 6 | public string Host { get; set; } 7 | public string Username { get; set; } 8 | public string Password { get; set; } 9 | public int Port { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IdentityNetCore.Data; 3 | using Microsoft.AspNetCore.Builder; 4 | using Microsoft.AspNetCore.Hosting; 5 | using Microsoft.EntityFrameworkCore; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.DependencyInjection; 8 | using Microsoft.Extensions.Hosting; 9 | using Microsoft.AspNetCore.Identity; 10 | using IdentityNetCore.Service; 11 | 12 | namespace IdentityNetCore 13 | { 14 | public class Startup 15 | { 16 | public Startup(IConfiguration configuration) 17 | { 18 | Configuration = configuration; 19 | } 20 | 21 | public IConfiguration Configuration { get; } 22 | 23 | // This method gets called by the runtime. Use this method to add services to the container. 24 | public void ConfigureServices(IServiceCollection services) 25 | { 26 | var connString = Configuration["ConnectionStrings:Default"]; 27 | services.AddDbContext(o => o.UseSqlServer(connString)); 28 | services.AddIdentity().AddEntityFrameworkStores(); 29 | 30 | services.Configure(options => { 31 | 32 | options.Password.RequiredLength = 3; 33 | options.Password.RequireDigit = true; 34 | options.Password.RequireNonAlphanumeric = false; 35 | 36 | options.Lockout.MaxFailedAccessAttempts = 3; 37 | options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(10); 38 | 39 | options.SignIn.RequireConfirmedEmail = false; 40 | 41 | }); 42 | 43 | services.ConfigureApplicationCookie(option=> { 44 | option.LoginPath = "/Identity/Signin"; 45 | option.AccessDeniedPath = "/Identity/AccessDenied"; 46 | option.ExpireTimeSpan = TimeSpan.FromHours(10); 47 | }); 48 | 49 | services.Configure(Configuration.GetSection("Smtp")); 50 | 51 | services.AddSingleton(); 52 | 53 | services.AddControllersWithViews(); 54 | } 55 | 56 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 57 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 58 | { 59 | if (env.IsDevelopment()) 60 | { 61 | app.UseDeveloperExceptionPage(); 62 | } 63 | else 64 | { 65 | app.UseExceptionHandler("/Home/Error"); 66 | } 67 | app.UseStaticFiles(); 68 | 69 | app.UseRouting(); 70 | 71 | app.UseAuthentication(); 72 | app.UseAuthorization(); 73 | 74 | app.UseEndpoints(endpoints => 75 | { 76 | endpoints.MapControllerRoute( 77 | name: "default", 78 | pattern: "{controller=Home}/{action=Index}/{id?}"); 79 | }); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Views/Home/Admin.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Member"; 4 | } 5 | 6 | 9 |
10 | Go Back 11 |
12 | 13 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
6 |

Welcome to ASP.NET Core Identity Management

7 | 10 | 11 |
12 | Go to Admin Area 13 |
14 |
15 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Views/Home/Member.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Member"; 4 | } 5 | 6 | 9 | 10 |
11 | Go Back 12 |
13 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

@ViewData["Title"]

5 | 6 |

Use this page to detail your site's privacy policy.

7 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Views/Identity/AccessDenied.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "AccessDenied"; 4 | } 5 | 6 |

Access Denied

7 | 8 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Views/Identity/Signin.cshtml: -------------------------------------------------------------------------------- 1 | @model SigninViewModel 2 | 3 | @{ 4 | ViewData["Title"] = "Signin"; 5 | } 6 | 7 |
8 | 9 | @Html.ValidationSummary() 10 | 11 |
12 | 13 | 14 |
15 | 16 |
17 | 18 | 19 |
20 |
21 | Remember Me 22 |
23 | 24 | 25 |
26 | 27 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Views/Identity/Signup.cshtml: -------------------------------------------------------------------------------- 1 | @model SignupViewModel 2 | @{ 3 | ViewData["Title"] = "Signup"; 4 | var roles = new List() {"Member" , "Admin" }; 5 | } 6 | 7 |

Signup

8 | 9 |
10 | @Html.ValidationSummary() 11 | 12 |
13 | 14 | 15 |
16 | 17 |
18 | 19 | 20 |
21 | 22 |
23 | @Html.DropDownListFor(x=> x.Role , roles.Select(s=> new SelectListItem {Text = s, Value = s }) , "Roles" , null) 24 |
25 | 26 | 27 |
28 | 29 |
30 | If you already have an account, pelase sign in 31 |
32 | 33 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Views/Shared/_Identity.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | var loggedIn = User.Identity.IsAuthenticated; 3 | } 4 | 5 | @if (loggedIn) 6 | { 7 | 10 | 13 | } 14 | else 15 | { 16 | 19 | 20 | 23 | } 24 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - IdentityNetCore 7 | 8 | 9 | 10 | 11 |
12 | 26 |
27 |
28 |
29 | @RenderBody() 30 |
31 |
32 | 33 |
34 |
35 | © 2019 - IdentityNetCore - Privacy 36 |
37 |
38 | 39 | 40 | 41 | @RenderSection("Scripts", required: false) 42 | 43 | 44 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using IdentityNetCore 2 | @using IdentityNetCore.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "ConnectionStrings": { 10 | "Default": "Data Source=database.jxtnest.local;Database=AspnetIdentityV2;User ID=admin;Password=Sankimsan1" 11 | }, 12 | "Smtp": { 13 | "Host": "in-v3.mailjet.com", 14 | "Username": "8842993ba6d9d0065e16d718430ddb9a", 15 | "Password": "da9782bab0f04afbd01f6e130c131f44", 16 | "Port": 25 17 | }, 18 | "AllowedHosts": "*" 19 | } 20 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aussiearef/asp-net-core-identity-old/851f90cc2c9cf96d43cf605fb3a360354353876c/Cookie-Based-Roles/IdentityNetCore/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Reboot v4.3.1 (https://getbootstrap.com/) 3 | * Copyright 2011-2019 The Bootstrap Authors 4 | * Copyright 2011-2019 Twitter, Inc. 5 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 6 | * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) 7 | */*,::after,::before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}[tabindex="-1"]:focus{outline:0!important}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;border-bottom:0;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#007bff;text-decoration:none;background-color:transparent}a:hover{color:#0056b3;text-decoration:underline}a:not([href]):not([tabindex]){color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus,a:not([href]):not([tabindex]):hover{color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus{outline:0}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em}pre{margin-top:0;margin-bottom:1rem;overflow:auto}figure{margin:0 0 1rem}img{vertical-align:middle;border-style:none}svg{overflow:hidden;vertical-align:middle}table{border-collapse:collapse}caption{padding-top:.75rem;padding-bottom:.75rem;color:#6c757d;text-align:left;caption-side:bottom}th{text-align:inherit}label{display:inline-block;margin-bottom:.5rem}button{border-radius:0}button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}select{word-wrap:normal}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=date],input[type=datetime-local],input[type=month],input[type=time]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;max-width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit;color:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item;cursor:pointer}template{display:none}[hidden]{display:none!important} 8 | /*# sourceMappingURL=bootstrap-reboot.min.css.map */ -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Cookie-Based-Roles/IdentityNetCore/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.Extensions.Logging; 8 | using IdentityNetCore.Models; 9 | using Microsoft.AspNetCore.Authorization; 10 | 11 | namespace IdentityNetCore.Controllers 12 | { 13 | public class HomeController : Controller 14 | { 15 | private readonly ILogger _logger; 16 | 17 | public HomeController(ILogger logger) 18 | { 19 | _logger = logger; 20 | } 21 | 22 | public IActionResult Index() 23 | { 24 | return View(); 25 | } 26 | 27 | [Authorize] 28 | public IActionResult Member() 29 | { 30 | return View(); 31 | } 32 | 33 | [Authorize] 34 | public IActionResult Admin() 35 | { 36 | return View(); 37 | } 38 | 39 | 40 | public IActionResult Privacy() 41 | { 42 | return View(); 43 | } 44 | 45 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 46 | public IActionResult Error() 47 | { 48 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Data/ApplicationDBContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore; 3 | 4 | namespace IdentityNetCore.Data 5 | { 6 | public class ApplicationDBContext : IdentityDbContext 7 | { 8 | public ApplicationDBContext() 9 | { } 10 | 11 | public ApplicationDBContext(DbContextOptions options) : base(options) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/IdentityNetCore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | runtime; build; native; contentfiles; analyzers; buildtransitive 13 | all 14 | 15 | 16 | 17 | all 18 | runtime; build; native; contentfiles; analyzers; buildtransitive 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/IdentityNetCore.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29519.87 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityNetCore", "IdentityNetCore.csproj", "{3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {0C239C2B-365F-4A1F-8675-03185FF7E083} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Models/SigninViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class SigninViewModel 6 | { 7 | [Required(ErrorMessage ="User nanme must be provided.")] 8 | [DataType(DataType.EmailAddress)] 9 | public string Username { get; set; } 10 | 11 | [Required(ErrorMessage ="Password must be provided.")] 12 | [DataType(DataType.Password)] 13 | public string Password { get; set; } 14 | public bool RememberMe { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Models/SignupViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class SignupViewModel 6 | { 7 | [Required] 8 | [DataType(DataType.EmailAddress, ErrorMessage ="Email address is missing or invalid.")] 9 | public string Email { get; set; } 10 | 11 | [Required] 12 | [DataType(DataType.Password, ErrorMessage ="Incorrect or missing password.")] 13 | public string Password { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace IdentityNetCore 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Service/IEmailSender.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace IdentityNetCore.Service 4 | { 5 | public interface IEmailSender 6 | { 7 | Task SendEmailAsync(string fromAddress, string toAddress, string subject, string message); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Service/SmtpEmailSender.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Options; 2 | using System.Net; 3 | using System.Net.Mail; 4 | using System.Threading.Tasks; 5 | 6 | namespace IdentityNetCore.Service 7 | { 8 | public class SmtpEmailSender : IEmailSender 9 | { 10 | private readonly IOptions options; 11 | 12 | public SmtpEmailSender(IOptions options) 13 | { 14 | this.options = options; 15 | } 16 | public async Task SendEmailAsync(string fromAddress, string toAddress, string subject, string message) 17 | { 18 | var mailMessage = new MailMessage(fromAddress, toAddress, subject, message); 19 | using (var client = new SmtpClient(options.Value.Host, options.Value.Port) 20 | { 21 | Credentials = new NetworkCredential(options.Value.Username, options.Value.Password) 22 | }) 23 | { 24 | await client.SendMailAsync(mailMessage); 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Service/SmtpOptions.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace IdentityNetCore.Service 3 | { 4 | public class SmtpOptions 5 | { 6 | public string Host { get; set; } 7 | public string Username { get; set; } 8 | public string Password { get; set; } 9 | public int Port { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IdentityNetCore.Data; 3 | using Microsoft.AspNetCore.Builder; 4 | using Microsoft.AspNetCore.Hosting; 5 | using Microsoft.EntityFrameworkCore; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.DependencyInjection; 8 | using Microsoft.Extensions.Hosting; 9 | using Microsoft.AspNetCore.Identity; 10 | using IdentityNetCore.Service; 11 | 12 | namespace IdentityNetCore 13 | { 14 | public class Startup 15 | { 16 | public Startup(IConfiguration configuration) 17 | { 18 | Configuration = configuration; 19 | } 20 | 21 | public IConfiguration Configuration { get; } 22 | 23 | // This method gets called by the runtime. Use this method to add services to the container. 24 | public void ConfigureServices(IServiceCollection services) 25 | { 26 | var connString = Configuration["ConnectionStrings:Default"]; 27 | services.AddDbContext(o => o.UseSqlServer(connString)); 28 | services.AddIdentity().AddEntityFrameworkStores(); 29 | 30 | services.Configure(options => { 31 | 32 | options.Password.RequiredLength = 3; 33 | options.Password.RequireDigit = true; 34 | options.Password.RequireNonAlphanumeric = false; 35 | 36 | options.Lockout.MaxFailedAccessAttempts = 3; 37 | options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(10); 38 | 39 | options.SignIn.RequireConfirmedEmail = true; 40 | 41 | }); 42 | 43 | services.ConfigureApplicationCookie(option=> { 44 | option.LoginPath = "/Identity/Signin"; 45 | option.AccessDeniedPath = "/Identity/AccessDenied"; 46 | option.ExpireTimeSpan = TimeSpan.FromHours(10); 47 | }); 48 | 49 | services.Configure(Configuration.GetSection("Smtp")); 50 | 51 | services.AddSingleton(); 52 | 53 | services.AddControllersWithViews(); 54 | } 55 | 56 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 57 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 58 | { 59 | if (env.IsDevelopment()) 60 | { 61 | app.UseDeveloperExceptionPage(); 62 | } 63 | else 64 | { 65 | app.UseExceptionHandler("/Home/Error"); 66 | } 67 | app.UseStaticFiles(); 68 | 69 | app.UseRouting(); 70 | 71 | app.UseAuthentication(); 72 | app.UseAuthorization(); 73 | 74 | app.UseEndpoints(endpoints => 75 | { 76 | endpoints.MapControllerRoute( 77 | name: "default", 78 | pattern: "{controller=Home}/{action=Index}/{id?}"); 79 | }); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Views/Home/Admin.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Member"; 4 | } 5 | 6 | 9 |
10 | Go Back 11 |
12 | 13 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
6 |

Welcome to ASP.NET Core Identity Management

7 | 10 | 11 |
12 | Go to Admin Area 13 |
14 |
15 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Views/Home/Member.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Member"; 4 | } 5 | 6 | 9 | 10 |
11 | Go Back 12 |
13 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

@ViewData["Title"]

5 | 6 |

Use this page to detail your site's privacy policy.

7 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Views/Identity/Signin.cshtml: -------------------------------------------------------------------------------- 1 | @model SigninViewModel 2 | 3 | @{ 4 | ViewData["Title"] = "Signin"; 5 | } 6 | 7 |
8 | 9 | @Html.ValidationSummary() 10 | 11 |
12 | 13 | 14 |
15 | 16 |
17 | 18 | 19 |
20 |
21 | Remember Me 22 |
23 | 24 | 25 |
26 | 27 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Views/Identity/Signup.cshtml: -------------------------------------------------------------------------------- 1 | @model SignupViewModel 2 | @{ 3 | ViewData["Title"] = "Signup"; 4 | } 5 | 6 |

Signup

7 | 8 |
9 | @Html.ValidationSummary() 10 | 11 |
12 | 13 | 14 |
15 | 16 |
17 | 18 | 19 |
20 | 21 | 22 |
23 | 24 |
25 | If you already have an account, pelase sign in 26 |
27 | 28 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - IdentityNetCore 7 | 8 | 9 | 10 | 11 |
12 | 31 |
32 |
33 |
34 | @RenderBody() 35 |
36 |
37 | 38 |
39 |
40 | © 2019 - IdentityNetCore - Privacy 41 |
42 |
43 | 44 | 45 | 46 | @RenderSection("Scripts", required: false) 47 | 48 | 49 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using IdentityNetCore 2 | @using IdentityNetCore.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "ConnectionStrings": { 10 | "Default": "Data Source=database.local;Database=AspnetIdentityV2;User ID=admin;Password=***" 11 | }, 12 | "Smtp": { 13 | "Host": "in-v3.mailjet.com", 14 | "Username": "***", 15 | "Password": "***", 16 | "Port": 25 17 | }, 18 | "AllowedHosts": "*" 19 | } 20 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aussiearef/asp-net-core-identity-old/851f90cc2c9cf96d43cf605fb3a360354353876c/Cookie-Based/IdentityNetCore/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Reboot v4.3.1 (https://getbootstrap.com/) 3 | * Copyright 2011-2019 The Bootstrap Authors 4 | * Copyright 2011-2019 Twitter, Inc. 5 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 6 | * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) 7 | */*,::after,::before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}[tabindex="-1"]:focus{outline:0!important}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;border-bottom:0;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#007bff;text-decoration:none;background-color:transparent}a:hover{color:#0056b3;text-decoration:underline}a:not([href]):not([tabindex]){color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus,a:not([href]):not([tabindex]):hover{color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus{outline:0}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em}pre{margin-top:0;margin-bottom:1rem;overflow:auto}figure{margin:0 0 1rem}img{vertical-align:middle;border-style:none}svg{overflow:hidden;vertical-align:middle}table{border-collapse:collapse}caption{padding-top:.75rem;padding-bottom:.75rem;color:#6c757d;text-align:left;caption-side:bottom}th{text-align:inherit}label{display:inline-block;margin-bottom:.5rem}button{border-radius:0}button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}select{word-wrap:normal}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=date],input[type=datetime-local],input[type=month],input[type=time]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;max-width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit;color:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item;cursor:pointer}template{display:none}[hidden]{display:none!important} 8 | /*# sourceMappingURL=bootstrap-reboot.min.css.map */ -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Cookie-Based/IdentityNetCore/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.Extensions.Logging; 8 | using IdentityNetCore.Models; 9 | using Microsoft.AspNetCore.Authorization; 10 | 11 | namespace IdentityNetCore.Controllers 12 | { 13 | public class HomeController : Controller 14 | { 15 | private readonly ILogger _logger; 16 | 17 | public HomeController(ILogger logger) 18 | { 19 | _logger = logger; 20 | } 21 | 22 | public IActionResult Index() 23 | { 24 | return View(); 25 | } 26 | 27 | [Authorize] 28 | public IActionResult Member() 29 | { 30 | return View(); 31 | } 32 | 33 | [Authorize] 34 | public IActionResult Admin() 35 | { 36 | return View(); 37 | } 38 | 39 | 40 | public IActionResult Privacy() 41 | { 42 | return View(); 43 | } 44 | 45 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 46 | public IActionResult Error() 47 | { 48 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Data/ApplicationDBContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore; 3 | 4 | namespace IdentityNetCore.Data 5 | { 6 | public class ApplicationDBContext : IdentityDbContext 7 | { 8 | public ApplicationDBContext() 9 | { } 10 | 11 | public ApplicationDBContext(DbContextOptions options) : base(options) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/IdentityNetCore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.0 5 | 497b882b-95a3-4026-9f49-7b399191392a 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | runtime; build; native; contentfiles; analyzers; buildtransitive 15 | all 16 | 17 | 18 | 19 | all 20 | runtime; build; native; contentfiles; analyzers; buildtransitive 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/IdentityNetCore.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29519.87 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityNetCore", "IdentityNetCore.csproj", "{3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {0C239C2B-365F-4A1F-8675-03185FF7E083} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Models/SigninViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class SigninViewModel 6 | { 7 | [Required(ErrorMessage ="User nanme must be provided.")] 8 | [DataType(DataType.EmailAddress)] 9 | public string Username { get; set; } 10 | 11 | [Required(ErrorMessage ="Password must be provided.")] 12 | [DataType(DataType.Password)] 13 | public string Password { get; set; } 14 | public bool RememberMe { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Models/SignupViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class SignupViewModel 6 | { 7 | [Required] 8 | [DataType(DataType.EmailAddress, ErrorMessage ="Email address is missing or invalid.")] 9 | public string Email { get; set; } 10 | 11 | [Required] 12 | [DataType(DataType.Password, ErrorMessage ="Incorrect or missing password.")] 13 | public string Password { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace IdentityNetCore 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Service/IEmailSender.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace IdentityNetCore.Service 4 | { 5 | public interface IEmailSender 6 | { 7 | Task SendEmailAsync(string fromAddress, string toAddress, string subject, string message); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Service/SmtpEmailSender.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Options; 2 | using System.Net; 3 | using System.Net.Mail; 4 | using System.Threading.Tasks; 5 | 6 | namespace IdentityNetCore.Service 7 | { 8 | public class SmtpEmailSender : IEmailSender 9 | { 10 | private readonly IOptions options; 11 | 12 | public SmtpEmailSender(IOptions options) 13 | { 14 | this.options = options; 15 | } 16 | public async Task SendEmailAsync(string fromAddress, string toAddress, string subject, string message) 17 | { 18 | var mailMessage = new MailMessage(fromAddress, toAddress, subject, message); 19 | using (var client = new SmtpClient(options.Value.Host, options.Value.Port) 20 | { 21 | Credentials = new NetworkCredential(options.Value.Username, options.Value.Password) 22 | }) 23 | { 24 | await client.SendMailAsync(mailMessage); 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Service/SmtpOptions.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace IdentityNetCore.Service 3 | { 4 | public class SmtpOptions 5 | { 6 | public string Host { get; set; } 7 | public string Username { get; set; } 8 | public string Password { get; set; } 9 | public int Port { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IdentityNetCore.Data; 3 | using Microsoft.AspNetCore.Builder; 4 | using Microsoft.AspNetCore.Hosting; 5 | using Microsoft.EntityFrameworkCore; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.DependencyInjection; 8 | using Microsoft.Extensions.Hosting; 9 | using Microsoft.AspNetCore.Identity; 10 | using IdentityNetCore.Service; 11 | 12 | namespace IdentityNetCore 13 | { 14 | public class Startup 15 | { 16 | public Startup(IConfiguration configuration) 17 | { 18 | Configuration = configuration; 19 | } 20 | 21 | public IConfiguration Configuration { get; } 22 | 23 | // This method gets called by the runtime. Use this method to add services to the container. 24 | public void ConfigureServices(IServiceCollection services) 25 | { 26 | var connString = Configuration["ConnectionStrings:Default"]; 27 | services.AddDbContext(o => o.UseSqlServer(connString)); 28 | services.AddIdentity().AddEntityFrameworkStores(); 29 | 30 | services.Configure(options => { 31 | 32 | options.Password.RequiredLength = 3; 33 | options.Password.RequireDigit = true; 34 | options.Password.RequireNonAlphanumeric = false; 35 | 36 | options.Lockout.MaxFailedAccessAttempts = 3; 37 | options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(10); 38 | 39 | options.SignIn.RequireConfirmedEmail = true; 40 | 41 | }); 42 | 43 | services.ConfigureApplicationCookie(option=> { 44 | option.LoginPath = "/Identity/Signin"; 45 | option.AccessDeniedPath = "/Identity/AccessDenied"; 46 | option.ExpireTimeSpan = TimeSpan.FromHours(10); 47 | }); 48 | 49 | services.AddAuthentication().AddFacebook(options=> { 50 | 51 | options.AppId = Configuration["FacebookAppId"]; 52 | options.AppSecret = Configuration["FacebookAppSecret"]; 53 | }); 54 | 55 | services.Configure(Configuration.GetSection("Smtp")); 56 | 57 | services.AddSingleton(); 58 | 59 | services.AddControllersWithViews(); 60 | } 61 | 62 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 63 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 64 | { 65 | if (env.IsDevelopment()) 66 | { 67 | app.UseDeveloperExceptionPage(); 68 | } 69 | else 70 | { 71 | app.UseExceptionHandler("/Home/Error"); 72 | } 73 | app.UseStaticFiles(); 74 | 75 | app.UseRouting(); 76 | 77 | app.UseAuthentication(); 78 | app.UseAuthorization(); 79 | 80 | app.UseEndpoints(endpoints => 81 | { 82 | endpoints.MapControllerRoute( 83 | name: "default", 84 | pattern: "{controller=Home}/{action=Index}/{id?}"); 85 | }); 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Views/Home/Admin.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Member"; 4 | } 5 | 6 | 9 |
10 | Go Back 11 |
12 | 13 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
6 |

Welcome to ASP.NET Core Identity Management

7 | 10 | 11 |
12 | Go to Admin Area 13 |
14 |
15 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Views/Home/Member.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Member"; 4 | } 5 | 6 | 9 | 10 |
11 | Go Back 12 |
13 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

@ViewData["Title"]

5 | 6 |

Use this page to detail your site's privacy policy.

7 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Views/Identity/Signin.cshtml: -------------------------------------------------------------------------------- 1 | @model SigninViewModel 2 | @using Microsoft.AspNetCore.Identity; 3 | @inject SignInManager signInManager 4 | 5 | @{ 6 | ViewData["Title"] = "Signin"; 7 | var providers = await signInManager.GetExternalAuthenticationSchemesAsync(); 8 | } 9 | 10 |
11 | 12 | @Html.ValidationSummary() 13 | 14 |
15 | 16 | 17 |
18 | 19 |
20 | 21 | 22 |
23 |
24 | Remember Me 25 |
26 | 27 | 28 |
29 | 30 |

31 | You can use your social media account to login as well. 32 |

33 | 34 |
35 |
36 | 37 | @foreach (var provider in providers) 38 | { 39 | 40 | } 41 |
42 |
43 | 44 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Views/Identity/Signup.cshtml: -------------------------------------------------------------------------------- 1 | @model SignupViewModel 2 | @{ 3 | ViewData["Title"] = "Signup"; 4 | } 5 | 6 |

Signup

7 | 8 |
9 | @Html.ValidationSummary() 10 | 11 |
12 | 13 | 14 |
15 | 16 |
17 | 18 | 19 |
20 | 21 | 22 |
23 | 24 |
25 | If you already have an account, pelase sign in 26 |
27 | 28 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - IdentityNetCore 7 | 8 | 9 | 10 | 11 |
12 | 31 |
32 |
33 |
34 | @RenderBody() 35 |
36 |
37 | 38 |
39 |
40 | © 2019 - IdentityNetCore - Privacy 41 |
42 |
43 | 44 | 45 | 46 | @RenderSection("Scripts", required: false) 47 | 48 | 49 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using IdentityNetCore 2 | @using IdentityNetCore.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "ConnectionStrings": { 10 | "Default": "Data Source=database.jxtnest.local;Database=AspnetIdentityV2;User ID=admin;Password=Sankimsan1" 11 | }, 12 | "Smtp": { 13 | "Host": "in-v3.mailjet.com", 14 | "Username": "8842993ba6d9d0065e16d718430ddb9a", 15 | "Password": "da9782bab0f04afbd01f6e130c131f44", 16 | "Port": 25 17 | }, 18 | "AllowedHosts": "*" 19 | } 20 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aussiearef/asp-net-core-identity-old/851f90cc2c9cf96d43cf605fb3a360354353876c/Facebook-Auth/Facebook-Auth/IdentityNetCore/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Facebook-Auth/Facebook-Auth/IdentityNetCore/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # asp-net-core-identity-v2 -------------------------------------------------------------------------------- /Starter/IdentityNetCore/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.Extensions.Logging; 8 | using IdentityNetCore.Models; 9 | 10 | namespace IdentityNetCore.Controllers 11 | { 12 | public class HomeController : Controller 13 | { 14 | private readonly ILogger _logger; 15 | 16 | public HomeController(ILogger logger) 17 | { 18 | _logger = logger; 19 | } 20 | 21 | public IActionResult Index() 22 | { 23 | return View(); 24 | } 25 | 26 | public IActionResult Member() 27 | { 28 | return View(); 29 | } 30 | 31 | public IActionResult Admin() 32 | { 33 | return View(); 34 | } 35 | 36 | 37 | public IActionResult Privacy() 38 | { 39 | return View(); 40 | } 41 | 42 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 43 | public IActionResult Error() 44 | { 45 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/IdentityNetCore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.0 5 | 6 | 7 | 8 | 9 | 10 | all 11 | runtime; build; native; contentfiles; analyzers; buildtransitive 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/IdentityNetCore.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29519.87 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityNetCore", "IdentityNetCore.csproj", "{3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {0C239C2B-365F-4A1F-8675-03185FF7E083} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace IdentityNetCore 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.Extensions.Configuration; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using Microsoft.Extensions.Hosting; 10 | 11 | namespace IdentityNetCore 12 | { 13 | public class Startup 14 | { 15 | public Startup(IConfiguration configuration) 16 | { 17 | Configuration = configuration; 18 | } 19 | 20 | public IConfiguration Configuration { get; } 21 | 22 | // This method gets called by the runtime. Use this method to add services to the container. 23 | public void ConfigureServices(IServiceCollection services) 24 | { 25 | services.AddControllersWithViews(); 26 | } 27 | 28 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 29 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 30 | { 31 | if (env.IsDevelopment()) 32 | { 33 | app.UseDeveloperExceptionPage(); 34 | } 35 | else 36 | { 37 | app.UseExceptionHandler("/Home/Error"); 38 | } 39 | app.UseStaticFiles(); 40 | 41 | app.UseRouting(); 42 | 43 | app.UseAuthorization(); 44 | 45 | app.UseEndpoints(endpoints => 46 | { 47 | endpoints.MapControllerRoute( 48 | name: "default", 49 | pattern: "{controller=Home}/{action=Index}/{id?}"); 50 | }); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/Views/Home/Admin.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Member"; 4 | } 5 | 6 | 9 |
10 | Go Back 11 |
12 | 13 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
6 |

Welcome to ASP.NET Core Identity Management

7 | 10 | 11 |
12 | Go to Admin Area 13 |
14 |
15 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/Views/Home/Member.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Member"; 4 | } 5 | 6 | 9 | 10 |
11 | Go Back 12 |
13 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

@ViewData["Title"]

5 | 6 |

Use this page to detail your site's privacy policy.

7 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - IdentityNetCore 7 | 8 | 9 | 10 | 11 |
12 | 31 |
32 |
33 |
34 | @RenderBody() 35 |
36 |
37 | 38 |
39 |
40 | © 2019 - IdentityNetCore - Privacy 41 |
42 |
43 | 44 | 45 | 46 | @RenderSection("Scripts", required: false) 47 | 48 | 49 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using IdentityNetCore 2 | @using IdentityNetCore.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aussiearef/asp-net-core-identity-old/851f90cc2c9cf96d43cf605fb3a360354353876c/Starter/IdentityNetCore/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Starter/IdentityNetCore/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Reboot v4.3.1 (https://getbootstrap.com/) 3 | * Copyright 2011-2019 The Bootstrap Authors 4 | * Copyright 2011-2019 Twitter, Inc. 5 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 6 | * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) 7 | */*,::after,::before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}[tabindex="-1"]:focus{outline:0!important}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;border-bottom:0;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#007bff;text-decoration:none;background-color:transparent}a:hover{color:#0056b3;text-decoration:underline}a:not([href]):not([tabindex]){color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus,a:not([href]):not([tabindex]):hover{color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus{outline:0}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em}pre{margin-top:0;margin-bottom:1rem;overflow:auto}figure{margin:0 0 1rem}img{vertical-align:middle;border-style:none}svg{overflow:hidden;vertical-align:middle}table{border-collapse:collapse}caption{padding-top:.75rem;padding-bottom:.75rem;color:#6c757d;text-align:left;caption-side:bottom}th{text-align:inherit}label{display:inline-block;margin-bottom:.5rem}button{border-radius:0}button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}select{word-wrap:normal}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=date],input[type=datetime-local],input[type=month],input[type=time]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;max-width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit;color:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item;cursor:pointer}template{display:none}[hidden]{display:none!important} 8 | /*# sourceMappingURL=bootstrap-reboot.min.css.map */ -------------------------------------------------------------------------------- /Starter/IdentityNetCore/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Starter/IdentityNetCore/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Controllers/ApiSecurityController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IdentityModel.Tokens.Jwt; 4 | using System.Linq; 5 | using System.Security.Claims; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using IdentityNetCore.Models; 9 | using Microsoft.AspNetCore.Authorization; 10 | using Microsoft.AspNetCore.Http; 11 | using Microsoft.AspNetCore.Identity; 12 | using Microsoft.AspNetCore.Mvc; 13 | using Microsoft.Extensions.Configuration; 14 | using Microsoft.IdentityModel.Tokens; 15 | 16 | namespace IdentityNetCore.Controllers 17 | { 18 | [Route("api/[controller]")] 19 | [ApiController] 20 | public class ApiSecurityController : ControllerBase 21 | { 22 | private readonly IConfiguration _configuration; 23 | private readonly SignInManager _signInManager; 24 | private readonly UserManager _userManager; 25 | 26 | public ApiSecurityController(IConfiguration configuration, SignInManager signInManager, UserManager userManager) 27 | { 28 | _configuration = configuration; 29 | _signInManager = signInManager; 30 | _userManager = userManager; 31 | } 32 | 33 | [AllowAnonymous] 34 | [Route(template:"Auth")] 35 | [HttpPost] 36 | public async Task TokenAuth(SigninViewModel model) 37 | { 38 | var issuer = _configuration["Tokens:Issuer"]; 39 | var audience = _configuration["Tokens:Audience"]; 40 | var key = _configuration["Tokens:Key"]; 41 | 42 | if (ModelState.IsValid) 43 | { 44 | var signinResult = 45 | await _signInManager.PasswordSignInAsync(model.Username, model.Password, false, false); 46 | if (signinResult.Succeeded) 47 | { 48 | var user = await _userManager.FindByEmailAsync(model.Username); 49 | if (user != null) 50 | { 51 | var claims = new[] 52 | { 53 | new Claim(JwtRegisteredClaimNames.Email , user.Email), 54 | new Claim(JwtRegisteredClaimNames.Jti , user.Id), 55 | }; 56 | 57 | var keyBytes = Encoding.UTF8.GetBytes(key); 58 | var theKey = new SymmetricSecurityKey(keyBytes); 59 | var creds = new SigningCredentials(theKey, SecurityAlgorithms.HmacSha256); 60 | var token = new JwtSecurityToken(issuer, audience, claims, expires: DateTime.Now.AddMinutes(30), signingCredentials: creds); 61 | 62 | return Ok(new {token= new JwtSecurityTokenHandler().WriteToken(token) }); 63 | } 64 | } 65 | } 66 | 67 | return BadRequest(); 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.Extensions.Logging; 8 | using IdentityNetCore.Models; 9 | using Microsoft.AspNetCore.Authorization; 10 | 11 | namespace IdentityNetCore.Controllers 12 | { 13 | public class HomeController : Controller 14 | { 15 | private readonly ILogger _logger; 16 | 17 | public HomeController(ILogger logger) 18 | { 19 | _logger = logger; 20 | } 21 | 22 | public IActionResult Index() 23 | { 24 | return View(); 25 | } 26 | 27 | [Authorize] 28 | public IActionResult Member() 29 | { 30 | return View(); 31 | } 32 | 33 | [Authorize] 34 | public IActionResult Admin() 35 | { 36 | return View(); 37 | } 38 | 39 | 40 | public IActionResult Privacy() 41 | { 42 | return View(); 43 | } 44 | 45 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 46 | public IActionResult Error() 47 | { 48 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Controllers/ProductsController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using IdentityNetCore.Models; 3 | using Microsoft.AspNetCore.Authentication.JwtBearer; 4 | using Microsoft.AspNetCore.Authorization; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | namespace IdentityNetCore.Controllers 8 | { 9 | [Route("api/[controller]")] 10 | [ApiController] 11 | public class ProductsController : ControllerBase 12 | { 13 | [Route(template:"List")] 14 | [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] 15 | public List GetList() 16 | { 17 | var chair = new Product {Name = "Chair", Price = 100}; 18 | var desk = new Product {Name = "Desk", Price = 50}; 19 | 20 | return new List {chair, desk}; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Data/ApplicationDBContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore; 3 | 4 | namespace IdentityNetCore.Data 5 | { 6 | public class ApplicationDBContext : IdentityDbContext 7 | { 8 | public ApplicationDBContext() 9 | { } 10 | 11 | public ApplicationDBContext(DbContextOptions options) : base(options) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/IdentityNetCore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | all 15 | 16 | 17 | 18 | all 19 | runtime; build; native; contentfiles; analyzers; buildtransitive 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/IdentityNetCore.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29519.87 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityNetCore", "IdentityNetCore.csproj", "{3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {3AC3603F-A4EE-4E73-ABBF-A66EFBB2907E}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {0C239C2B-365F-4A1F-8675-03185FF7E083} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Models/Product.cs: -------------------------------------------------------------------------------- 1 | namespace IdentityNetCore.Models 2 | { 3 | public class Product 4 | { 5 | public string Name { get; set; } 6 | public int Price { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Models/SigninViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class SigninViewModel 6 | { 7 | [Required(ErrorMessage ="User nanme must be provided.")] 8 | [DataType(DataType.EmailAddress)] 9 | public string Username { get; set; } 10 | 11 | [Required(ErrorMessage ="Password must be provided.")] 12 | [DataType(DataType.Password)] 13 | public string Password { get; set; } 14 | public bool RememberMe { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Models/SignupViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace IdentityNetCore.Models 4 | { 5 | public class SignupViewModel 6 | { 7 | [Required] 8 | [DataType(DataType.EmailAddress, ErrorMessage ="Email address is missing or invalid.")] 9 | public string Email { get; set; } 10 | 11 | [Required] 12 | [DataType(DataType.Password, ErrorMessage ="Incorrect or missing password.")] 13 | public string Password { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace IdentityNetCore 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Service/IEmailSender.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace IdentityNetCore.Service 4 | { 5 | public interface IEmailSender 6 | { 7 | Task SendEmailAsync(string fromAddress, string toAddress, string subject, string message); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Service/SmtpEmailSender.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Options; 2 | using System.Net; 3 | using System.Net.Mail; 4 | using System.Threading.Tasks; 5 | 6 | namespace IdentityNetCore.Service 7 | { 8 | public class SmtpEmailSender : IEmailSender 9 | { 10 | private readonly IOptions options; 11 | 12 | public SmtpEmailSender(IOptions options) 13 | { 14 | this.options = options; 15 | } 16 | public async Task SendEmailAsync(string fromAddress, string toAddress, string subject, string message) 17 | { 18 | var mailMessage = new MailMessage(fromAddress, toAddress, subject, message); 19 | using (var client = new SmtpClient(options.Value.Host, options.Value.Port) 20 | { 21 | Credentials = new NetworkCredential(options.Value.Username, options.Value.Password) 22 | }) 23 | { 24 | await client.SendMailAsync(mailMessage); 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Service/SmtpOptions.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace IdentityNetCore.Service 3 | { 4 | public class SmtpOptions 5 | { 6 | public string Host { get; set; } 7 | public string Username { get; set; } 8 | public string Password { get; set; } 9 | public int Port { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Views/Home/Admin.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Member"; 4 | } 5 | 6 | 9 |
10 | Go Back 11 |
12 | 13 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
6 |

Welcome to ASP.NET Core Identity Management

7 | 10 | 11 |
12 | Go to Admin Area 13 |
14 |
15 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Views/Home/Member.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Member"; 4 | } 5 | 6 | 9 | 10 |
11 | Go Back 12 |
13 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

@ViewData["Title"]

5 | 6 |

Use this page to detail your site's privacy policy.

7 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Views/Identity/Signin.cshtml: -------------------------------------------------------------------------------- 1 | @model SigninViewModel 2 | 3 | @{ 4 | ViewData["Title"] = "Signin"; 5 | } 6 | 7 |
8 | 9 | @Html.ValidationSummary() 10 | 11 |
12 | 13 | 14 |
15 | 16 |
17 | 18 | 19 |
20 |
21 | Remember Me 22 |
23 | 24 | 25 |
26 | 27 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Views/Identity/Signup.cshtml: -------------------------------------------------------------------------------- 1 | @model SignupViewModel 2 | @{ 3 | ViewData["Title"] = "Signup"; 4 | } 5 | 6 |

Signup

7 | 8 |
9 | @Html.ValidationSummary() 10 | 11 |
12 | 13 | 14 |
15 | 16 |
17 | 18 | 19 |
20 | 21 | 22 |
23 | 24 |
25 | If you already have an account, pelase sign in 26 |
27 | 28 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - IdentityNetCore 7 | 8 | 9 | 10 | 11 |
12 | 31 |
32 |
33 |
34 | @RenderBody() 35 |
36 |
37 | 38 |
39 |
40 | © 2019 - IdentityNetCore - Privacy 41 |
42 |
43 | 44 | 45 | 46 | @RenderSection("Scripts", required: false) 47 | 48 | 49 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using IdentityNetCore 2 | @using IdentityNetCore.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "ConnectionStrings": { 10 | "Default": "Data Source=database.jxtnest.local;Database=AspnetIdentityV2;User ID=admin;Password=Sankimsan1" 11 | }, 12 | "Smtp": { 13 | "Host": "in-v3.mailjet.com", 14 | "Username": "8842993ba6d9d0065e16d718430ddb9a", 15 | "Password": "da9782bab0f04afbd01f6e130c131f44", 16 | "Port": 25 17 | }, 18 | 19 | "Tokens": { 20 | "Issuer": "http://localhost", 21 | "Audience": "http://localhost", 22 | "Key": "0123456789ABCDEF" 23 | }, 24 | 25 | "AllowedHosts": "*" 26 | } 27 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aussiearef/asp-net-core-identity-old/851f90cc2c9cf96d43cf605fb3a360354353876c/Token-Basewd-Web-API/IdentityNetCore/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Token-Basewd-Web-API/IdentityNetCore/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | --------------------------------------------------------------------------------