Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add a method to read a section with Downstream apis (.AddDownstreamApis(IConfigurationSection)) #2255

Closed
jmprieur opened this issue May 22, 2023 · 1 comment
Assignees
Labels
Milestone

Comments

@jmprieur
Copy link
Collaborator

jmprieur commented May 22, 2023

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)
@jmprieur jmprieur added enhancement New feature or request feature request labels May 22, 2023
@jmprieur jmprieur added the 1P label Apr 21, 2024
@jmprieur jmprieur changed the title [Feature Request] Add a method to read a section with Downstream apis (.AddDownstreamApis(section name)) [Feature Request] Add a method to read a section with Downstream apis (.AddDownstreamApis(IConfigurationSection)) Apr 21, 2024
@jennyf19 jennyf19 added this to the 2.18 milestone Apr 22, 2024
@jennyf19 jennyf19 self-assigned this Apr 22, 2024
@jennyf19
Copy link
Collaborator

#2782

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants