You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to OpenRasta
What is the best way to get information in and out of an
OperationInterceptor? I have the following which works but feels a
bit clunky:
public class Authorizer : OperationInterceptor
{
readonly IDependencyResolver dependencyResolver;
public Authorizer(IDependencyResolver dependencyResolver)
{
this.dependencyResolver = dependencyResolver;
}
public override bool BeforeExecute(IOperation operation)
{
// Was UserContext added by our authentication
contributor?
if (dependencyResolver.HasDependency<UserContext>())
return true;
// Are unauthenticated users allowed to call this?
if(operation.FindAttribute<PublicAttribute>() != null)
return true;
// Reject the request
var context =
dependencyResolver.Resolve<ICommunicationContext>();
context.OperationResult = new OperationResult.Unauthorized
();
return false;
}
}
1. Can I have the communication context injected somehow so I don't
need to call resolve?
2. Is this the correct way to reject the request?
I notice some comments a while ago about writing some documentation
for interceptors but haven't been able to find any so I assume it's
not done yet.