All Projects → abergs → Fido2 Net Lib

abergs / Fido2 Net Lib

Licence: mit
FIDO2 .NET library for FIDO2 / WebAuthn Attestation and Assertion using .NET

Projects that are alternatives of or similar to Fido2 Net Lib

Simplcommerce
A simple, cross platform, modularized ecommerce system built on .NET Core
Stars: ✭ 3,474 (+733.09%)
Mutual labels:  asp-net-core, net-core
Aspnetcore Realworld Example App
ASP.NET Core backend implementation for RealWorld
Stars: ✭ 1,315 (+215.35%)
Mutual labels:  asp-net-core, net-core
Webapicontrib.core
Community Contributions for ASP.NET Core
Stars: ✭ 426 (+2.16%)
Mutual labels:  asp-net-core, net-core
Elmahcore
ELMAH for Net.Standard and Net.Core
Stars: ✭ 127 (-69.54%)
Mutual labels:  asp-net-core, net-core
jQuery-datatable-server-side-net-core
A simple Visual Studio solution using jQuery DataTable with Server-Side processing using .NET 5
Stars: ✭ 71 (-82.97%)
Mutual labels:  asp-net-core, net-core
vscode-csharp-snippets
Extension of C# Snippets for Visual Studio Code
Stars: ✭ 22 (-94.72%)
Mutual labels:  asp-net-core, net-core
X.pagedlist
Library for easily paging through any IEnumerable/IQueryable in ASP.NET/ASP.NET Core
Stars: ✭ 625 (+49.88%)
Mutual labels:  asp-net-core, net-core
Cqrs Clean Eventual Consistency
CQRS, using Clean Architecture, multiple databases and Eventual Consistency
Stars: ✭ 247 (-40.77%)
Mutual labels:  asp-net-core, net-core
LoggingAdvanced
Improved and patched .NET Core console logger.
Stars: ✭ 20 (-95.2%)
Mutual labels:  asp-net-core, net-core
IdentityServer4.PhoneNumberAuth
Sample passwordless phone number authentication using OAuth in ASP.NET Core 2.2
Stars: ✭ 83 (-80.1%)
Mutual labels:  asp-net-core, net-core
Plato
Plato helps software teams connect & stay engaged with users to gather feedback, provide support & deliver better software.
Stars: ✭ 293 (-29.74%)
Mutual labels:  asp-net-core, net-core
Exceptionless.net
Exceptionless clients for the .NET platform
Stars: ✭ 362 (-13.19%)
Mutual labels:  asp-net-core
Microsoft Identity Web
Helps creating protected web apps and web APIs with Microsoft identity platform and Azure AD B2C
Stars: ✭ 321 (-23.02%)
Mutual labels:  asp-net-core
Blog.identityserver
🥗 打造一个功能强大的通用型Ids4用户认证授权服务中心,配合之前的所有开源项目
Stars: ✭ 315 (-24.46%)
Mutual labels:  asp-net-core
Professionalcsharp7
Code samples for the book Professional C# 7 and .NET Core 2.0 (with updates for 2.1), Wrox Press
Stars: ✭ 403 (-3.36%)
Mutual labels:  asp-net-core
Epplus.core
EPPlus.Core is an unofficial port of the EPPlus library to .NET Core
Stars: ✭ 354 (-15.11%)
Mutual labels:  asp-net-core
Aspnetcore Webapi Sample
This is a sample ASP.NET Core WebAPI
Stars: ✭ 310 (-25.66%)
Mutual labels:  asp-net-core
Mix.core
🚀 Mixcore CMS is an open source CMS that support both headless and decoupled to easily build any kinds of app/web app/customisable APIs built on top of ASP.NET Core / Dotnet Core. It is a completely open source ASP.NET Core (Dotnet Core) CMS solution. https://mixcore.org
Stars: ✭ 304 (-27.1%)
Mutual labels:  asp-net-core
Aspnetcore.grid
Grid controls for ASP.NET Core projects
Stars: ✭ 304 (-27.1%)
Mutual labels:  asp-net-core
Panda.dynamicwebapi
ASP.NET Core Dynamic Restful WebApi. Generating WebApi from Classes. Such as: Direct Generation of WebApi Based on Business Logic Layer.
Stars: ✭ 410 (-1.68%)
Mutual labels:  asp-net-core

FIDO2 .NET Library (WebAuthn)

A working implementation library + demo for FIDO2 and WebAuthn using .NET
Build Status codecov Financial Contributors on Open Collective NuGet Status Change log

💡 Passwordless API now available!

The quickest way to get started with FIDO2 and WebAuthn is with the Passwordless API. It free to try and get started with before commiting to implement your own server with this library.

Blog: How to get started

Purpose

Enable passwordless sign in for all .net apps (asp, core, native).

To provide a developer friendly and well tested .NET FIDO2 Server / WebAuthn relying party library for the easy validation of registration (attestation) and authentication (assertion) of FIDO2 / WebAuthn credentials, in order to increase the adoption of the technology, ultimately defeating phishing attacks.

Install-Package Fido2 -Version 1.1.0

To use the asp.net helpers, install the asp.net-package.

Install-Package Fido2.AspNet -Version 1.1.0

Demo

What is FIDO2?

The passwordless web is coming.
FIDO2 / WebAuthn is a new open authentication standard, supported by browsers and many large tech companies such as Microsoft, Google etc. The main driver is to allow a user to login without passwords, creating passwordless flows or strong MFA for user signup/login on websites. The standard is not limited to web applications with support coming to Active Directory and native apps. The technology builds on public/private keys, allowing authentication to happen without sharing a secret between the user & platform. This brings many benefits, such as easier and safer logins and makes phishing attempts extremely hard.

Read more:

Supported features

  • ✅ Attestation API & verification (Register and verify credentials/authenticators)
  • ✅ Assertion API & verification (Authenticate users)
  • ✅ 100% pass rate in conformance testing (results)
  • ✅ FIDO2 security keys aka roaming authenticators (spec), like SoloKeys Solo, Yubico YubiKey, and Feitian BioPass FIDO2)
  • ✅ Device embedded authenticators aka platform authenticators (spec), like Android Key and TPM)
  • ✅ Backwards compatibility with FIDO U2F authenticators (spec)
  • Windows Hello
  • Face ID and Touch ID for the Web (aka "Apple Hello")
  • ✅ All currently referenced cryptographic algorithms for FIDO2 Server (spec)
  • ✅ All current attestation formats: "packed", "tpm", "android-key", "android-safetynet", "fido-u2f", "apple", and "none" (spec)
  • ✅ FIDO2 Server attestation validation via FIDO Metadata Service (spec)
  • ✅ WebAuthn extensions (spec)
  • ✅ Examples & demos
  • ✅ Intellisense documentation
  • 💤 Formal documentation
  • 💤 Recommended usage patterns

Configuration

Only some options are mentioned here, see the Configuration class for all options

  • fido2:MDSAccessKey - App Secret / environment variable that holds the FIDO2 MDS AccessKey. Required when using the default MetadataService provider.
  • fido2:MDSCacheDirPath - App Secret / environment variable that sets the cache path for the MDS. Defaults to "current user's temporary folder"/fido2mdscache. Optional when using the default MetadataService provider.

Examples

See the demo controller for full examples of both attestation and assertion.

See the test controller for examples of how to pass the conformance tests.

See the Active Directory Store information and example credential store for ideas on how to integrate this library with an on-premises Active Directory.

Create attestation Options

To add FIDO2 credentials to an existing user account, we we perform a attestation process. It starts with returning options to the client.

// file: Controller.cs
// 1. Get user from DB by username (in our example, auto create missing users)
var user = DemoStorage.GetOrAddUser(username, () => new User
{
    DisplayName = "Display " + username,
    Name = username,
    Id = Encoding.UTF8.GetBytes(username) // byte representation of userID is required
});

// 2. Get user existing keys by username
List<PublicKeyCredentialDescriptor> existingKeys = DemoStorage.GetCredentialsByUser(user).Select(c => c.Descriptor).ToList();

// 3. Create options
var options = _lib.RequestNewCredential(user, existingKeys, AuthenticatorSelection.Default, AttestationConveyancePreference.Parse(attType));

// 4. Temporarily store options, session/in-memory cache/redis/db
HttpContext.Session.SetString("fido2.attestationOptions", options.ToJson());

// 5. return options to client
return Json(options);

Register credentials

When the client returns a response, we verify and register the credentials.

// file: Controller.cs
// 1. get the options we sent the client and remove it from storage
var jsonOptions = HttpContext.Session.GetString("fido2.attestationOptions");
HttpContext.Session.Remove("fido2.attestationOptions");
var options = CredentialCreateOptions.FromJson(jsonOptions);

// 2. Create callback so that lib can verify credential id is unique to this user
IsCredentialIdUniqueToUserAsyncDelegate callback = async (IsCredentialIdUniqueToUserParams args) =>
{
    List<User> users = await DemoStorage.GetUsersByCredentialIdAsync(args.CredentialId);
    if (users.Count > 0) return false;

    return true;
};

// 2. Verify and make the credentials
var success = await _lib.MakeNewCredentialAsync(attestationResponse, options, callback);

// 3. Store the credentials in db
DemoStorage.AddCredentialToUser(options.User, new StoredCredential
{
    Descriptor = new PublicKeyCredentialDescriptor(success.Result.CredentialId),
    PublicKey = success.Result.PublicKey,
    UserHandle = success.Result.User.Id
});

// 4. return "ok" to the client
return Json(success);

Create Assertion options

When a user wants to log a user in, we do an assertion based on the registered credentials.

First we create the assertion options and return to the client.

// file: Controller.cs
// 1. Get user from DB
var user = DemoStorage.GetUser(username);
if (user == null) return NotFound("username was not registered");

// 2. Get registered credentials from database
List<PublicKeyCredentialDescriptor> existingCredentials = DemoStorage.GetCredentialsByUser(user).Select(c => c.Descriptor).ToList();

// 3. Create options
var options = _lib.GetAssertionOptions(
    existingCredentials,
    UserVerificationRequirement.Discouraged
);

// 4. Temporarily store options, session/in-memory cache/redis/db
HttpContext.Session.SetString("fido2.assertionOptions", options.ToJson());

// 5. Return options to client
return Json(options);

Verify the assertion response

When the client returns a response, we verify it and accepts the login.

// 1. Get the assertion options we sent the client and remove from storage
var jsonOptions = HttpContext.Session.GetString("fido2.assertionOptions");
HttpContext.Session.Remove("fido2.assertionOptions");
var options = AssertionOptions.FromJson(jsonOptions);

// 2. Get registered credential from database
StoredCredential creds = DemoStorage.GetCredentialById(clientResponse.Id);

// 3. Get credential counter from database
var storedCounter = creds.SignatureCounter;

// 4. Create callback to check if userhandle owns the credentialId
IsUserHandleOwnerOfCredentialIdAsync callback = async (args) =>
{
    List<StoredCredential> storedCreds = await DemoStorage.GetCredentialsByUserHandleAsync(args.UserHandle);
    return storedCreds.Exists(c => c.Descriptor.Id.SequenceEqual(args.CredentialId));
};

// 5. Make the assertion
var res = await _lib.MakeAssertionAsync(clientResponse, options, creds.PublicKey, storedCounter, callback);

// 6. Store the updated counter
DemoStorage.UpdateCounter(res.CredentialId, res.Counter);

// 7. return OK to client
return Json(res);

Nuget package

https://www.nuget.org/packages/Fido2/ and https://www.nuget.org/packages/Fido2.Models/

Contributing

See Contributing for informations about contributing to the project.

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].