Skip to content
Shannon Deminick edited this page Feb 27, 2018 · 13 revisions

ASP.Net Identity for Umbraco

Minimum requirements, installation and setup

See the project home page

Installation

1) Nuget Installation

PM> Install-Package UmbracoIdentity

There's also a nightly Nuget feed: https://ci.appveyor.com/nuget/umbracoidentity-nightly

There is also just an UmbracoIdentity.Core package too in case you just want the binaries

2) Member type updates

You must add these properties to your Member Types:

Name Alias Type Mandatory Show on profile Member can edit
Security Stamp securityStamp Umbraco.Textbox no no no

If you don't add these properties, you will end up with tons of warnings in your logs and things will not work properly.

3) Creating the Account page

The easiest way to demonstrate how this all can work is to

  • The Nuget install has already created a view called '~/Views/Account.cshtml', be sure to copy/paste the markup in this view to Notepad temporarily

  • Create a new Document Type, for this example we'll call it "Account"

  • Let it create a template for you (this may overwrite the ~/Views/Account.cshtml content)

  • If the ~/Views/Account.cshtml file has been overwritten, paste back in the contents of the file you saved earlier

  • Create a Content item of this document type, publish it and view the result

Install notes: Auth, Config, OWIN, Controllers & Views

Important note: Because this is using a different authentication mechanism than Umbraco normally uses, it means that a few of the MembershipHelper methods will not work, such as sign in/out. You will need to use OWIN to perform these methods.

Controllers

The Nuget install will install an MVC controller: UmbracoIdentityAccountController that contains all of the logic that the Visual Studio template has, except that the logic is updated to work nicely with Umbraco.

Views

The Nuget install will also install some models and views. The models are basically the same as the Visual Studio template ones and the views that are there can be used as examples on how to integrate everything in Umbraco.

The Account.cshtml file uses the AccountLayout.cshtml file as the layout and uses 'Foundation' as the css framework. The Account.cshtml file renders 5 main partial views:

When not logged in:

  • ~/Views/UmbracoIdentityAccount/Login.cshtml
  • ~/Views/UmbracoIdentityAccount/ExternalLoginsList.cshtml
  • ~/Views/UmbracoIdentityAccount/Register.cshtml

When logged in:

  • ~/Views/UmbracoIdentityAccount/LoginStatus.cshtml
  • ~/Views/UmbracoIdentityAccount/Profile.cshtml

There are other partial views in the ~/Views/UmbracoIdentityAccount folder which are used for other aspects of the Identity integration which you can browse.

Config

These config updates 'should' be taken care of by the nuget install, but you should double check to be sure.

Remove FormsAuthentication from your web.config, this should be the last entry in your httpmodules lists:

<remove name="FormsAuthenticationModule" />

The entry is slightly different for the system.webServer/modules list:

<remove name="FormsAuthentication" />

You then need to disable FormsAuthentication as the authentication provider, change the authentication element to:

<authentication mode="None" />

Replace the 'type' attribute of your UmbracoMembershipProvider in your web.config to be:

"UmbracoIdentity.IdentityEnabledMembersMembershipProvider, UmbracoIdentity"

Owin setup

What is OWIN? If you are unsure, be sure to read this before you continue!

If you are familiar with OWIN then here's been installed and how to use it

  • Models/UmbracoApplicationMember - this is similar to the ApplicationUser class that comes with the VS 2013 template, except that this one inherits from UmbracoIdentityMember. You can customize this how you like.
  • App_Start/UmbracoIdentityStartup - this is the OWIN startup class that will be used
  • In your web.config, change the appSetting owin:appStartup to: UmbracoIdentityStartup
  • The UmbracoIdentityStartup file is now your OWIN startup class, you can modify it if you require Identity customizations. If you want to enable 3rd party OAuth authentication, you'll need to follow the normal ASP.Net Identity documentation, sample code for this exists in the UmbracoIdentityStartup class.

External authentication

Info on external authentication like Google and Facebook auth.

Known issues/limitations

Some known issues and limitations and potential work arounds

Custom Startup/Configuration

Info on custom startup/configuration and specifying your own user store or user manager.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.