diff --git a/eng/Versions.props b/eng/Versions.props index 444074e1980f..793c8e31c654 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -269,9 +269,10 @@ 6.0.4 6.0.4 2.5.108 - 1.16.0 - 1.16.0 - 1.16.0 + 2.10.0 + 2.10.0 + 2.10.0 + 2.10.0 $(MessagePackVersion) 4.10.0 0.11.2 diff --git a/src/Framework/AspNetCoreAnalyzers/test/RouteHandlers/DisallowNonParsableComplexTypesOnParametersTest.cs b/src/Framework/AspNetCoreAnalyzers/test/RouteHandlers/DisallowNonParsableComplexTypesOnParametersTest.cs index aaa80f6db2c1..6651effa31fa 100644 --- a/src/Framework/AspNetCoreAnalyzers/test/RouteHandlers/DisallowNonParsableComplexTypesOnParametersTest.cs +++ b/src/Framework/AspNetCoreAnalyzers/test/RouteHandlers/DisallowNonParsableComplexTypesOnParametersTest.cs @@ -648,10 +648,10 @@ public async Task Handler_Parameter_withServiceInterface_Works() using Microsoft.AspNetCore.Builder; var webApp = WebApplication.Create(); -webApp.MapGet("/weatherforecast", (HttpContext context, IDownstreamWebApi downstreamWebApi) => {}); +webApp.MapGet("/weatherforecast", (HttpContext context, IDownstreamApi downstreamApi) => {}); // This type doesn't need to be parsable because it should be assumed to be a service type. -public interface IDownstreamWebApi +public interface IDownstreamApi { } """; diff --git a/src/ProjectTemplates/Web.ProjectTemplates/BlazorServerWeb-CSharp.csproj.in b/src/ProjectTemplates/Web.ProjectTemplates/BlazorServerWeb-CSharp.csproj.in index 27c7c22f3c2c..d7786a9e09d1 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/BlazorServerWeb-CSharp.csproj.in +++ b/src/ProjectTemplates/Web.ProjectTemplates/BlazorServerWeb-CSharp.csproj.in @@ -31,6 +31,7 @@ + diff --git a/src/ProjectTemplates/Web.ProjectTemplates/ComponentsWebAssembly-CSharp.Server.csproj.in b/src/ProjectTemplates/Web.ProjectTemplates/ComponentsWebAssembly-CSharp.Server.csproj.in index 5d2cb0e520ee..b40abaead722 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/ComponentsWebAssembly-CSharp.Server.csproj.in +++ b/src/ProjectTemplates/Web.ProjectTemplates/ComponentsWebAssembly-CSharp.Server.csproj.in @@ -45,6 +45,7 @@ + diff --git a/src/ProjectTemplates/Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj b/src/ProjectTemplates/Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj index 67ffc2559937..bfa7944a0d62 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj +++ b/src/ProjectTemplates/Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj @@ -22,6 +22,7 @@ MicrosoftIdentityWebVersion=$(MicrosoftIdentityWebVersion); MicrosoftIdentityWebMicrosoftGraphVersion=$(MicrosoftIdentityWebMicrosoftGraphVersion); MicrosoftIdentityWebUIVersion=$(MicrosoftIdentityWebUIVersion); + MicrosoftIdentityWebDownstreamApiVersion=$(MicrosoftIdentityWebDownstreamApiVersion); MicrosoftNETCoreAppRuntimeVersion=$(MicrosoftNETCoreAppRuntimeVersion); SystemNetHttpJsonVersion=$(SystemNetHttpJsonVersion); MicrosoftGraphVersion=$(MicrosoftGraphVersion); diff --git a/src/ProjectTemplates/Web.ProjectTemplates/RazorPagesWeb-CSharp.csproj.in b/src/ProjectTemplates/Web.ProjectTemplates/RazorPagesWeb-CSharp.csproj.in index 6048bfc0fb4a..bb4de59b14bc 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/RazorPagesWeb-CSharp.csproj.in +++ b/src/ProjectTemplates/Web.ProjectTemplates/RazorPagesWeb-CSharp.csproj.in @@ -29,6 +29,7 @@ + diff --git a/src/ProjectTemplates/Web.ProjectTemplates/StarterWeb-CSharp.csproj.in b/src/ProjectTemplates/Web.ProjectTemplates/StarterWeb-CSharp.csproj.in index b1cc65340e1d..444453017f10 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/StarterWeb-CSharp.csproj.in +++ b/src/ProjectTemplates/Web.ProjectTemplates/StarterWeb-CSharp.csproj.in @@ -29,6 +29,7 @@ + diff --git a/src/ProjectTemplates/Web.ProjectTemplates/WebApi-CSharp.csproj.in b/src/ProjectTemplates/Web.ProjectTemplates/WebApi-CSharp.csproj.in index e79188f36d01..0e825ca5f248 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/WebApi-CSharp.csproj.in +++ b/src/ProjectTemplates/Web.ProjectTemplates/WebApi-CSharp.csproj.in @@ -18,6 +18,7 @@ + diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Pages/CallWebApi.razor b/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Pages/CallWebApi.razor index beac855d317a..b6132c605ec0 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Pages/CallWebApi.razor +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Pages/CallWebApi.razor @@ -2,8 +2,9 @@ @using BlazorServerWeb_CSharp @using Microsoft.Identity.Web +@using Microsoft.Identity.Abstractions -@inject IDownstreamWebApi downstreamAPI +@inject IDownstreamApi downstreamAPI @inject MicrosoftIdentityConsentAndConditionalAccessHandler ConsentHandler

Call an API

@@ -28,7 +29,7 @@ else { try { - response = await downstreamAPI.CallWebApiForUserAsync( + response = await downstreamAPI.CallApiForUserAsync( "DownstreamApi", options => options.RelativePath = ""); diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Program.Main.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Program.Main.cs index cc3c8ab895b3..ca30b112ea8c 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Program.Main.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Program.Main.cs @@ -67,7 +67,7 @@ public static void Main(string[] args) .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd")) .EnableTokenAcquisitionToCallDownstreamApi(initialScopes) #if (GenerateApi) - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) #endif #if (GenerateGraph) .AddMicrosoftGraph(builder.Configuration.GetSection("DownstreamApi")) @@ -85,7 +85,7 @@ public static void Main(string[] args) #if (GenerateApi) .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAdB2C")) .EnableTokenAcquisitionToCallDownstreamApi(initialScopes) - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) .AddInMemoryTokenCaches(); #else .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAdB2C")); diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Program.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Program.cs index 8056669b00f8..0b1391e4464b 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Program.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Program.cs @@ -61,7 +61,7 @@ .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd")) .EnableTokenAcquisitionToCallDownstreamApi(initialScopes) #if (GenerateApi) - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) #endif #if (GenerateGraph) .AddMicrosoftGraph(builder.Configuration.GetSection("DownstreamApi")) @@ -79,7 +79,7 @@ #if (GenerateApi) .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAdB2C")) .EnableTokenAcquisitionToCallDownstreamApi(initialScopes) - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) .AddInMemoryTokenCaches(); #else .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAdB2C")); diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/appsettings.json b/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/appsettings.json index 5292d34e9e9a..03d1f8518f77 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/appsettings.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/appsettings.json @@ -41,14 +41,16 @@ For more info see https:////aka.ms/dotnet-template-ms-identity-platform ////#if (GenerateApiOrGraph) // "DownstreamApi": { // /* -// 'Scopes' contains space separated scopes of the Web API you want to call. This can be: +// 'Scopes' contains scopes of the Web API you want to call. This can be: // - a scope for a V2 application (for instance api://b3682cc7-8b30-4bd2-aaba-080c6bf0fd31/access_as_user) // - a scope corresponding to a V1 application (for instance /.default, where is the // App ID URI of a legacy v1 Web application // Applications are registered in the https://portal.azure.com portal. // */ // "BaseUrl": "[WebApiUrl]", -// "Scopes": "user.read" +// "Scopes": [ +// "user.read" +// ] // }, ////#endif ////#if (IndividualLocalAuth) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Controllers/WeatherForecastController.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Controllers/WeatherForecastController.cs index 52fab2ac5dbb..7f9c35470eb7 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Controllers/WeatherForecastController.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Controllers/WeatherForecastController.cs @@ -3,6 +3,7 @@ #endif #if (GenerateApi) using Microsoft.Identity.Web; +using Microsoft.Identity.Abstractions; using System.Net; #endif #if (GenerateGraph) @@ -36,19 +37,19 @@ public class WeatherForecastController : ControllerBase private readonly ILogger _logger; #if (GenerateApi) - private readonly IDownstreamWebApi _downstreamWebApi; + private readonly IDownstreamApi _downstreamApi; public WeatherForecastController(ILogger logger, - IDownstreamWebApi downstreamWebApi) + IDownstreamApi downstreamApi) { _logger = logger; - _downstreamWebApi = downstreamWebApi; + _downstreamApi = downstreamApi; } [HttpGet] public async Task> Get() { - using var response = await _downstreamWebApi.CallWebApiForUserAsync("DownstreamApi").ConfigureAwait(false); + using var response = await _downstreamApi.CallApiForUserAsync("DownstreamApi").ConfigureAwait(false); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var apiResult = await response.Content.ReadAsStringAsync().ConfigureAwait(false); diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Program.Main.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Program.Main.cs index cc52a2ed54b9..c503b8292039 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Program.Main.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Program.Main.cs @@ -53,7 +53,7 @@ public static void Main(string[] args) .AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAd")) .EnableTokenAcquisitionToCallDownstreamApi() #if (GenerateApi) - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) #endif #if (GenerateGraph) .AddMicrosoftGraph(builder.Configuration.GetSection("DownstreamApi")) @@ -67,7 +67,7 @@ public static void Main(string[] args) #if (GenerateApi) .AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAdB2C")) .EnableTokenAcquisitionToCallDownstreamApi() - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) .AddInMemoryTokenCaches(); #else .AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAdB2C")); diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Program.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Program.cs index 3a44aefeb9f9..885e23ce075f 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Program.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Program.cs @@ -47,7 +47,7 @@ .AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAd")) .EnableTokenAcquisitionToCallDownstreamApi() #if (GenerateApi) - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) #endif #if (GenerateGraph) .AddMicrosoftGraph(builder.Configuration.GetSection("DownstreamApi")) @@ -61,7 +61,7 @@ #if (GenerateApi) .AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAdB2C")) .EnableTokenAcquisitionToCallDownstreamApi() - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) .AddInMemoryTokenCaches(); #else .AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAdB2C")); diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/appsettings.json b/src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/appsettings.json index 2117429dd5d2..04c6aa7aedfa 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/appsettings.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/appsettings.json @@ -52,14 +52,16 @@ For more info see https:////aka.ms/dotnet-template-ms-identity-platform ////#if (GenerateApiOrGraph) // "DownstreamApi": { // /* -// 'Scopes' contains space separated scopes of the Web API you want to call. This can be: +// 'Scopes' contains scopes of the Web API you want to call. This can be: // - a scope for a V2 application (for instance api://b3682cc7-8b30-4bd2-aaba-080c6bf0fd31/access_as_user) // - a scope corresponding to a V1 application (for instance /.default, where is the // App ID URI of a legacy v1 Web application // Applications are registered in the https://portal.azure.com portal. // */ // "BaseUrl": "[WebApiUrl]", -// "Scopes": "user.read" +// "Scopes": [ +// "user.read" +// ] // }, ////#endif "Logging": { diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Pages/Index.cshtml.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Pages/Index.cshtml.cs index af4794371e82..1e6a3050e5e5 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Pages/Index.cshtml.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Pages/Index.cshtml.cs @@ -1,4 +1,4 @@ -#if (GenerateApiOrGraph) +#if (GenerateApiOrGraph) using System.Net; #endif using Microsoft.AspNetCore.Mvc; @@ -8,6 +8,7 @@ #endif #if (GenerateApiOrGraph) using Microsoft.Identity.Web; +using Microsoft.Identity.Abstractions; #endif namespace Company.WebApplication1.Pages; @@ -20,18 +21,18 @@ public class IndexModel : PageModel private readonly ILogger _logger; #if (GenerateApi) - private readonly IDownstreamWebApi _downstreamWebApi; + private readonly IDownstreamApi _downstreamApi; public IndexModel(ILogger logger, - IDownstreamWebApi downstreamWebApi) + IDownstreamApi downstreamApi) { _logger = logger; - _downstreamWebApi = downstreamWebApi; + _downstreamApi = downstreamApi; } public async Task OnGet() { - using var response = await _downstreamWebApi.CallWebApiForUserAsync("DownstreamApi").ConfigureAwait(false); + using var response = await _downstreamApi.CallApiForUserAsync("DownstreamApi").ConfigureAwait(false); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var apiResult = await response.Content.ReadAsStringAsync().ConfigureAwait(false); diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Program.Main.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Program.Main.cs index dd471686ceeb..bce4b6039495 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Program.Main.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Program.Main.cs @@ -62,7 +62,7 @@ public static void Main(string[] args) .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd")) .EnableTokenAcquisitionToCallDownstreamApi(initialScopes) #if (GenerateApi) - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) #endif #if (GenerateGraph) .AddMicrosoftGraph(builder.Configuration.GetSection("DownstreamApi")) @@ -80,7 +80,7 @@ public static void Main(string[] args) #if (GenerateApi) .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAdB2C")) .EnableTokenAcquisitionToCallDownstreamApi(initialScopes) - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) .AddInMemoryTokenCaches(); #else .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAdB2C")); diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Program.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Program.cs index 936ac7591442..948286a94361 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Program.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Program.cs @@ -56,7 +56,7 @@ .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd")) .EnableTokenAcquisitionToCallDownstreamApi(initialScopes) #if (GenerateApi) - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) #endif #if (GenerateGraph) .AddMicrosoftGraph(builder.Configuration.GetSection("DownstreamApi")) @@ -74,7 +74,7 @@ #if (GenerateApi) .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAdB2C")) .EnableTokenAcquisitionToCallDownstreamApi(initialScopes) - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) .AddInMemoryTokenCaches(); #else .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAdB2C")); diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/appsettings.json b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/appsettings.json index cf9667fd139f..1d8c4ecbe393 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/appsettings.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/appsettings.json @@ -41,14 +41,16 @@ For more info see https:////aka.ms/dotnet-template-ms-identity-platform ////#if (GenerateApiOrGraph) // "DownstreamApi": { // /* -// 'Scopes' contains space separated scopes of the Web API you want to call. This can be: +// 'Scopes' contains scopes of the Web API you want to call. This can be: // - a scope for a V2 application (for instance api://b3682cc7-8b30-4bd2-aaba-080c6bf0fd31/access_as_user) // - a scope corresponding to a V1 application (for instance /.default, where is the // App ID URI of a legacy v1 Web application // Applications are registered in the https://portal.azure.com portal. // */ // "BaseUrl": "[WebApiUrl]", -// "Scopes": "user.read" +// "Scopes": [ +// "user.read" +// ] // }, ////#endif ////#if (IndividualLocalAuth) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Controllers/HomeController.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Controllers/HomeController.cs index 93e8d95a2afb..d5674f6c5408 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Controllers/HomeController.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Controllers/HomeController.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Diagnostics; #if (GenerateApiOrGraph) using System.Net; #endif @@ -11,6 +11,7 @@ #endif #if (GenerateApiOrGraph) using Microsoft.Identity.Web; +using Microsoft.Identity.Abstractions; #endif using Company.WebApplication1.Models; @@ -24,19 +25,19 @@ public class HomeController : Controller private readonly ILogger _logger; #if (GenerateApi) - private readonly IDownstreamWebApi _downstreamWebApi; + private readonly IDownstreamApi _downstreamApi; public HomeController(ILogger logger, - IDownstreamWebApi downstreamWebApi) + IDownstreamApi downstreamApi) { _logger = logger; - _downstreamWebApi = downstreamWebApi; + _downstreamApi = downstreamApi; } [AuthorizeForScopes(ScopeKeySection = "DownstreamApi:Scopes")] public async Task Index() { - using var response = await _downstreamWebApi.CallWebApiForUserAsync("DownstreamApi").ConfigureAwait(false); + using var response = await _downstreamApi.CallApiForUserAsync("DownstreamApi").ConfigureAwait(false); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var apiResult = await response.Content.ReadAsStringAsync().ConfigureAwait(false); diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Program.Main.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Program.Main.cs index 4cd34b1c9aee..f7d20fa0f2ee 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Program.Main.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Program.Main.cs @@ -62,7 +62,7 @@ public static void Main(string[] args) .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd")) .EnableTokenAcquisitionToCallDownstreamApi(initialScopes) #if (GenerateApi) - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) #endif #if (GenerateGraph) .AddMicrosoftGraph(builder.Configuration.GetSection("DownstreamApi")) @@ -80,7 +80,7 @@ public static void Main(string[] args) #if (GenerateApi) .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAdB2C")) .EnableTokenAcquisitionToCallDownstreamApi(initialScopes) - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) .AddInMemoryTokenCaches(); #else .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAdB2C")); diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Program.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Program.cs index 8d79c7c94330..46a9fd064067 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Program.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Program.cs @@ -56,7 +56,7 @@ .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd")) .EnableTokenAcquisitionToCallDownstreamApi(initialScopes) #if (GenerateApi) - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) #endif #if (GenerateGraph) .AddMicrosoftGraph(builder.Configuration.GetSection("DownstreamApi")) @@ -74,7 +74,7 @@ #if (GenerateApi) .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAdB2C")) .EnableTokenAcquisitionToCallDownstreamApi(initialScopes) - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) .AddInMemoryTokenCaches(); #else .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAdB2C")); diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/appsettings.json b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/appsettings.json index d3278a7dd48e..b77e611d8915 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/appsettings.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/appsettings.json @@ -41,14 +41,16 @@ For more info see https:////aka.ms/dotnet-template-ms-identity-platform ////#if (GenerateApiOrGraph) // "DownstreamApi": { // /* -// 'Scopes' contains space separated scopes of the Web API you want to call. This can be: +// 'Scopes' contains scopes of the Web API you want to call. This can be: // - a scope for a V2 application (for instance api://b3682cc7-8b30-4bd2-aaba-080c6bf0fd31/access_as_user) // - a scope corresponding to a V1 application (for instance /.default, where is the // App ID URI of a legacy v1 Web application // Applications are registered in the https://portal.azure.com portal. // */ // "BaseUrl": "[WebApiUrl]", -// "Scopes": "user.read" +// "Scopes": [ +// "user.read" +// ] // }, ////#endif ////#if (IndividualLocalAuth) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Controllers/WeatherForecastController.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Controllers/WeatherForecastController.cs index 1db80ec1fac3..1f0cd2dcae98 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Controllers/WeatherForecastController.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Controllers/WeatherForecastController.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc; #if (GenerateApi) using Microsoft.Identity.Web; +using Microsoft.Identity.Abstractions; #endif #if (OrganizationalAuth || IndividualB2CAuth) using Microsoft.Identity.Web.Resource; @@ -35,13 +36,13 @@ public class WeatherForecastController : ControllerBase private readonly ILogger _logger; #if (GenerateApi) - private readonly IDownstreamWebApi _downstreamWebApi; + private readonly IDownstreamApi _downstreamApi; public WeatherForecastController(ILogger logger, - IDownstreamWebApi downstreamWebApi) + IDownstreamApi downstreamApi) { _logger = logger; - _downstreamWebApi = downstreamWebApi; + _downstreamApi = downstreamApi; } #if (EnableOpenAPI) @@ -51,7 +52,7 @@ public WeatherForecastController(ILogger logger, #endif public async Task> Get() { - using var response = await _downstreamWebApi.CallWebApiForUserAsync("DownstreamApi").ConfigureAwait(false); + using var response = await _downstreamApi.CallApiForUserAsync("DownstreamApi").ConfigureAwait(false); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var apiResult = await response.Content.ReadAsStringAsync().ConfigureAwait(false); diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.Main.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.Main.cs index b74c5afce180..314d3412d3dc 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.Main.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.Main.cs @@ -10,6 +10,7 @@ #endif #if (OrganizationalAuth || IndividualB2CAuth) using Microsoft.Identity.Web; +using Microsoft.Identity.Abstractions; using Microsoft.Identity.Web.Resource; #endif #if (OrganizationalAuth || IndividualB2CAuth || GenerateGraph || WindowsAuth || EnableOpenAPI) @@ -30,7 +31,7 @@ public static void Main(string[] args) .AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAd")) .EnableTokenAcquisitionToCallDownstreamApi() #if (GenerateApi) - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) #endif #if (GenerateGraph) .AddMicrosoftGraph(builder.Configuration.GetSection("DownstreamApi")) @@ -44,7 +45,7 @@ public static void Main(string[] args) #if (GenerateApi) .AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAdB2C")) .EnableTokenAcquisitionToCallDownstreamApi() - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) .AddInMemoryTokenCaches(); #else .AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAdB2C")); @@ -101,11 +102,11 @@ public static void Main(string[] args) }; #if (GenerateApi) - app.MapGet("/weatherforecast", async (HttpContext httpContext, IDownstreamWebApi downstreamWebApi) => + app.MapGet("/weatherforecast", async (HttpContext httpContext, IDownstreamApi downstreamApi) => { httpContext.VerifyUserHasAnyAcceptedScope(scopeRequiredByApi); - using var response = await downstreamWebApi.CallWebApiForUserAsync("DownstreamApi").ConfigureAwait(false); + using var response = await downstreamApi.CallApiForUserAsync("DownstreamApi").ConfigureAwait(false); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var apiResult = await response.Content.ReadAsStringAsync().ConfigureAwait(false); diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.MinimalAPIs.OrgOrIndividualB2CAuth.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.MinimalAPIs.OrgOrIndividualB2CAuth.cs index d767b12fd007..587cb84bdd24 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.MinimalAPIs.OrgOrIndividualB2CAuth.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.MinimalAPIs.OrgOrIndividualB2CAuth.cs @@ -7,6 +7,7 @@ using Graph = Microsoft.Graph; #endif using Microsoft.Identity.Web; +using Microsoft.Identity.Abstractions; using Microsoft.Identity.Web.Resource; var builder = WebApplication.CreateBuilder(args); @@ -18,7 +19,7 @@ .AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAd")) .EnableTokenAcquisitionToCallDownstreamApi() #if (GenerateApi) - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) #endif #if (GenerateGraph) .AddMicrosoftGraph(builder.Configuration.GetSection("DownstreamApi")) @@ -32,7 +33,7 @@ #if (GenerateApi) .AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAdB2C")) .EnableTokenAcquisitionToCallDownstreamApi() - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) .AddInMemoryTokenCaches(); #else .AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAdB2C")); @@ -68,11 +69,11 @@ }; #if (GenerateApi) -app.MapGet("/weatherforecast", async (HttpContext httpContext, IDownstreamWebApi downstreamWebApi) => +app.MapGet("/weatherforecast", async (HttpContext httpContext, IDownstreamApi downstreamApi) => { httpContext.VerifyUserHasAnyAcceptedScope(scopeRequiredByApi); - using var response = await downstreamWebApi.CallWebApiForUserAsync("DownstreamApi").ConfigureAwait(false); + using var response = await downstreamApi.CallApiForUserAsync("DownstreamApi").ConfigureAwait(false); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var apiResult = await response.Content.ReadAsStringAsync().ConfigureAwait(false); diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.cs index 28d3caf7546d..d63b3aa1d734 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.cs @@ -23,7 +23,7 @@ .AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAd")) .EnableTokenAcquisitionToCallDownstreamApi() #if (GenerateApi) - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) #endif #if (GenerateGraph) .AddMicrosoftGraph(builder.Configuration.GetSection("DownstreamApi")) @@ -37,7 +37,7 @@ #if (GenerateApi) .AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAdB2C")) .EnableTokenAcquisitionToCallDownstreamApi() - .AddDownstreamWebApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) + .AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi")) .AddInMemoryTokenCaches(); #else .AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAdB2C")); diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/appsettings.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/appsettings.json index e2b8fc294a06..674807ffa7d8 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/appsettings.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/appsettings.json @@ -45,14 +45,16 @@ For more info see https:////aka.ms/dotnet-template-ms-identity-platform ////#if (GenerateApiOrGraph) // "DownstreamApi": { // /* -// 'Scopes' contains space separated scopes of the Web API you want to call. This can be: +// 'Scopes' contains scopes of the Web API you want to call. This can be: // - a scope for a V2 application (for instance api://b3682cc7-8b30-4bd2-aaba-080c6bf0fd31/access_as_user) // - a scope corresponding to a V1 application (for instance /.default, where is the // App ID URI of a legacy v1 Web application // Applications are registered in the https://portal.azure.com portal. // */ // "BaseUrl": "[WebApiUrl]", -// "Scopes": "user.read" +// "Scopes": [ +// "user.read" +// ] // }, ////#endif "Logging": {