Looking to get started building ASP.NET MVC apps with RavenDB? Check out RavenDB.ModernMvcStarterKit. It’s an MVC template that lets users register on your site, verify their registration via email, and allows them to opt-in to two-factor authentication via email or SMS.
Modern websites need a robust identity system, where users can login, confirm their registration via email, and optionally enable two-factor authentication.
Doing this with the .NET + RavenDB stack has had some friction:
- The default MVC template is wired to work with Entity Framework, not RavenDB.
- Making the default template work with RavenDB is non-trivial, and requires implementing a RavenDB-specific identity provider.
- There is no publicly-available Identity provider for RavenDB. Or rather, there are 2 available, but they work against old versions of Identity Framework: tugberkugurlu’s AspNet.Identity.RavenDB and ILM’s RavenDB.AspNet.Identity.
- The basic MVC template from Visual Studio doesn’t implement email service or SMS service, nor UI for this or Two-Factor Authentication, leaving it up to you to do all the heavy lifting.
To remove this friction, I created RavenDB.ModernMvcStarterKit.
In a nutshell, it’s an MVC sample project that uses RavenDB as the backend, supports user registration and confirmation via email (SendGrid), and optionally supports Two-Factor Authentication via email (SendGrid) or SMS (Twilio).
This project provides:
- A RavenDB-backed identity provider, updated to work with the latest MS Identity Framework (2.1 at the time of this writing). This is a fork of ILM’s RavenDB.AspNet.Identity provider, updated to work with email and SMS authentication and the latest Identity bits. I’ve submitted a pull request with my changes to merge back into that repo.
- A registration confirmation system: when a user registers, he is required to confirm his registration via email. The email is sent via your developer SendGrid account. Upon registering, the user is presented with the following screen:
The user will receive an email with a confirmation link. Following the link, he’ll be taken to this page:
- Optional two-factor authentication: Users can optionally go to their profile page and add a phone number and enable Two-Factor Authentication:
When the user enters his phone number, we send an SMS verification code via your developer Twilio account:
With Two-Factor Authentication enabled, when the user goes to sign-in next time, he will first login as usual, and then be prompted to enter the 2nd form of identification, either email or SMS:
The user will receive a verfication code via SMS or email and be redirected to the verification page:
Upon entering the verification code, they’ll be able to sign in.
Bottom line: this is a nice way to build a modern MVC app with RavenDB. It’s all about removing friction. Check out the project on GitHub.