Closed
Description
Why?
As developers use more IDownstreamApi, standardize the description of a collection of Downstream APIs, and register them all at once.
In the appsettings.json, customers could describe their APIs in a particular section, and Microsoft.Identity.Web should be able to add them all.
"AzureAd" : {
},
"DownstreamApi":
{
"MyApi1": {
"BaseUrl" : "https://myservice.com",
"Scopes" : [ "access_as_admin" ],
"RequestAppToken" : true
},
"MyApi2": {
"BaseUrl" : "https://myOtherService.com",
"Scopes" : [ "access_as_user" ],
}
}
What?
Have an API, in DownstreamApiExtensions that takes a IConfigurationSection
services.AddDownstreamApis(Configuration.GetSection("DownstreamApis")
This would deserialize the section as a Dictionary<string, DownstreamApiOptions>, register the DownstreamApi service, and keep the Options in named options.
P2: Also add a method:
AddDownstrsamApis(IConfiguration, Action<Dictionary<string, DownstreamApiOptions>> configureOptions)
How
Dictionary<string, DownstreamApiOptions> dictionaryOfDownstreamApiOptionsByServiceName;
foreach(var optionsForService in dictionaryOfDownstreamApiOptionsByServiceName)
{
services.Configure(optionsForService.Key, optionsForService.Value);
}
RegisterDownstreamApi(services)