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