1
我想对某些自动查询执行身份验证。ServiceStack自动查询和[身份验证]属性
[Authenticate]
public class BusinessEntitiesService : QueryDb<DataModel.dbo.BusinessEntity>
{
}
这是我的问题。上面的类在我的ServiceModel项目中...为了添加[Authenticate]属性,我需要添加一个对ServiceStack.dll的引用,我认为这会引起问题(根据以前的指导仅引用ServiceStack。 ServiceModel中的接口)。我无法将上面的类添加到ServiceInterfaces中,因为那么我必须在每个使用客户端的地方引用它。
我也使用GlobalRequestFilter试过......但似乎与AdminFeature插件偷懒:
private bool IsAProtectedPath(string path)
{
return !path.StartsWith("/auth") && !path.StartsWith("/autoquery");
}
GlobalRequestFilters.Add((httpReq, httpResp, requestDto) =>
{
if(IsAProtectedPath(httpReq.PathInfo))
new AuthenticateAttribute().Execute(httpReq, httpResp, requestDto);
});
不能确定如何最好地处理这个问题。
是IAutoQueryDb应该被注入到服务?我得到一个空例外....使用基本上相同的例子,从你提供的链接。 –
@ChrisKlepeis是啊'当您注册AutoQueryFeature时,IAutoQueryDb'在IOC中注册,例如'Plugins.Add(new AutoQueryFeature()); – mythz