如果已在本網站或廣泛的ServiceStack文檔中得到回答,我們表示歉意 - 我已看過,但如果確實存在,我將不勝感激!ServiceStack .NET核心的OAuth2身份驗證插件
我一直在試圖敲起一個示例服務堆棧(1.0.35)服務,它演示了使用.NET核心(不是.NET 4.5.x)的OAuth2的使用。
我找到了this web page,並添加了所描述的AuthFeature插件,這對於可用的提供者來說似乎很好。
我的問題:雅虎,的OpenID,谷歌和LinkedIn提供商不會出現在ServiceStack.Auth命名空間的一部分(沒有?)。我已經看過了Servicestack.Authentication.OAuth2 NuGET包,但這似乎是針對.NET 4.6.x.這個功能是否可用,或者是ServiceStack .NET核心的路線圖?我的演示應用程序的
全碼回購:
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
{
}
我打算編寫一個與.NET核心兼容的ServiceStack.Auth.OAuth2.OAuth2Provider端口作爲OSS,但首先我要查看它是否已經完成。任何人之前做過? –
同時在https://servicestack.uservoice.com/forums/176786-feature-requests/suggestions/19534429-support-oauth2-on-net-core –