My MVC 3 REST API features a straightforward controller called ApiController
. Within this controller, there exists a method named Foo
that accepts string data and returns a JSON result:
public class ApiController : Controller
{
[HttpPost]
public JsonResult Foo(string input)
{
...
}
}
My goal is to utilize a JQuery function to invoke Foo with user-provided information and exhibit the outcome.
The challenge is ensuring that only authorized users have access to Foo. What steps should I take within ASP.NET MVC 3 to address this? I'm considering implementing SSL and basic authentication, but I need guidance on how to implement it. Additionally, I am unsure if I need to develop my own password encryption method or if there is a way to leverage Forms Authentication.
Edit: It's important to note that my aim is to develop an API for third-party developers to utilize. For instance, allowing someone to create a browser extension similar to Rapportive that scans Gmail, sends the text to Foo, and displays the results in the browser.
Furthermore, I am concerned that using just Forms Authentication may transmit username and password details in plain text. How can I incorporate SSL to prevent this security risk?