我正在尝试使用身份服务器4实现多租户应用程序,假设我有
web1.local.com
web2.local.com
当我登录到 web1.local.com 其他域时,web2.local.com 也会自动登录。
有没有办法将这些登录名分开?
我正在考虑有自定义实现IUserSession
public virtual async Task CreateSessionIdAsync(ClaimsPrincipal principal, AuthenticationProperties properties)
{
if (principal == null) throw new ArgumentNullException(nameof(principal));
if (properties == null) throw new ArgumentNullException(nameof(properties));
var currentSubjectId = (await GetUserAsync())?.GetSubjectId();
var newSubjectId = principal.GetSubjectId();
if (!properties.Items.ContainsKey(SessionIdKey) || currentSubjectId != newSubjectId)
{
properties.Items[SessionIdKey] = CryptoRandom.CreateUniqueId(16);
}
IssueSessionIdCookie(properties.Items[SessionIdKey]);
Principal = principal;
Properties = properties;
}
private void IssueSessionIdCookie(string sid)
{
if (Options.Endpoints.EnableCheckSessionEndpoint)
{
if (GetSessionIdCookieValue() != sid)
{
HttpContext.Response.Cookies.Append(
Options.Authentication.CheckSessionCookieName,
sid,
CreateSessionIdCookieOptions());
}
}
}
什么是最好的方法?
繁花不似锦
相关分类