ASP.Net MVC Authentication

I know this has been asked a million times, but all I could find was either very simple scripts or too complex ones that I donโ€™t really like (for example, a huge implementation of MemberhipProvider sample on MSDN).

Here is my problem: I have a database with a Users table. The user has a username, password and other important information. I want the page to require authentication, so if the user has already subscribed to an application that he can authenticate using his uname / pwd, otherwise he can register by filling out all the necessary information. No roles, no special privileges, nothing, just simple authentication.

I assume that this should be something straightforward, I just want to make sure that it is decoupled enough and does not want to write my own authentication system, if there is a built-in, already available and tested.

Thank.

EDIT:
For clarification, I donโ€™t need a special MemberhipProvider, I use the SQL Server database, so the default provider should work fine. The problem is how I can simply define my own set of necessary information for the user.

ANSWER:
Ultimately, I had to derive my MembershipProvider class and override the methods that interested me. It was a lot easier than I thought they worked well.

+3
2

Visual Studio (2008, 2010), ASP.NET MVC2 ( , , ). IMembershipService:

public interface IMembershipService {
   int MinPasswordLength { get; }
   bool ValidateUser(string userName, string password);
   MembershipCreateStatus CreateUser(string userName, string password, string email);
   bool ChangePassword(string userName, string oldPassword, string newPassword);
}

, , , , Users.

, - WCF. , .

.

+2

,

FormsAuthentication.SetAuthCookie(userName, rememberMe);

[Authorize] ,

</" > , , .

http://code.google.com/p/asms-md/source/browse/trunk/WebUI/FormAuths.cs

0

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


All Articles