Keoz
Keoz

Reputation: 394

Aspnet Web API Authentication on mobile clients

I am implementing an API using ASP.net Web API and I'm trying to find proper alternatives for authentication in my scenario, it is as follows:

So I've explored some options and I have found that a basic authentication over SSL would be enough, but some people say it might not be enough, a claims based solution would.

Then I have explored Azure ACS and I see there are some advantages but maybe it's overcomplicated for my scenario? still I should create an identity provider like in basic authentication. Sample flow (second approach): http://msdn.microsoft.com/en-us/library/gg429784.aspx

What do you think?

Thanks

UPDATE:

I have been thinking about using an implementation of DotNetOpenOauth and using the Resource Owner Password Grants so I can just use the device id and user id the first time to get an access token without storing credentials, the server can authorize the caller based on the device calling it, is this correct?

Upvotes: 2

Views: 1503

Answers (3)

Johan O
Johan O

Reputation: 454

In VS 2013 you can use the "Asp MVC SPA Application" template to generate a working implementation that is generating a Oauth2 token bearer on login and authorizing it for WebApi controller calls using [Authorize] attributes. It uses Membership and Entity Framework to store users and hashes locally in a SQL Server. Just delete the asp mvc parts you don't need and keep the Auth part for WebApi. More details here: http://msdnrss.thecoderblogs.com/2013/09/understanding-security-features-in-the-spa-template-for-vs2013-rc/

Upvotes: 2

aamir sajjad
aamir sajjad

Reputation: 3039

I did it using asp.net mvc 4.0/web api basic membership. you may find it helpful.

https://github.com/aamir-poswal/Mobile-Apps-Authentication-Authorization-ASP.NET-WEB-MVC-4.0

Upvotes: 1

leastprivilege
leastprivilege

Reputation: 18482

Not storing credentials is a good idea. You can have a look at IdentityServer, it supports resource owner, implicit and code flow:

https://github.com/thinktecture/Thinktecture.IdentityServer.v2/wiki

Upvotes: 0

Related Questions