Middleware for multisite ASP.NET Identity 2

≡放荡痞女 提交于 2019-12-08 05:38:11

问题


Context:

In a project, i was given the work to create a middleware that used identity 2 for authentication, replacing the simple membership project they had. I extended roles and user to my like and everything worked good. Now i need to make this middleware, multisite ready.

Requirements:

  • Each site is treated as a different application;
  • Each username is unique, making him possible to login in multisites if he has the permissions for it;
  • Every site has their unique roles, and they can have the same name (not description name) as other sites (making the ID the only unique attribute in the role table).
  • Every role has their own set of properties, that can and probably will have different values, from other roles with the same name from other sites.

Idea:

The way i am thinking on how to tackle this is:

  • Since the roles have their ID and it should be unique, there should be no problem in having different roles with the same name (so i would have to remove the uniqueness from the Role Name).
  • Each role belongs to an application, so a many to one connection between role and application (or site if you want to make it simpler).
  • And that's it, that should pretty mutch be simple.

Problem:

I have been trying to extend Identity so i could tackle the problem at hands, but it seems i cannot override the uniqueness from the role name with identityDbContext and so, my ApplicationDbContext now inherits DbContext.

Question:

I know identity is pretty flexible and that i can possibly tackle this from another angle i am not thinking of right now, since i will have pretty mutch to change usermanager, userstore, rolestore and rolemanager. It's more a question of "am i tackling this the right way", cause so far, i have not found anything about tackling this approach in identity 2.

Thank you for any help!

来源:https://stackoverflow.com/questions/28496594/middleware-for-multisite-asp-net-identity-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!