我在 Servicestack 中注册自定义身份验证提供程序时遇到了一些麻烦。我正在使用以下内容为我的服务配置身份验证:
Plugins.Add(new AuthFeature(() => new CustomUserSession(),
new IAuthProvider[] {
new VendorAuth(appSettings),
new FacilitiesAuth(appSettings)
}, null));
作为测试,第一个身份验证提供程序只是设置为始终成功:
public class VendorAuth : CredentialsAuthProvider
{
public VendorAuth(AppSettings appSettings) : base(appSettings) { }
public override object Authenticate(IServiceBase authService, IAuthSession session, Auth request)
{
return base.Authenticate(authService, session, request);
}
public override bool TryAuthenticate(IServiceBase authService, string userName, string password)
{
return true;
}
}
这就是我的理解可能有点分崩离析的地方。但是在客户端,我试图以这种方式访问“VendorAuth”提供者:
public class VendorAuth : Auth
{
}
var AuthResponse = client.Post(new VendorAuth
{
provider = "credentials", // This may be an issue
UserName = "someuser",
Password = "somepass",
RememberMe = true
});
当客户端尝试进行身份验证时,这似乎总是返回 405:
POST /json/syncreply/VendorAuth HTTP/1.1" 405
所以我想问题是......看起来好像我正在正确注册我的自定义身份验证提供程序?