本文介绍了具有多个用户/密码的 ServiceStack CredentialAuthProvider的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用自定义身份验证提供程序,但我不知道如何让标准身份验证内容将更多用户和密码作为参数处理.
I want to use a custom auth provider, but I don't see how I can make the standard Auth stuff handle more that user and password as parameters.
这能做到吗?
推荐答案
取决于你想做什么,如果你想通过继承 CredentialsAuthProvider 来创建你自己的 Custom auth provider,你可以通过 访问不同的请求参数IHttpRequest
对象:
Depends what you want to do, if you want to create your own Custom auth provider by inheriting from CredentialsAuthProvider, you can access different request params via the IHttpRequest
object:
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 的内置身份验证的不同方法:
Here are some other related questions and answers that show different ways to customize ServiceStack's built-in Auth:
这篇关于具有多个用户/密码的 ServiceStack CredentialAuthProvider的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!