1

In previous versions of ASP.NET you got authorization and authentication out of the box from the default template.

I have a Web API application and three or four well defined clients that will consume it and I need to secure it.

I read about OpenID and OAuth but they seem like an overkill for my problem.

What's the simplest way to achieve that?

2
  • The default templates will bootstrap you in many different kind of authoriztion/authentification scenarios. docs.asp.net/en/latest/security/authorization/index.html Commented Dec 17, 2015 at 17:26
  • The default template comes with Forms Authentication which is fine for regular web applications, but I'm building a Web API for clients with no browser. Commented Dec 17, 2015 at 18:13

2 Answers 2

1

These would be the 3 best solutions if you require security:

WEB API browser client: Implicit OAuth 2 flow

WEB API Application client: OAuth2 code flow

(With OpenId)

OR: Cookie Authentication with Cross-site request forgery protection. (Default template MVC 6 website template)

If your application is public, I would use at least one of these, otherwise it depends on how secure your data must be.

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

Comments

0

Well, it depends on your scenario. If you don't need authentication (because it's a server-to-server scenario), use a security token as described below. If you need authentication of the user, you may use Basic or Digest security combined with HTTPS.

In a security token scenario, the client simply has to add the token to the request headers and the server needs to validate the token. Make sure the requests transit as HTTPS to make sure the token is encrypted. Remember, this method is only valid if you know the applications that will access your API will be in a secure environment (another server, for example). Otherwise, I would go for another solution.

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.