微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

AzureADDefaults 已过时

如何解决AzureADDefaults 已过时

我有以下 Azure AD 身份验证代码

pitch / sizeof(datatype)

AzureADDefaults.AuthenticationScheme 和 AzureADDefaults.OpenIdScheme 现在已过时,消息“改用 Microsoft.Identity.Web。请参阅 https://aka.ms/ms-identity-web."。但是我找不到任何明确的文档如何升级以下代码以使用 Identity.Web而不是那些过时的常量。

有人知道如何删除这个过时的代码吗?

解决方法

blog 向您展示了 Identity PlatformIdentity.Web 之间的区别。

对于 Identity.Web,我们使用 Microsoft.Identity.WebMicrosoft.Identity.Web.UI。尝试查看此 sample,它使用 AddMicrosoftIdentityWebAppAuthentication 来登录用户。

    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        services.Configure<CookiePolicyOptions>(options =>
        {
            // This lambda determines whether user consent for non-essential cookies is needed for a given request.
            options.CheckConsentNeeded = context => true;
            options.MinimumSameSitePolicy = SameSiteMode.Unspecified;
            // Handling SameSite cookie according to https://docs.microsoft.com/en-us/aspnet/core/security/samesite?view=aspnetcore-3.1
            options.HandleSameSiteCookieCompatibility();
        });

        // Sign-in users with the Microsoft identity platform
        services.AddMicrosoftIdentityWebAppAuthentication(Configuration);

        services.AddControllersWithViews(options =>
        {
            var policy = new AuthorizationPolicyBuilder()
                .RequireAuthenticatedUser()
                .Build();
            options.Filters.Add(new AuthorizeFilter(policy));
        }).AddMicrosoftIdentityUI();

        services.AddRazorPages();
    }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。