-
Notifications
You must be signed in to change notification settings - Fork 598
Standardize services.AddXyz() behavior with default config #1191
Comments
Interesting problem. How do I add stuff without using any config? Presumably that's also important. |
Good question, when you say 'without using any config'. There's two ways to interpret that question.
|
Yeah I think (2) is what I'm saying: I happen to have some config sections in config, but I don't want them to be used. But maybe that's not a problem? |
Yeah I'm not sure how big a problem this would be, I guess it depends on how much we end up putting in the config for templates by default, but I'm guessing it's mostly going to be strings, which you could just override in the action. |
Yeah maybe it's fine. @DamianEdwards - thoughts on having all the various AddXyz() ServiceCollection extension methods dig up config? I'm not crazy about that, but I'm not sure when it's problematic... |
I think there's some wider questions to ask here about how we want "convention based configuration" to work, but in the scope of those services that support named options for the purposes of (faux) multi-tenancy/instances, I think @HaoK proposal looks like a fair place to start (we'll likely tweak as we go of course, e.g. I wouldn't use the full type name but rather a nice short name). |
So we should probably get together and discuss this along with @davidfowl and whoever else ought to be there. |
Agreed this is a good starting point and that shorter names could be nicer. Should we group the keys in sections per area rather than putting dot separated namespaces in the keys? The convention also needs to be predictable when there are not named and named things. E.g. Named could always bind to sub keys nested under the key of the not named one: services.AddCookies(); // binds to AspNetCore:Authentication:Cookies (append :Default?)
services.AddCookies("Application"); // binds to AspNetCore:Authentication:Cookies:Application |
Well right now auth is the only thing with names, and luckily there's always a name for auth, even in the default case(its the name of the auth scheme), i.e. Cookies, Google, Facebook, so we don't have to do anything special for the default section from any other named section. An example for identity + auth ConfigureServices code: services.AddIdentity<ApplicationUser, ApplicationRole>().AddEntityFrameworkStores();
services.AddGoogleAuthentication();
services.AddFacebookAuthentication(); Config
|
So you'd have that compose with AddFacebook(options => ...)? E.g. I could define the events in code and the secrets in config? |
Yeah the idea is that all the AddXyz's will compose |
@HaoK - can you set up a mtg for this? |
New tracking issue with current POR: aspnet/MetaPackages#117 |
Should
AddXyz(o => o = { })
also register the default configuration binding? The complication is each auth can be called multiple times with the name overload, so one possible soln is to have an AddXyz that takes a name, and binds to the named section.Examples:
We also should add more support in the binder for things like PathString which cannot be bound today.
@glennc @ajcvickers @divega @DamianEdwards @davidfowl @Eilon @Tratcher
The text was updated successfully, but these errors were encountered: