Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Authentication 利用ServiceStack的表单身份验证的最干净的方法是什么?_Authentication_Forms Authentication_<img Src="//i.stack.imgur.com/WM7S8.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">servicestack - Fatal编程技术网 servicestack,Authentication,Forms Authentication,servicestack" /> servicestack,Authentication,Forms Authentication,servicestack" />

Authentication 利用ServiceStack的表单身份验证的最干净的方法是什么?

Authentication 利用ServiceStack的表单身份验证的最干净的方法是什么?,authentication,forms-authentication,servicestack,Authentication,Forms Authentication,servicestack,我正在尝试将ServiceStack与现有的Web表单站点集成。该站点使用表单身份验证以及一些涉及数据库调用等的自定义身份验证逻辑 如何使用相同的机制保护ServiceStack调用?在阅读时,我似乎应该编写一个从credentialauthProvider继承的自定义身份验证提供程序来执行数据库检查等操作,并添加一个请求筛选器以将AuthenticateAttribute应用于每个请求。我是否还需要设置表单身份验证票证(一旦通过身份验证),并在每次请求时检查票证?我在哪里做这些事情 我遗漏了什

我正在尝试将ServiceStack与现有的Web表单站点集成。该站点使用表单身份验证以及一些涉及数据库调用等的自定义身份验证逻辑

如何使用相同的机制保护ServiceStack调用?在阅读时,我似乎应该编写一个从
credentialauthProvider
继承的自定义身份验证提供程序来执行数据库检查等操作,并添加一个请求筛选器以将
AuthenticateAttribute
应用于每个请求。我是否还需要设置表单身份验证票证(一旦通过身份验证),并在每次请求时检查票证?我在哪里做这些事情

我遗漏了什么吗?有更好的方法吗?

有关将MVC表单身份验证与ServiceStack的身份验证提供程序集成的示例,请参见用例项目

具体而言,该方法显示了如何从MVC调用ServiceStack:

[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginModel model, string returnUrl)
{
    if (ModelState.IsValid)
    {
        var authService = AppHostBase.Instance.TryResolve<AuthService>();
        authService.RequestContext = CreateRequestContext();
        var response = authService.Authenticate(new Auth
        {
            UserName = model.UserName,
            Password = model.Password,
            RememberMe = model.RememberMe
        });

        // add ASP.NET auth cookie
        FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);

        return RedirectToLocal(returnUrl);
    }

    // If we got this far, something failed, redisplay form
    ModelState.AddModelError("", 
        "The user name or password provided is incorrect.");
    return View(model);
}
[HttpPost]
[异名]
[ValidateAntiForgeryToken]
公共操作结果登录(LoginModel模型,字符串返回URL)
{
if(ModelState.IsValid)
{
var authService=AppHostBase.Instance.TryResolve();
authService.RequestContext=CreateRequestContext();
var response=authService.Authenticate(新身份验证
{
用户名=model.UserName,
Password=model.Password,
RememberMe=model.RememberMe
});
//添加ASP.NET身份验证cookie
FormsAuthentication.SetAuthCookie(model.UserName,model.RememberMe);
返回重定向到本地(returnUrl);
}
//如果我们走到这一步,有些东西失败了,重新显示形式
ModelState.AddModelError(“,
“提供的用户名或密码不正确。”);
返回视图(模型);
}

My authentication logic可以返回多个值:“用户未找到”、“锁定”等。是否可以使用
CredentialAuthProvider来支持此功能?
?这是可能的,但还没有人提供支持:)