Sorry if this has already been answered on this site or in the extensive ServiceStack documentation - I looked, but if it really exists, I would appreciate a pointer!
I tried to bring down the service stack service example (1.0.35), which demonstrates using OAuth2 using the .NET kernel (not .NET 4.5.x).
I found this web page and added the AuthFeature plugin as described, which seems to be suitable for available providers.
My question is . Providers of Yahoo, OpenId, Google, and LinkedIn are not part of the ServiceStack.Auth namespace (yet?). I looked at the Servicestack.Authentication.OAuth2 NuGET package, but it seems to be targeting .NET 4.6.x. Is this functionality available or in the roadmap for the ServiceStack.NET kernel?
Full repo code of my demo application:
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),
new CredentialsAuthProvider(),
new BasicAuthProvider(),
new DigestAuthProvider(AppSettings),
new TwitterAuthProvider(AppSettings),
new FacebookAuthProvider(AppSettings),
new GithubAuthProvider(AppSettings),
new YandexAuthProvider(AppSettings),
new VkAuthProvider(AppSettings),
}));
}
}
public class MyService : Service
{
}
source
share