Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Identity and mobile clients

The latest version of ASP.NET includes the new authentication framework ASP.NET Identity, which should be the core building block for user management in all new and near future ASP.NET projects and websites.

I have seen that it can integrate with the WebAPI quite nicely, but haven't seen any example of integration as authentication for mobile client devices. For example - suppose I have a ASP.NET website with Identity implemented in use. Now I want to build client applications for Windows 8.1 and Windows Phone 8. I see two main issues that are limiting this.

Firstly - ASP.NET Identity apparently issues only short-lived auth. tokens, which is quite a bad user experience for mobile applications. I have seen some attempts to create a refresh token mechanism - http://leastprivilege.com/2013/11/15/adding-refresh-tokens-to-a-web-api-v2-authorization-server/ . This is quite a nice approach, but it would still be more interesting to see a really built in solution.

Second - and maybe more important - external authentication provider support. On the ASP.NET Identity website it is quite clear and easy to see a way to authenticate via WebAPI, but I haven't seen this in use with external authentication. How is it possible to get the authentication URLs for Facebook, Microsoft and Twitter and how can the authentication flow be completed from within the app?

Has anyone some experience with this? It would be great to find a complete walkthrough, I will gladly reward the correct solution with some bounty points :-) .

like image 933
Martin Zikmund Avatar asked Mar 02 '14 10:03

Martin Zikmund


People also ask

What is ASP NET identity used for?

ASP.NET Core Identity: Is an API that supports user interface (UI) login functionality. Manages users, passwords, profile data, roles, claims, tokens, email confirmation, and more.

Which instance holds the user identity in an ASP NET page?

This instance is of type IPrincipal . IPrincipal is a special interface used to represent different identity types inside ASP.NET. It holds an IIdentity that represents the user identity plus its roles as an array of strings.

What is ASP Net Identity in MVC?

ASP.NET Identity is a new authentication system that is intended to replace the existing membership system of ASP.NET. ASP.NET Identity is an OWIN (Open Web Interface for . NET) based library. Visual Studio 2013 project templates allow you to use ASP.NET Identity for securing the web application being created.

What is ASP NET identity claims?

ASP.NET Core Identity Claims are name-value pair issued to users to represent what the users are allowed to do. For example, a person driving licence is issued by a driving license authority.


1 Answers

The problem is that security is complicated and that Microsoft's solutions only address the simple scenarios.

Also, you're consing terminology (which increases everyone's confusion, including your own). ASP.NET Identity manages users' credentials stored in a database. It's unrelated to the type of application that needs to validate credentials (mobile, api, browser, desktop, etc).

Katana middleware is what allows an application to authenticate the caller. There's cookie middleware for browser applications, external middleware for google, facebook, WS-Fed, etc, and then there's OAuth2 for API applications. Each work differently based upon the nature of the application. Some of them interact as well, depending on the requirements of the application.

I don't mean to pick on you -- this is more of a complaint about Microsoft's lack of education/documentation in the frameworks they provide. And I suppose this is an answer to your question -- Microsoft doesn't have what you're asking for. They have bits and pieces, but you're left to connect the dots.

Some links that might help:

http://www.asp.net/identity

http://www.asp.net/web-api/overview/security

http://www.asp.net/vnext/overview/authentication

http://brockallen.com/category/owin-katana/

http://leastprivilege.com/category/katana/

http://leastprivilege.com/category/webapi/

HTH

like image 118
Brock Allen Avatar answered Sep 17 '22 19:09

Brock Allen