How to show/hide few methods to one client and few other methods to another client in Web Api

Viewed 78

I have a Web Api say "Calculator". It has say methods Add,Subtract,Multiply,Divide. I wanted to make sure that only Add, Subtract methods will be visible to client when we handover them. And when I handover to another client I wanted to show only Multiply and Divide methods. Is it possible in Web Api 2.0?

1 Answers

Authentication And Authorization

This article explains it pretty well. Once a client is authenticated you may authorize them to do specific actions based on conditions.

Here's a small example of how authorization works, from the article:

// Restrict by user:
[Authorize(Users="Alice,Bob")]
public class ValuesController : ApiController
{
}

// Restrict by role:
[Authorize(Roles="Administrators")]
public class ValuesController : ApiController
{
}
Related