tags:

views:

21

answers:

1

what is the ActionFilterAttribute equivalent in WCF?

I have a rest service which looks like below

[WebInvoke(Method = "POST", UriTemplate = "/")]
public User CreateBookMark(BookMark bm)
{
  User authenticateUser = GetUserSomeHow();

  //do stuff


}

I want to change this to follwoing

[WebInvoke(Method = "POST", UriTemplate = "/")]
public User CreateBookMark(BookMark bm, User authenticateUser)
{

  //do stuff


}
+1  A: 

Create a custom service behavior (IServiceBehavior) - that hooks up a custom operation behavior (IOperationBehavior) that will inject the the extra parameter. It may be you also want to implement your own AuthorizationManager - but it's most likely that you can do with the features (OperationContext.Current.SecurityContext and System.Threading.Thread.CurrentPrincipal).

larsw
Do you have an example of how you would do it?
ps