Authentication ServiceStack中多租户的自定义身份验证请求
我已经在基于ServiceStack的web服务应用程序中使用自定义身份验证提供程序 我正在重写Authenticate方法,并根据多个后端租户数据库之一验证我的用户。我目前通过将API密钥与数据库字符串匹配来确定租户数据库Authentication ServiceStack中多租户的自定义身份验证请求,authentication,servicestack,Authentication,servicestack,我已经在基于ServiceStack的web服务应用程序中使用自定义身份验证提供程序 我正在重写Authenticate方法,并根据多个后端租户数据库之一验证我的用户。我目前通过将API密钥与数据库字符串匹配来确定租户数据库 public override object Authenticate( IServiceBase authService, IAuthSession session, Auth request) // <- custom object here
public override object Authenticate(
IServiceBase authService,
IAuthSession session,
Auth request) // <- custom object here, MyCustomAuth request
{
// ...
}
公共覆盖对象身份验证(
IServiceBase身份验证服务,
第二届会议,
Auth request)//您不能修改内置的认证
请求数据以使用,但可以使用其字典元
属性随认证请求发送其他元数据,例如:
client.Post(new Authenticate {
...
Meta = new Dictionary<string,string> {
{"TenantId", tenantId},
}
}
Meta
属性是否在v3.9.x之后?另外,对于相同的3.9.x版本(.48),我假设我需要执行authService.RequestContext.Get().Items[“TenantId”]
?@Junto-Authenticate.Meta是在v4中添加的。这就是在v3中访问当前请求的方法,但是如果您正在寻找查询字符串,那么您仍然希望查看查询字符串。
var tenantId = authService.Request.QueryString["TenantId"];