簡體   English   中英

Azure B2C保持在MVC 6 .Net Core 2中的簽名

[英]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)功能,如下所示:

https://docs.microsoft.com/zh-CN/azure/active-directory-b2c/active-directory-b2c-reference-kmsi-custom

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM