Skip to content

[Documentation] Documentation of new AOT support #3741

@kevincathcart-cas

Description

@kevincathcart-cas

Documentation related to component

AOT support

Please check all that apply

  • typo
  • documentation doesn't exist
  • documentation needs clarification
  • error(s) in the example
  • needs an example

Description of the issue

Prose documentation of the new AOT stuff would be beneficial.

If a user currently has code like:

    builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
        .AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAd"))
        .EnableTokenAcquisitionToCallDownstreamApi()
        .AddMicrosoftGraph()
        .AddInMemoryTokenCaches();

It is not hard to figure out that you want to map AddMicrosoftIdentityWebApi to:

    var azureAdSection = builder.Configuration.GetSection("AzureAd");
    builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
        .AddMicrosoftIdentityWebApiAot(o=>azureAdSection.Bind(o), JwtBearerDefaults.AuthenticationScheme, null);

However, it is a lot less obvious that EnableTokenAcquisitionToCallDownstreamApi should map to either nothing if only OBO calls are needed, or binding ConfidentialClientApplicationOptions with the authentication scheme name, using any method that supports the source generator (one approach of several shown below):

    builder.Services.Configure<ConfidentialClientApplicationOptions>(JwtBearerDefaults.AuthenticationScheme, azureAdSection); 

It also isn't completely obvious that the calls following EnableTokenAcquisitionToCallDownstreamApi simply get moved to be made on builder.Services instead:

    builder.Services
        .AddMicrosoftGraph()
        .AddInMemoryTokenCaches();

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions