c# - Asp.NET MVC 5 IdentityServer4 外部供应商

标签 c# asp.net asp.net-mvc identityserver4

使用 IdentityServer3,一种配置外部身份验证提供程序的方法被添加到应用程序的启动方法中

    internal class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            var microsoft = new MicrosoftAccountAuthenticationOptions()
            {
                AuthenticationType = "Microsoft",
                ClientId = "********",
                ClientSecret = "********"
            };
            app.UseMicrosoftAccountAuthentication(microsoft);
            ....
        }
    }

在 IdentityServer4 中,一切都是围绕 IApplicationBuilder 接口(interface)设计的,它没有上述方法。

    public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
    {
       ....
    }

这是否意味着在 V4 中尚不支持外部提供者身份验证?

我尝试在 Configure 方法中注入(inject) IAppBuilder 但没有成功,但这将是一个非常困惑的解决方案......

有什么想法吗?谢谢

最佳答案

谢谢大家,

我认为我取得了一些重大进展。问题是我试图将旧的 OWIN 引用添加到我的解决方案中,而不是采用新的 AspNet 身份验证。

“Microsoft.AspNet.Authentication.MicrosoftAccount”:“1.0.0-rc1-final”

我找到了解决方案 here .

使用 IApplicationBuilder 的事件可以注册外部提供者,如下所述

        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
    {
        ...
        app.UseMicrosoftAccountAuthentication(options =>
        {
            options.ClientId = Configuration["AppSettings:AzureClientId"];
            options.ClientSecret = Configuration["AppSettings:AzureClientSecret"];
            options.AuthenticationScheme = "Microsoft";
            options.SignInScheme = "Cookies";
            options.CallbackPath = new PathString("/signin-microsoft");
            options.AuthorizationEndpoint = MicrosoftAccountDefaults.AuthorizationEndpoint;
            options.TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint;
        });
    }

关于c# - Asp.NET MVC 5 IdentityServer4 外部供应商,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35589801/

相关文章:

c# - ASP.NET MVC : Routing custom slugs without affecting performance

c# - 绑定(bind)到MVVM WPF中的窗口关闭事件?

asp.net - 在预编译的部署网站中添加附属程序集

javascript - 单击链接时使用 AJAX 在 Kendo 窗口中加载数据

c# - 使用 MVCContrib 对 MVC 3 Controller 和 View 进行单元测试时,将键和值添加到 RouteData

c# - 测试 URL 和查询字符串是否有效

c# - 如何在 c#.net Web 应用程序中读取 pdf 文件中的文本

尽管未使用 C# 方法仍抛出异常

c# - Enumerable.Except 不使用我的自定义比较器

c# - 在 C#.NET 中捕获所有未处理的异常的简单方法