在现有的WebForms Web应用程序上实现微软认证(win)。

问题描述 投票:0回答:1

我正试图在现有的WebForms Web应用程序上实现微软认证(win)。我不能使用微软的官方指南,因为它们是为现代的MVC解决方案制作的。

有什么提示可以从哪里开始?我找不到任何指南。

asp.net-mvc azure authentication webforms azure-active-directory
1个回答
1
投票

请按照该文件,它可以帮助你在旧的.NET窗体使用。OWIN表格中间件 并将此中间件用于Azure AD身份验证,请按照以下步骤操作 文件.


0
投票

安装Microsoft.Owin.Security.Cookies的包右键点击项目上的App_Start文件夹添加->新项目-> "OWIN启动类"

然后创建以下文件夹

    public void Configuration(IAppBuilder app)
    {
        CookieAuthenticationOptions opt = new CookieAuthenticationOptions();
        opt.AuthenticationType = CookieAuthenticationDefaults.AuthenticationType;// "Identity.Application";
        opt.CookieName = ".SSO";
        opt.CookieDomain = "localhost";
        opt.SlidingExpiration = true;

        ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("192.168.1.96:6379");
        IDataProtector proc = DataProtectionProvider.Create(new DirectoryInfo(@"C:\test\core"), buildAction => 
            buildAction.SetApplicationName("MyApp").SetDefaultKeyLifetime(TimeSpan.FromDays(9000)).ProtectKeysWithDpapi().PersistKeysToStackExchangeRedis(redis)).CreateProtector("Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", "Cookies", "v2");

        DataProtectorShim shim = new DataProtectorShim(proc);

        opt.TicketDataFormat = new AspNetTicketDataFormat(shim);

        app.UseCookieAuthentication(opt);
    }
© www.soinside.com 2019 - 2024. All rights reserved.