How can I implement an identifier based user system (membership, authorization, etc.) in ASP.NET MVC?

I have been thinking for a long time about how to solve the problem of implementing an identifier-based user system when using ASP.NET MVC. My goals, like the StackOverflow system, are as follows:

  • Allow users to change their aliases without the “avoid duplicate” restriction.
  • Allow users to authenticate using OpenID (not yet with a password).

I wanted to avoid as many alterations as possible, so I first thought about using membership in roles, roles, and (possibly) a profile, but I found that they are based on the username. I thought about adapting the hell from SqlMembershipProvider using a username field to store identifiers and throw UnsupportedException based on passwords and the like to be able to use other systems. But he feels bulky and stupid (if at all possible).

On the other hand, maybe I should minimize my own user system, but I'm not sure that even if I can’t use providers, I can still use some MVC functions (connect my code to MVC somewhere, I can think about AuthorizeAttribute from my head).

So, I was wondering if someone ran into the same design problem and what solutions they came up with.

The more detailed the better!

+3
source share
4 answers

I needed to create a fast membership system for the client, they had some requirements that did not allow me to use the built-in right away on the road, as well as the time to build what they wanted. I have plans to eventually implement a full membership management system, but like you, I need something now. I went with the following plan, which, ultimately, will allow me to swap the built-in providers for my own time constraints and deadlines:

(PT) - MembershipId, UserName, E-mail, . , . , , http, cookie - .

SqlProfileProvider , . ( ), MVC. . , .

:

  • PT .
  • Guid - MembershipId
  • MemberhipUser, MemberhipId - ( ), , ..
  • PT MemberhipId PrimaryKey.

PT, MembershipId , ..

:

  • PT , , /
  • MemberShipId
  • PT
  • User Membership.DeleteUser(MembershipId, true) - , aspnet_

, :)

: User.Identity.Name MemberhipId (Guid). SignIn Role. PT - , ( ). , .., , PrimaryKey PT.

, PT, MemberhipId ( ).

auth - sprocs, , , . . - milion, , .

OpenId, , , , , , , , , ( , OpenId) MembershipId ( ).

, , , , .. . , , .

+2
+2

SqlMembershipProvider. , , . , , .

0

sql proc .

0

Source: https://habr.com/ru/post/1773151/


All Articles