I have an MVC Application, which allows logged-in users to perform CRUD operations according to their Roles. I have handled authentication and authorization for the MVC App (with OWIN).
I have Web APIs within the same project which are mostly used to handle delete requests(Ajax) originate from list item views (MVC).
I have decorated Web API Controller Actions with [Authorize]
attribute as sample code below
[HttpDelete]
[Authorize(Roles=UserRoles.Admin)]
public IHttpActionResult Delete(int id)
I have not implemented token based authentication/authorization and I am not setting any authorization headers in Ajax requests (or pass any cookie values)
$.ajax({
url: "/api/productCategories/" + id,
method: "DELETE"
})
.done(done)
.fail(fail);
But the authorization works properly, only the authorized users can call the relevant endpoints.
How does it work? Does this mean token based authorization is not needed if the Web API, MVC App, and client app are in the same project? Or else What is the best way to implement Authorization? What about the Cross-site Scripting (XSS) issues?