Answer the question
In order to leave comments, you need to log in
ASP.NET Custom Authentication Service + OWIN or ASP.NET Identity 2.0?
Good afternoon! I ask for help in the issue of building authorization / authentication in the N-Layer application.
The application uses a three-tier architecture:
Answer the question
In order to leave comments, you need to log in
1) Enough
2) Identity implements the basic functionality of working with users / roles, etc., the ability to connect authorization through third-party services.
If you need the simplest authentication / authorization, then Identity as a whole is not needed, it will be enough to find a user in the DAL with the specified login and password and authorize him.
Pseudocode:
public User Validate(string login, string secret)
{
return DbContext.Users.FirstOrDefault(x=>x.login == login && secret == secret );
}
public async void SignIn(User user)
{
List<Claim> claims = new List<Claim>();
claims.Add(new Claim(ClaimTypes.Name, user.Name));
ClaimsIdentity identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
ClaimsPrincipal principal = new ClaimsPrincipal(identity);
await HttpContext.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal);
}
public async void SignOut()
{
await HttpContext.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question