Description
For the BFF Entra pivot & sample ...
- The sample will hardcode the request transformer scopes.
- The article section on config will call out the manual config.
- The article section on using app settings config will show the app settings and code to draw the scopes from configuration.
app.MapForwarder("/weather-forecast", "https://weatherapi", transformBuilder =>
{
transformBuilder.AddRequestTransform(async transformContext =>
{
var tokenAcquisition = transformContext.HttpContext.RequestServices.GetRequiredService<ITokenAcquisition>();
List<string> scopes = ["{APP ID URI}/Weather.Get"];
var accessToken = await tokenAcquisition.GetAccessTokenForUserAsync(scopes);
transformContext.ProxyRequest.Headers.Authorization = new("Bearer", accessToken);
});
}).RequireAuthorization();
var configuration = transformContext.HttpContext.RequestServices.GetRequiredService<IConfiguration>();
var scopes = configuration.GetSection("DownstreamApi:Scopes").Get<IEnumerable<string>>();
var accessToken = await tokenAcquisition.GetAccessTokenForUserAsync(scopes ??
throw new IOException("No downstream API scopes!"));
"DownstreamApi": {
"BaseUrl": "{BASE URL}",
"Scopes": [ "{APP ID URI}/Weather.Get" ]
}
Page URL
https://learn.microsoft.com/en-us/aspnet/core/blazor/security/blazor-web-app-with-entra?view=aspnetcore-9.0
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/security/blazor-web-app-with-entra.md
Document ID
58758d13-94c9-e208-e0f6-16676834413c
Platform Id
1c89a093-14c3-881b-7297-49c7c6cb4ea1
Article author
@guardrex
Metadata
- ID: 58758d13-94c9-e208-e0f6-16676834413c
- PlatformId: 1c89a093-14c3-881b-7297-49c7c6cb4ea1
- Service: aspnet-core
- Sub-service: blazor
Related Issues
Description
For the BFF Entra pivot & sample ...
Page URL
https://learn.microsoft.com/en-us/aspnet/core/blazor/security/blazor-web-app-with-entra?view=aspnetcore-9.0
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/security/blazor-web-app-with-entra.md
Document ID
58758d13-94c9-e208-e0f6-16676834413c
Platform Id
1c89a093-14c3-881b-7297-49c7c6cb4ea1
Article author
@guardrex
Metadata
Related Issues