ASP.NET Identity 2.x provider

4 posts, 0 answers
  1. Fredrik
    Fredrik avatar
    8 posts
    Member since:
    Sep 2014

    Posted 21 Oct 2014 Link to this post

    I recently migrated one of my projects to Data Access and needed to get a solution for authentication that was as flexible. So I decided to create a Data Access implementation for ASP.NET Identity 2.x. Just wanted to share it with anyone else that can find it useful. Code feedback are also very welcomed :)

    The code can be found at: https://github.com/fschultz/AspNet.Identity.DataAccess/
  2. Boyan
    Admin
    Boyan avatar
    100 posts

    Posted 24 Oct 2014 Link to this post

    Hello Fredrik,

    We are very thankful for your input. Could I kindly ask you to provide a short description or a simple sample project that demonstrate how your implementation is designed to be used with an ASP application? I had some trouble integrating it following an approach similar to the one described in this documentation article.

    I am looking forward to hearing from you.

    Regards,
    Boyan
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  3. DevCraft banner
  4. Fredrik
    Fredrik avatar
    8 posts
    Member since:
    Sep 2014

    Posted 24 Oct 2014 in reply to Boyan Link to this post

    I've posted an article on how to convert from the standard Entity Framework implementation that's added when creating a templated ASP.NET web project: http://kaliko.com/blog/aspnet-template-for-data-access-identity/

    I noticed that it's requires a few more steps than the MySQL implementation to get it up and running with the sample code that comes with the templated web project. Much due to the fact that I chose to use Guids as identifiers rather than strings which require the identifier data type to be specified in many calls.

    General usage is much more straight forward, the following sample creates a role if it not exist and assign a user to it:
    using AspNet.Identity.DataAccess;
    using Microsoft.AspNet.Identity;
     
    ...
     
    var roleManager = new RoleManager<IdentityRole, Guid>(new RoleStore());
     
    var roleName = "MyGroup";
     
    var role = roleManager.FindByName(roleName);
     
    if (role == null) {
        role = new IdentityRole(roleName);
        roleManager.Create(role);
    }
     
    var userManager = new UserManager<IdentityUser, Guid>(new UserStore());
     
    var user = userManager.FindByName("MyUser");
     
    if (user != null) {
        userManager.AddToRole(user.Id, roleName);
    }
  5. Boyan
    Admin
    Boyan avatar
    100 posts

    Posted 29 Oct 2014 Link to this post

    Hello Fredrik,

    We much appreciate your contribution to the Telerik Data Access community. 

    Please find your Telerik Points for your great help.

    Regards,
    Boyan
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
Back to Top