ASP.NET MVC5 add authentication into an empty project - asp.net

I've created an empty asp.net mvc5 project, used EF with code first approach. How can I add OWIN authentication and store Users and Roles in my created database? How can I customize OWIN authentication for my purpose?

Look into Microsoft's Identity framework. You can the Nuget package Identity EntityFramework to your project.

A good guide to setup a token based authentication: http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/

Related

How can I use Azure Active Directory as an identity provider for my webforms and mvc applications?

I have a WebForms application that uses old Membership identity for authentication/authorization. Now I am adding an MVC Core application that needs to share the same users. But .Net Core doesn't support old way of authentication.
So I am thinking about migrating to a 3rd party provider. We already use Azure. But I cannot find a simple tutorial on how to do this migration to Azure Active Directory.
Here is an article about using Azure Active Directory as an identity provider for the webforms and mvc applications.
Also, you can refer to the official samples.
Select Register to create the application." What if I already have an
application?
If the application you mentioned refer to https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app. You can use the old one(need to change the settings) or just create a new one.

Can i use asp.net membership with owin and oauth provider?

I have started to create ASP.NET membership for learning basis but i found new ASP.NET Identity. Some people suggested that latter is advanced than ASP.NET membership and ASP.NET simple membership.
I have read the comparison from this source. But still i have some questions because i some things are still unclear to me.
Can i use owin and oauth with ASP.NET membership and simple membership?
how i can authenticate web api with ASP.NET membership and simple membership?
Can i customize tables for profile, user and role in ASP.NET Identity?
Please suggest. If any one can suggest me a good reference for authorization and authentication of web API and ASP.NET Identity configuration, it would be great.
ASP.NET Identity is now a mature technology and it's complex enough to accommodate all your requirements.
More than so, there is even a better solution, it's called ASP.NET Identity Server and comes with couple things extra:
Can be used with Identity
Implements SSO (Single Sign-On)
Can be used with Entity Framework
It's a self host product
So to answer you're questions:
No, you cannot use both Identity and Simple Membership.
Using ASP.NET Identity Server, via a token.
You can customize the tables to meet you requirements.
Here is the official documentation for the Identity Server.

Adding User Authentication to MVC

I was assigned my first ever MVC 5 projet, it is a simple Lending System with lots of CRUD operations which is almost done except that I have not implemented user authentication to the app yet.
My project has 4 layers:
1. App.Web - mvc web app
2. App.DataAccess - crud repositories
3. App.Common- my edmx/entities and interfaces
4. App.Business - services / logical operations
Now I just need to add user authentication to complete my project. Just a simple individual user account but I need to implement user roles. I do NOT need any other api login feature (facebook, google etc). But I am too lazy to code this and wanted to use asp.net identity instead. So when I created my MVC 5 App.Web, I checked individual user authentication so everything I need is now referenced in my App.Web but I dont know how to make it work with my application layer.
Is there a way I can use asp.net identity in my web application? How can I do this to fit in my application architecture nicely? Please help!
to understand the structure and customization of ASP.NET Identity you can create empty project on visual studio and download this package from NuGet.
Install-Package Microsoft.AspNet.Identity.Samples -Pre
If your project is not too big I mean if have just some simple User roles and Login/Log out system ,so I recommend you to use ASP.NET membership system.it is very easy to manage user's and roles.Please take a look into the following article:
Introduction to Membership

ASP.Net Identity using DevExpress ORM instead of Entity Framework

I'm implementing ASP.Net Identity for my MVC web application.
Could someone profide hints on how to use DevEx ORM and not Entity Framework?
Thanks in advance.
I got this answer from DevEx team:
Hi Muris,
ASP.NET Identity Framework is highly dependable on the Entity Framework, therefore it is required to write a lot of custom code to utilize it with other ORM. What we plan to do in the context of the Add support for VS2013 authentication modes ticket is to support selecting the ASP.NET Identity as an authentication provider when creating a new project using the Project Wizard. Since our Project Wizard uses Entity Framework as a data provider, we will also use it to support the ASP.NET Identity authentication.

Using an authentication provider from one project to authenticate another project in ASP.NET

I have an ASP.NET project that has a forms authentication provider which works great. Is there a way to make a second project use the same forms authentication provider?
I'm not familiar with ASP.NET authentication so any reference to what I'm trying to do and why it can or can't be done would be great!

Resources