├── src └── Fido2.Passwordless │ ├── Views │ ├── _ViewStart.cshtml │ ├── _ViewImports.cshtml │ ├── Home │ │ ├── Privacy.cshtml │ │ └── Index.cshtml │ ├── Shared │ │ ├── _LoginPartial.cshtml │ │ ├── Error.cshtml │ │ ├── _Layout.cshtml.css │ │ ├── _ValidationScriptsPartial.cshtml │ │ └── _Layout.cshtml │ ├── Usernameless │ │ ├── Index.cshtml │ │ └── Login.cshtml │ └── Passwordless │ │ ├── Index.cshtml │ │ └── Login.cshtml │ ├── Areas │ └── Identity │ │ └── Pages │ │ └── _ViewStart.cshtml │ ├── wwwroot │ ├── favicon.ico │ ├── css │ │ └── site.css │ ├── lib │ │ ├── jquery-validation-unobtrusive │ │ │ ├── LICENSE.txt │ │ │ ├── jquery.validate.unobtrusive.min.js │ │ │ └── jquery.validate.unobtrusive.js │ │ ├── jquery-validation │ │ │ └── LICENSE.md │ │ ├── bootstrap │ │ │ └── LICENSE │ │ └── jquery │ │ │ └── LICENSE.txt │ ├── images │ │ └── securitykey.min.svg │ └── js │ │ ├── helpers.js │ │ ├── login.usernameless.js │ │ ├── login.passwordless.js │ │ ├── register.usernameless.js │ │ └── register.passwordless.js │ ├── appsettings.Development.json │ ├── ScaffoldingReadMe.txt │ ├── Properties │ ├── serviceDependencies.json │ ├── serviceDependencies.local.json │ └── launchSettings.json │ ├── Models │ ├── ErrorViewModel.cs │ ├── UsernamelessModel.cs │ └── PasswordlessModel.cs │ ├── Data │ ├── ApplicationDbContext.cs │ └── DbMigrationHelpers.cs │ ├── appsettings.json │ ├── Dockerfile │ ├── Controllers │ ├── HomeController.cs │ ├── UsernamelessController.cs │ └── PasswordlessController.cs │ ├── Fido2.Passwordless.csproj │ └── Program.cs ├── .dockerignore ├── README.md ├── Fido2.sln ├── .gitattributes └── .gitignore /src/Fido2.Passwordless/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /src/Fido2.Passwordless/Areas/Identity/Pages/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "/Views/Shared/_Layout.cshtml"; 3 | } 4 | -------------------------------------------------------------------------------- /src/Fido2.Passwordless/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brunobritodev/FIDO2.Demo/master/src/Fido2.Passwordless/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/Fido2.Passwordless/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using Fido2.Passwordless 2 | @using Fido2.Passwordless.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /src/Fido2.Passwordless/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/Fido2.Passwordless/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |
Use this page to detail your site's privacy policy.
7 | -------------------------------------------------------------------------------- /src/Fido2.Passwordless/ScaffoldingReadMe.txt: -------------------------------------------------------------------------------- 1 | Support for ASP.NET Core Identity was added to your project. 2 | 3 | For setup and configuration information, see https://go.microsoft.com/fwlink/?linkid=2116645. 4 | -------------------------------------------------------------------------------- /src/Fido2.Passwordless/Properties/serviceDependencies.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mssql1": { 4 | "type": "mssql", 5 | "connectionId": "ConnectionStrings:DefaultConnection" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /src/Fido2.Passwordless/Properties/serviceDependencies.local.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mssql1": { 4 | "type": "mssql.local", 5 | "connectionId": "ConnectionStrings:DefaultConnection" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /src/Fido2.Passwordless/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace Fido2.Passwordless.Models 2 | { 3 | public class ErrorViewModel 4 | { 5 | public string? RequestId { get; set; } 6 | 7 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 8 | } 9 | } -------------------------------------------------------------------------------- /src/Fido2.Passwordless/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |Learn about building Web apps with ASP.NET Core.
8 |
3 |
4 | This demo show how to add a Passwordless and Usernameless flow with FIDO2 and ASP.NET Identity.
5 |
6 | * **Server Side**: ASP.NET Core MVC
7 |
8 | Pre reqs
9 |
10 | * .NET 6
11 |
12 | Techs:
13 |
14 | * ASP.NET Core
15 |
16 | # How to run
17 |
18 | 1. Open VSCode and load folder
19 | * Open terminas (CTRL + \`)
20 | * dotnet run
21 |
22 | Device used for this demo [BioPass FIDO Security Key](https://www.ftsafe.com/store/product/biopass-fido-security-key/)
23 |
24 | There is a post about this code:
25 | [Integração ASP.NET Identity com FIDO2](https://brunobrito.net.br/asp-net-identity-fido2/)
26 |
--------------------------------------------------------------------------------
/src/Fido2.Passwordless/Views/Shared/_LoginPartial.cshtml:
--------------------------------------------------------------------------------
1 | @using Microsoft.AspNetCore.Identity
2 | @inject SignInManager
12 | Request ID: @Model.RequestId
13 |
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 | -------------------------------------------------------------------------------- /src/Fido2.Passwordless/Views/Shared/_Layout.cshtml.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 | a { 11 | color: #0077cc; 12 | } 13 | 14 | .btn-primary { 15 | color: #fff; 16 | background-color: #1b6ec2; 17 | border-color: #1861ac; 18 | } 19 | 20 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 21 | color: #fff; 22 | background-color: #1b6ec2; 23 | border-color: #1861ac; 24 | } 25 | 26 | .border-top { 27 | border-top: 1px solid #e5e5e5; 28 | } 29 | .border-bottom { 30 | border-bottom: 1px solid #e5e5e5; 31 | } 32 | 33 | .box-shadow { 34 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 35 | } 36 | 37 | button.accept-policy { 38 | font-size: 1rem; 39 | line-height: inherit; 40 | } 41 | 42 | .footer { 43 | position: absolute; 44 | bottom: 0; 45 | width: 100%; 46 | white-space: nowrap; 47 | line-height: 60px; 48 | } 49 | -------------------------------------------------------------------------------- /src/Fido2.Passwordless/Models/UsernamelessModel.cs: -------------------------------------------------------------------------------- 1 | using Fido2NetLib; 2 | using NetDevPack.Utilities; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Text; 5 | 6 | namespace Fido2.Passwordless.Models 7 | { 8 | public class UsernamelessModel 9 | { 10 | [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 1)] 11 | [Display(Name = "Name")] 12 | public string DisplayName { get; set; } 13 | 14 | public string? AttestationResponse { get; set; } 15 | 16 | public Fido2User Get() 17 | { 18 | return new Fido2User 19 | { 20 | DisplayName = DisplayName, 21 | Name = DisplayName.Urlize(), 22 | Id = Encoding.UTF8.GetBytes(DisplayName.Urlize()) // byte representation of userID is required 23 | }; 24 | } 25 | 26 | public class LoginModel 27 | { 28 | [Required] 29 | public bool RememberMe { get; set; } 30 | 31 | public string? AssertionResponse { get; set; } 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/Fido2.Passwordless/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 | -------------------------------------------------------------------------------- /Fido2.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.2.32616.157 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fido2.Passwordless", "src\Fido2.Passwordless\Fido2.Passwordless.csproj", "{25F39EA0-0BFA-40D7-8096-06B628E3125A}" 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 | {25F39EA0-0BFA-40D7-8096-06B628E3125A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {25F39EA0-0BFA-40D7-8096-06B628E3125A}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {25F39EA0-0BFA-40D7-8096-06B628E3125A}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {25F39EA0-0BFA-40D7-8096-06B628E3125A}.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 = {1CAB7981-4B00-4D8B-BEAD-D02FB535AB8F} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /src/Fido2.Passwordless/Data/DbMigrationHelpers.cs: -------------------------------------------------------------------------------- 1 | namespace Fido2.Passwordless.Data 2 | { 3 | public static class DbMigrationHelpers 4 | { 5 | ///