Coder Social home page Coder Social logo

dystudio / identitymanagerui Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mguinness/identitymanagerui

0.0 0.0 0.0 815 KB

Identity management system for ASP.NET Core Identity.

License: MIT License

C# 78.61% HTML 16.32% CSS 4.34% JavaScript 0.73%

identitymanagerui's Introduction

Identity Manager UI

Identity management system for ASP.NET Core Identity for use with .NET Core 3.1 and Bootstrap 4.

Introduction

When creating a new ASP.NET Core project you have the option to change the authentication to individual user accounts that adds a reference to Microsoft.AspNetCore.Identity.UI to include the identity system into your website. This includes registration, login and several pages related to user account self management like 2FA and password reset.

The missing piece to the puzzle is user management for the site. For ASP.NET membership there was ASP.NET Website Administration Tool (WSAT) and for ASP.NET Identity there was Identity Manager by Brock Allen. AFAIK there is no solution available for ASP.NET Core Identity so this repo is an effort to remedy that.

UI Integration

Identity Manager UI was developed as a Razor class library that simplifies integrating it into an existing project. The UI has an area named IdentityManager (containing views for both users and roles) that requires area routing.

app.UseEndpoints(endpoints =>
{
    endpoints.MapControllerRoute(
        name: "areas",
        pattern: "{area}/{controller=Home}/{action=Index}/{id?}");
});

Also in Startup you will have to include references to ApplicationUser and ApplicationRole that are defined inside the UI component.

services.AddDefaultIdentity<ApplicationUser>()
    .AddRoles<ApplicationRole>()
    .AddEntityFrameworkStores<ApplicationDbContext>();

In your ApplicationDbContext you need to define the following navigation properties.

protected override void OnModelCreating(ModelBuilder builder)
{
    base.OnModelCreating(builder);

    builder.Entity<ApplicationUser>().HasMany(p => p.Roles).WithOne().HasForeignKey(p => p.UserId).IsRequired().OnDelete(DeleteBehavior.Cascade);
    builder.Entity<ApplicationUser>().HasMany(e => e.Claims).WithOne().HasForeignKey(e => e.UserId).IsRequired().OnDelete(DeleteBehavior.Cascade);
    builder.Entity<ApplicationRole>().HasMany(r => r.Claims).WithOne().HasForeignKey(r => r.RoleId).IsRequired().OnDelete(DeleteBehavior.Cascade);
}

Setup

As the example project uses FileContextCore as the database provider there is no database setup needed since the ASP.NET Identity Core tables are stored in files, however for your own project you should use a Database Provider to store these.

Run the project and you will be able to use the website to manage users, roles and claims. Please note that authentication is not required to use the website since the project uses middleware (for demonstration purposes only) that creates a dummy user with the Admin role.

Features

The first thing that you will likely do is create a new administrator role to manage additional users.

Screenshot

Once done you can create a new user by providing basic information like username and password.

Screenshot

After the user has been created you can then edit email address and lock account if required.

Screenshot

In the user edit dialog you can select the Roles tab to assign user to previously defined roles.

Screenshot

In addition you can also select the Claims tab to add or remove claims to the user being edited.

Screenshot

identitymanagerui's People

Contributors

mguinness avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.