【发布时间】:2013-10-23 07:44:55
【问题描述】:
在现有的 Silverlight 应用程序中,我将 WCF 服务替换为 ServiceStack 的服务...我成功地移植了所有服务并对其进行了测试..我还有最后一点要看...身份验证
目前,我使用基于 CustomMembershipProvider 的 Asp.NET 身份验证,该身份验证使用一些标准检查用户是否可以访问应用程序。
在我的每个服务方法中,我都有一些东西
public bool DoSomething(int idUser, string prefix)
{
if (!HttpContext.Current.User.Identity.IsAuthenticated) throw new SecurityExeption();
//some computation
return res;
}
而且效果很好... 现在我试图在 ServiceStack 上实现同样的事情,我已经创建了我的 AuthProvider 如下
公共类 myAuthProvider : CredentialsAuthProvider { public override bool TryAuthenticate(IServiceBase authService, string userName, string password) { if (userName == "test" && 密码 == "test") 返回真;
return false;
//return base.TryAuthenticate(authService, userName, password);
}
public override void OnAuthenticated(IServiceBase authService, IAuthSession session, IOAuthTokens tokens, Dictionary<string, string> authInfo)
{
authService.SaveSession(session, SessionExpiry);
}
}
并在一个示例项目上对其进行了测试(我保证在部署之前我会删除测试/测试!)
在我通过 SS 服务进行身份验证后,我尝试检查 HttpContext.Current.User.Identity.IsAuthenticated 是否有效,但我得到一个错误...我做错了什么还是 ServiceStack 不会在其上构建身份验证ASP.NET?我是否从错误的 AuthProvider 中脱颖而出?我希望通过 web.config 等将所有 asp.net feauter 持久化为滑动周期/会话超时
谢谢
【问题讨论】:
标签: servicestack