Skip to content

Instantly share code, notes, and snippets.

@jjwilliams42
Last active November 18, 2017 08:54
Show Gist options
  • Save jjwilliams42/142aa296654a1ee77cd2e7a6c8078f65 to your computer and use it in GitHub Desktop.
Save jjwilliams42/142aa296654a1ee77cd2e7a6c8078f65 to your computer and use it in GitHub Desktop.
Startup.cs - Configure
namespace Test
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions()
{
HotModuleReplacement = true,
ReactHotModuleReplacement = true
});
}
app.UseServiceStack(new AppHost());
}
}
public class AppHost : AppHostBase
{
...
// Configure your AppHost with the necessary configuration and dependencies your App needs
public override void Configure(Container container)
{
...
container.Register<IPasswordHasher<User>>(
new PasswordHasher<User>(new OptionsWrapper<PasswordHasherOptions>(new PasswordHasherOptions()
{
CompatibilityMode = PasswordHasherCompatibilityMode.IdentityV2
})));
container.Register<IPasswordHasher>(new CustomPasswordHasher(container.Resolve<IPasswordHasher<User>>()));
container.Register<IUserAuthRepository>(c => new CustomAuthRepository(c.Resolve<IDbConnectionFactory>()));
var authRepo = (CustomAuthRepository)container.Resolve<IUserAuthRepository>();
authRepo.InitSchema();
Plugins.AddRange(new IPlugin[]
{
new AuthFeature(() => new AuthUserSession(), new IAuthProvider[]
{
new CustomAuthProvider()
{
PersistSession = true
}
})
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment