Skip to content

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

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)

Activity

  1. 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))[/+] on Apr 21, 2024
  2. added this to the 2.18 milestone on Apr 22, 2024
  3. self-assigned this
    on Apr 22, 2024
  4. jennyf19 commented on Apr 22, 2024

    @jennyf19
    Collaborator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions