[英]How to get list of Users from my Azure AD B2C in asp net core mvc app?
[英]Azure B2C Keep signed in MVC 6 .Net Core 2
我的WebApp中存在Azure B2C的問題。 每次關閉瀏覽器時,我都必須再次登錄。 這不是很方便。
有什么解決辦法嗎? 我已經測試了幾個(微軟)示例,效果相同。
啟動文件
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(auth =>
{
auth.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
auth.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
auth.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddAzureAdB2C(opts =>
{
Configuration.GetSection("Authentication:AzureAdB2C").Bind(opts);
})
.AddCookie(opts =>
{
opts.ExpireTimeSpan = TimeSpan.FromDays(14);
}
);
“ IsPersistent = true”是可能的解決方案,但沒有效果。
SessionController.cs
[HttpGet]
public IActionResult SignIn()
{
return Challenge(
new AuthenticationProperties { IsPersistent = true, RedirectUri = Url.Action("SignedIn") },
OpenIdConnectDefaults.AuthenticationScheme);
}
我找到了解決問題的方法。
具有Azure Active Directory身份驗證票證壽命的Microsoft.Owin.Security.OpenIdConnect
OpenIdConnectionOption-> UseLifeTime = false; (默認值)
或者,如果您不想跨會話保存應用程序cookie,並且使用的是Azure AD B2C自定義策略,則可以啟用“保持登錄狀態”(KMSI)功能,如下所示:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.