Apologies if this is already answered on this site or in the extensive ServiceStack documentation - I have looked, but if it does exist, I would appreciate a pointer!
I've been trying to knock up an example service stack (1.0.35) service which demonstrates the usage of OAuth2 using .NET core (not .NET 4.5.x).
I have found this web page and have added the AuthFeature plugin as described, which seems to be fine for the providers that are available.
My question: The Yahoo, OpenId, Google and LinkedIn providers don't appear part of the ServiceStack.Auth namespace (yet?). I have looked at the Servicestack.Authentication.OAuth2 NuGET package, but this appears to be targeted at .NET 4.6.x. Is this functionality available or on the roadmap for ServiceStack .NET core?
Full Code repo of my demo app:
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
{
}
ServiceStack's OAuth2 depends on DotNetOpenAuth which unfortunately doesn't support .NET Core so there's currently no support for OAuth2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With