如果已经在本网站或广泛的ServiceStack文档中回答过这些问题,我已经看过了,但是如果确实存在,我会很感激指针!
我一直试图敲定示例服务堆栈(1.0.35)服务,该服务演示了如何使用.NET核心(不是.NET 4.5.x)来使用OAuth2。
我找到this web page并添加了所描述的AuthFeature插件,这对于可用的提供程序似乎没问题。
我的问题:Yahoo,OpenId,Google和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
{
}
答案 0 :(得分:4)
ServiceStack的OAuth2依赖于DotNetOpenAuth,遗憾的是它不支持.NET Core,因此目前不支持OAuth2。