我想使用自定义身份验证提供程序,但我不知道如何使标准身份验证内容处理更多用户和密码作为参数。
这可以做到吗?
取决于您想要做什么,如果您想通过继承 Credentials AuthProvider 创建自己的自定义身份验证提供程序,您可以通过以下方式访问不同的请求参数IHttpRequest
目的:
public virtual bool TryAuthenticate(IServiceBase authService,
string userName, string password)
{
var httpReq = authService.RequestContext.Get<IHttpRequest>();
var fromQueryString = httpRequest.QueryString["CustomField"];
var fromPostData = httpRequest.FormData["CustomField"];
var fromEither = httpRequest.GetParam("CustomField"); //Ext method
}
以下是一些其他相关问题和答案,展示了自定义 ServiceStack 内置 Auth 的不同方法:
- 如何扩展 ServiceStack 身份验证 https://stackoverflow.com/questions/11117469/how-can-i-extend-servicestack-authentication
-
使用数据库中的数据填充 IAuthSession https://stackoverflow.com/questions/12594048/populating-iauthsession-with-data-from-the-database
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)