Is there a way to use Dependency Injection to configure the cookie authentication options? I would like to get some of the settings from the database, but I don't have access to the DatabaseContext at this point.
public void ConfigureServices(IServiceCollection services)
{
...
services
.AddAuthentication(Authentication.scheme)
.AddCookie(Authentication.scheme, options =>
{
options.ExpireTimeSpan = new TimeSpan(30, 0, 0, 0, 0);
options.Cookie.IsEssential = true;
options.Cookie.Name = ".AUTH-Cookie";
options.ReturnUrlParameter = "returnUrl";
options.LoginPath = "/Security/SignIn";
options.LogoutPath = "/Security/SignOut";
options.EventsType = typeof(CookieAuthenticationEvents);
});
...
}
I'm able to use AddOptions() and Configure() to do this with other items in ConfigureServices, but I can't figure out how to do it with the CookieAuthenticationOptions...
services
.AddOptions<MvcOptions>()
.Configure<IDisplayMetadataProvider>((options, localizationMetadataProvider) =>
{
options.ModelMetadataDetailsProviders.Add(localizationMetadataProvider);
});
I tried to do the same thing with CookieAuthenticationOptions, but it doesn't appear to work the same way...