Azure active directory Azure B2C持久Cookie
我正在使用配置了一个身份提供商(LinkedIn)的Azure B2C。我有一个Web API(b2c承载身份验证)和一个Web应用程序MVC(b2c开放Id) 我正在尝试创建一个持久登录-这意味着用户可以从给定的设备+浏览器每90天通过LinkedIn登录一次 我得到的最接近的结果是,我在web应用程序中添加了IsPersistent=true代码以启用: 更新:更新了基于Azure B2C GA的代码。为了达到预览版的效果,我仍然使用自定义授权属性,但代码已更新:Azure active directory Azure B2C持久Cookie,azure-active-directory,azure-ad-b2c,Azure Active Directory,Azure Ad B2c,我正在使用配置了一个身份提供商(LinkedIn)的Azure B2C。我有一个Web API(b2c承载身份验证)和一个Web应用程序MVC(b2c开放Id) 我正在尝试创建一个持久登录-这意味着用户可以从给定的设备+浏览器每90天通过LinkedIn登录一次 我得到的最接近的结果是,我在web应用程序中添加了IsPersistent=true代码以启用: 更新:更新了基于Azure B2C GA的代码。为了达到预览版的效果,我仍然使用自定义授权属性,但代码已更新: protected ove
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
filterContext.HttpContext.GetOwinContext().Authentication.Challenge(
new AuthenticationProperties()
{
IsPersistent = true
});
base.HandleUnauthorizedRequest(filterContext);
}
但是,这仅在大约1小时内有效。可能是遵循访问和ID策略?刷新令牌没有限制-我不确定为什么“iPersistent”只有1小时
这就引出了这些问题:
任何想法或意见都将是伟大的 在执行以下操作后,我已经能够与B2C实现持久会话:
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
filterContext.HttpContext.GetOwinContext()
.Authentication.Challenge(
new AuthenticationProperties() { IsPersistent = true }
);
base.HandleUnauthorizedRequest(filterContext);
}
return new OpenIdConnectAuthenticationOptions
{
MetadataAddress = String.Format(aadInstance, tenant, policy),
AuthenticationType = policy,
UseTokenLifetime = false,
ClientId = clientId,
RedirectUri = redirectUri,
PostLogoutRedirectUri = redirectUri,
Notifications = new OpenIdConnectAuthenticationNotifications
{
AuthenticationFailed = OnAuthenticationFailed,
AuthorizationCodeReceived = OnAuthorizationCodeReceived,
},
Scope = "openid offline_access",
ResponseType = "code id_token",
TokenValidationParameters = new TokenValidationParameters
{
NameClaimType = "name",
SaveSigninToken = true,
},
}