Amour Rashid
Amour Rashid

Reputation: 41

Breeze.WebApi2 Authentication Microsoft.AspNet.Identity

Now that AS.NET WebApi2 has an integrated authorization mechanism using tokens. How can we integrate this mechanism with Breeze.WebApi2. That is Breeze.WebApi2 and Microsoft.AspNet.Identity.

What I need is how to modify the project created using visual studio 2013 project wizard that is configured to use individual accounts in security into a breeze web api 2 server with the same security setup.

I tried it by creating a web api project with individual accounts security and then added breeze web api 2 server using nuget package but that was s bit confusing to me. A sample code or application would be more useful for me to get started. Thanks.

Upvotes: 1

Views: 437

Answers (1)

Jay Traband
Jay Traband

Reputation: 17052

If you use the Authorize attribute you can also access the user data via the "User" variable.

[BreezeController]
[Authorize]
public class NorthwindIBModelController : ApiController {

   [HttpGet]
   public IQueryable<Customer> CustomerList() {
     var userName = User.Identity.Name;

     var filter = filter on customers;
     var custs = ContextProvider.Context.Customers.Where({ some filter using userName});
   }

}

Upvotes: 1

Related Questions