I've looked around to try and find an answer to my specific question. I'm basically using an external library to check if a user is authorized within our domain via username and password.
var authenticatedUser = ECNSecurity.SecurityChecker.AuthenticateUser(model.Username, model.Password);
Returns true or false whether the user is or is not. I'd like to be able to use the [Authorize] attribute on some of my controller methods. Is this possible to do this without using Identity? Or would I need to get Identity and create my own user which inherits the Identity UserModel? Then when I mark that user as authenticated, somehow, the [Authorize] attribute will be picked up?
I am watching tutorials and reading but I do have a more specific kind of use case for this that I can't find a direct answer for. Excuse my inexperience in this security/authorize area if I'm asking something too silly. Maybe what I'm failing to realize is that the [Authorize] attribute will only work with Identity users.
Any input would be much appreciated. Thank you.
You do not need ASP.NET Identity if you just want Authorize filter to work.
You just need OWIN Cookie Middleware in ASP.NET MVC. You could also add claims such as username, if you want.
Here are few steps you need -
Startup.cs
Configure OWIN Cookie Middleware at startup.
OwinAuthenticationService
You can look at my working sample project at GitHub.
To authorize with cookies in the .net framework versions of mvc, you can simply use the following
remember
is a boolean that is equivalent to "remember me" option.Check my answer here for more info in the set up if needed How to hide Login fields from the logged user