Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ServiceStack.NET核心的OAuth2身份验证插件_C#_Oauth 2.0_<img Src="//i.stack.imgur.com/WM7S8.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">servicestack_.net Core - Fatal编程技术网 servicestack,.net-core,C#,Oauth 2.0,servicestack,.net Core" /> servicestack,.net-core,C#,Oauth 2.0,servicestack,.net Core" />

C# ServiceStack.NET核心的OAuth2身份验证插件

C# ServiceStack.NET核心的OAuth2身份验证插件,c#,oauth-2.0,servicestack,.net-core,C#,Oauth 2.0,servicestack,.net Core,如果此网站或广泛的ServiceStack文档中已经回答了此问题,我深表歉意-我已经看过了,但如果确实存在此问题,我将非常感谢您的指点 我一直在尝试构建一个示例服务堆栈(1.0.35)服务,该服务演示了使用.NETCore(而不是.NET4.5.x)使用OAuth2的情况 我已经找到并添加了AuthFeature插件,如前所述,对于可用的提供者来说,这似乎很好 我的问题:Yahoo、OpenId、Google和LinkedIn提供商没有出现在ServiceStack.Auth命名空间中(还没有?

如果此网站或广泛的ServiceStack文档中已经回答了此问题,我深表歉意-我已经看过了,但如果确实存在此问题,我将非常感谢您的指点

我一直在尝试构建一个示例服务堆栈(1.0.35)服务,该服务演示了使用.NETCore(而不是.NET4.5.x)使用OAuth2的情况

我已经找到并添加了AuthFeature插件,如前所述,对于可用的提供者来说,这似乎很好

我的问题:Yahoo、OpenId、Google和LinkedIn提供商没有出现在ServiceStack.Auth命名空间中(还没有?)。我已经看过Servicestack.Authentication.OAuth2 NuGET包,但它似乎是针对.NET 4.6.x的。此功能是否可用,或者是否在ServiceStack.NET core的路线图上

我的演示应用程序的完整代码回购:

namespace ServiceStackAuthTest1
{
public class Program
{
    public static void Main(string[] args)
    {
        IWebHost host = new WebHostBuilder()
           .UseKestrel()
           .UseContentRoot(Directory.GetCurrentDirectory())
           .UseStartup<Startup>()
           .UseUrls("http://*:40000/")
           .Build();

        host.Run();
    }
}

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddLogging();

    }


    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        app.UseServiceStack((AppHostBase)Activator.CreateInstance<AppHost>());

        app.Run((RequestDelegate)(context => (Task)Task.FromResult<int>(0)));
    }

}

public class AppHost : AppHostBase
{
    public AppHost() 
        : base("My Test Service", typeof(MyService).GetAssembly())
    {
    }

    public override void Configure(Container container)
    {
        Plugins.Add(new AuthFeature(() => new AuthUserSession(),
            new IAuthProvider[]
            {
                new JwtAuthProvider(AppSettings)
                {
                    HashAlgorithm = "RS256",
                    PrivateKeyXml = AppSettings.GetString("PrivateKeyXml")
                },
                new ApiKeyAuthProvider(AppSettings), //Sign-in with API Key
                new CredentialsAuthProvider(), //Sign-in with UserName/Password credentials
                new BasicAuthProvider(), //Sign-in with HTTP Basic Auth
                new DigestAuthProvider(AppSettings), //Sign-in with HTTP Digest Auth
                new TwitterAuthProvider(AppSettings), //Sign-in with Twitter
                new FacebookAuthProvider(AppSettings), //Sign-in with Facebook
                //new YahooOpenIdOAuthProvider(AppSettings), //Sign-in with Yahoo OpenId
                //new OpenIdOAuthProvider(AppSettings), //Sign-in with Custom OpenId
                //new GoogleOAuth2Provider(AppSettings), //Sign-in with Google OAuth2 Provider
                //new LinkedInOAuth2Provider(AppSettings), //Sign-in with LinkedIn OAuth2 Provider
                new GithubAuthProvider(AppSettings), //Sign-in with GitHub OAuth Provider
                new YandexAuthProvider(AppSettings), //Sign-in with Yandex OAuth Provider        
                new VkAuthProvider(AppSettings), //Sign-in with VK.com OAuth Provider 
            }));
    }
}

public class MyService : Service
{

}
命名空间服务StackAuthTest1
{
公共课程
{
公共静态void Main(字符串[]args)
{
IWebHost主机=新WebHostBuilder()
.UseKestrel()
.UseContentRoot(目录.GetCurrentDirectory())
.UseStartup()
.useURL(“http://*:40000/”)
.Build();
host.Run();
}
}
公营创业
{
public void配置服务(IServiceCollection服务)
{
services.AddLogging();
}
公共无效配置(IApplicationBuilder应用程序,IHostingEnvironment环境)
{
app.UseServiceStack((AppHostBase)Activator.CreateInstance());
运行((RequestDelegate)(上下文=>(任务)任务.FromResult(0));
}
}
公共类AppHost:AppHostBase
{
公共AppHost()
:base(“我的测试服务”,typeof(MyService).GetAssembly())
{
}
公共覆盖无效配置(容器)
{
Add(新建AuthFeature(()=>新建AuthUserSession(),
新IAuthProvider[]
{
新JwtAuthProvider(AppSettings)
{
HashAlgorithm=“RS256”,
PrivateKeyXml=AppSettings.GetString(“PrivateKeyXml”)
},
新建ApiKeyAuthProvider(AppSettings),//使用API密钥登录
new CredentialAuthProvider(),//使用用户名/密码凭据登录
新建BasicAuthProvider(),//使用HTTP基本身份验证登录
新建DigestAuthProvider(AppSettings),//使用HTTP Digest Auth登录
新建TwitterAuthProvider(AppSettings),//使用Twitter登录
新建FacebookAuthProvider(AppSettings),//使用Facebook登录
//新建YahooOpenIdOAuthProvider(AppSettings),//使用Yahoo OpenId登录
//新建OpenIdOAuthProvider(AppSettings),//使用自定义OpenId登录
//新建Google OAuth2Provider(AppSettings),//使用Google OAuth2提供程序登录
//新建LinkedInOAuth2Provider(AppSettings),//使用LinkedIn OAuth2提供程序登录
新建GithubAuthProvider(AppSettings),//使用GitHub OAuth提供程序登录
新建Yandex AuthProvider(AppSettings),//使用Yandex OAuth提供程序登录
新建VkAuthProvider(AppSettings),//使用VK.com OAuth提供程序登录
}));
}
}
公共类MyService:Service
{
}

ServiceStack的OAuth2依赖于DotNetOpenAuth,不幸的是,DotNetOpenAuth不支持.NET Core,因此目前没有对OAuth2的支持。

那很好(感谢您的正式回答!)-我想知道是否有任何未来的计划来支持这些OAuth2提供商?我开始认为我可以(应该?)获取一个公共Nginx网守/反向代理类型的东西来处理身份验证,只需将相关令牌转发给我的内部服务堆栈服务。@Jay我们确实希望在.NET Core中支持OAuth2,只需找到一个有效的解决方案,并与ServiceStack进行最佳集成。@mythz有什么进展吗?Google auth是唯一可以防止的g我们不要迁移到.net core!@JMK还没有,所以我们可以衡量对这个问题的兴趣,你可以得到更新的通知。人们,当你需要这个功能时,投票支持它。我计划编写一个与.net core兼容的ServiceStack.Auth.OAuth2.OAuth2端口作为OSS,但首先我想看看是否已经完成了。有人完成了吗这之前?在这期间投票表决