0

We are starting a project which will consist in:

  • Web project (ASP.NET MVC)
  • IOS app

and both will consume data from a .NET WEB API service.

The WEB API service will expose a POST Method with the url "user/create". But i don't know how can i avoid another apps for making post to this url? I know i need a security protocol, but i wanted to know which one you recommend me, and if you have, an article where is it explained.

Thanks

1
  • Restrict it with an app key parameter? Commented Aug 13, 2015 at 16:54

3 Answers 3

1

web api 2 provides oauth authentication. You will need to get a token from the token end point of web api and pass that token in subsequent requests.

You should find lot of online resources if you search for web api 2 oauth.

Sign up to request clarification or add additional context in comments.

Comments

1

We did something similar recently using OWIN OAuth 2.0 Authorization Server

Reference this ASP.NET page for details. Sample code is included as well for several different implementations.

For our purposes, we used the Client Credentials Grant section about half-way down the page. Our implementation involved server-server OAuth (Web API to MVC), but I bet it's pretty similar to have iOS connect. The only thing I would caution is to somehow encrypt the login credentials on the iOS side, and I'm sure there is a way to do that.

Comments

1

So you want the WebAPI to only be used by the MVC page? The best architectural method is to separate the two rather than leave both in one project. Why? Because the MVC app is a experience layer for humans. The WebAPI is an experience layer for the MVC app. Move it back where it can't be accessed.

You can add on tokens, etc, but the MVC app sits on the server, but is accessed on the client computer. The wider the scope of the application (ie, intranet or internet or something in between?), the more difficult the problem and the harder it is for your users to access the application. Moving the WebAPI internal and leaving the MVC app exposed guarantees external users cannot use the API.

The main reason WebAPI and MVC exist together in a single project (still a mistake in most instances, IMO) is you are exposing both to the same audience. If that is not your intent, don't do it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.