Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions 10.0/BlazorWebAppEntra/BlazorWebAppEntra/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
.AddInteractiveWebAssemblyComponents()
.AddAuthenticationStateSerialization(options => options.SerializeAllClaims = true);

// Configure authentication to use Microsoft Entra ID
builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(msIdentityOptions =>
{
Expand All @@ -41,6 +42,30 @@
})
.AddDistributedTokenCaches();

// Configure authentication to use Microsoft Entra External ID
//
// Instead of the preceding configuration for Microsoft Entra ID, use the
// following configuration for Microsoft Entra External ID. Comment out or
// remove the preceding 'AddAuthentication' configuration if you activate
// the following code.
/*
builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(msIdentityOptions =>
{
msIdentityOptions.CallbackPath = "/signin-oidc";
msIdentityOptions.Authority = "https://{DIRECTORY NAME}.ciamlogin.com/{TENANT ID}/v2.0";
msIdentityOptions.ClientId = "{CLIENT ID (BLAZOR APP)}";
msIdentityOptions.ResponseType = "code";
})
.EnableTokenAcquisitionToCallDownstreamApi()
.AddDownstreamApi("DownstreamApi", configOptions =>
{
configOptions.BaseUrl = "{BASE URL}";
configOptions.Scopes = ["{APP ID URI}/Weather.Get"];
})
.AddDistributedTokenCaches();
*/

builder.Services.AddDistributedMemoryCache();

builder.Services.Configure<MsalDistributedTokenCacheAdapterOptions>(
Expand Down
8 changes: 5 additions & 3 deletions 10.0/BlazorWebAppEntra/MinimalApiJwt/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
//
// Authority format {AUTHORITY} matches the issurer (`iss`) of the JWT returned by the identity provider.
//
// Authority format {AUTHORITY} for ME-ID tenant type: https://sts.windows.net/{TENANT ID}/
// Authority format {AUTHORITY} for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0/
// Authority format {AUTHORITY} for ME-ID tenant type: https://sts.windows.net/{TENANT ID}
// Authority format {AUTHORITY} for ME External ID tenant type: https://{DIRECTORY NAME}.ciamlogin.com/{TENANT ID}/v2.0
// Authority format {AUTHORITY} for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0
//
jwtOptions.Authority = "{AUTHORITY}";
//
// The following should match just the path of the Application ID URI configured when adding the "Weather.Get" scope
// under "Expose an API" in the Azure or Entra portal. {CLIENT ID} is the application (client) ID of this
// app's registration in the Azure portal.
//
// Audience format {AUDIENCE} for ME-ID tenant type: api://{CLIENT ID (WEB API APP)
// Audience format {AUDIENCE} for ME-ID tenant type: api://{CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for ME External ID tenant type: {CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for B2C tenant type: https://{DIRECTORY NAME}.onmicrosoft.com/{CLIENT ID (WEB API APP)}
//
jwtOptions.Audience = "{AUDIENCE}";
Expand Down
27 changes: 26 additions & 1 deletion 10.0/BlazorWebAppEntraBff/BlazorWebAppEntra/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
// Add service defaults & Aspire components.
builder.AddServiceDefaults();

// Add services to the container.
// Configure authentication to use Microsoft Entra ID
builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(msIdentityOptions =>
{
Expand All @@ -35,6 +36,30 @@
})
.AddDistributedTokenCaches();

// Configure authentication to use Microsoft Entra External ID
//
// Instead of the preceding configuration for Microsoft Entra ID, use the
// following configuration for Microsoft Entra External ID. Comment out or
// remove the preceding 'AddAuthentication' configuration if you activate
// the following code.
/*
builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(msIdentityOptions =>
{
msIdentityOptions.CallbackPath = "/signin-oidc";
msIdentityOptions.Authority = "https://{DIRECTORY NAME}.ciamlogin.com/{TENANT ID}/v2.0";
msIdentityOptions.ClientId = "{CLIENT ID (BLAZOR APP)}";
msIdentityOptions.ResponseType = "code";
})
.EnableTokenAcquisitionToCallDownstreamApi()
.AddDownstreamApi("DownstreamApi", configOptions =>
{
configOptions.BaseUrl = "{BASE URL}";
configOptions.Scopes = ["{APP ID URI}/Weather.Get"];
})
.AddDistributedTokenCaches();
*/

builder.Services.AddDistributedMemoryCache();

builder.Services.Configure<MsalDistributedTokenCacheAdapterOptions>(
Expand Down
12 changes: 7 additions & 5 deletions 10.0/BlazorWebAppEntraBff/MinimalApiJwt/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
{
// {TENANT ID} in the following examples is the directory (tenant) ID.
//
// Authority format '{AUTHORITY}' matches the issurer (`iss`) of the JWT returned by the identity provider.
// Authority format {AUTHORITY} matches the issurer (`iss`) of the JWT returned by the identity provider.
//
// Authority format '{AUTHORITY}' for ME-ID tenant type: https://sts.windows.net/{TENANT ID}/
// Authority format '{AUTHORITY}' for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0/
// Authority format {AUTHORITY} for ME-ID tenant type: https://sts.windows.net/{TENANT ID}
// Authority format {AUTHORITY} for ME External ID tenant type: https://{DIRECTORY NAME}.ciamlogin.com/{TENANT ID}/v2.0
// Authority format {AUTHORITY} for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0
//
jwtOptions.Authority = "{AUTHORITY}";

Expand All @@ -20,8 +21,9 @@
// under "Expose an API" in the Azure or Entra portal. {CLIENT ID} is the application (client) ID of this
// app's registration in the Azure portal.
//
// Audience format '{AUDIENCE}' for ME-ID tenant type: api://{CLIENT ID (WEB API APP)}
// Audience format '{AUDIENCE}' for B2C tenant type: https://{DIRECTORY NAME}.onmicrosoft.com/{CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for ME-ID tenant type: api://{CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for ME External ID tenant type: {CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for B2C tenant type: https://{DIRECTORY NAME}.onmicrosoft.com/{CLIENT ID (WEB API APP)}
//
jwtOptions.Audience = "{AUDIENCE}";
});
Expand Down
6 changes: 4 additions & 2 deletions 10.0/BlazorWebAppOidc/MinimalApiJwt/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
//
// Authority format {AUTHORITY} matches the issurer (`iss`) of the JWT returned by the identity provider.
//
// Authority format {AUTHORITY} for ME-ID tenant type: https://sts.windows.net/{TENANT ID}/
// Authority format {AUTHORITY} for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0/
// Authority format {AUTHORITY} for ME-ID tenant type: https://sts.windows.net/{TENANT ID}
// Authority format {AUTHORITY} for ME External ID tenant type: https://{DIRECTORY NAME}.ciamlogin.com/{TENANT ID}/v2.0
// Authority format {AUTHORITY} for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0
//
jwtOptions.Authority = "{AUTHORITY}";
//
Expand All @@ -17,6 +18,7 @@
// app's registration in the Azure portal.
//
// Audience format {AUDIENCE} for ME-ID tenant type: api://{CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for ME External ID tenant type: {CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for B2C tenant type: https://{DIRECTORY NAME}.onmicrosoft.com/{CLIENT ID (WEB API APP)}
//
jwtOptions.Audience = "{AUDIENCE}";
Expand Down
6 changes: 4 additions & 2 deletions 8.0/BlazorWebAppOidc/MinimalApiJwt/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
//
// Authority format {AUTHORITY} matches the issurer (`iss`) of the JWT returned by the identity provider.
//
// Authority format {AUTHORITY} for ME-ID tenant type: https://sts.windows.net/{TENANT ID}/
// Authority format {AUTHORITY} for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0/
// Authority format {AUTHORITY} for ME-ID tenant type: https://sts.windows.net/{TENANT ID}
// Authority format {AUTHORITY} for ME External ID tenant type: https://{DIRECTORY NAME}.ciamlogin.com/{TENANT ID}/v2.0
// Authority format {AUTHORITY} for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0
//
jwtOptions.Authority = "{AUTHORITY}";
//
Expand All @@ -17,6 +18,7 @@
// app's registration in the Azure portal.
//
// Audience format {AUDIENCE} for ME-ID tenant type: api://{CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for ME External ID tenant type: {CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for B2C tenant type: https://{DIRECTORY NAME}.onmicrosoft.com/{CLIENT ID (WEB API APP)}
//
jwtOptions.Audience = "{AUDIENCE}";
Expand Down
6 changes: 4 additions & 2 deletions 8.0/BlazorWebAppOidcBff/MinimalApiJwt/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
//
// Authority format {AUTHORITY} matches the issurer (`iss`) of the JWT returned by the identity provider.
//
// Authority format {AUTHORITY} for ME-ID tenant type: https://sts.windows.net/{TENANT ID}/
// Authority format {AUTHORITY} for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0/
// Authority format {AUTHORITY} for ME-ID tenant type: https://sts.windows.net/{TENANT ID}
// Authority format {AUTHORITY} for ME External ID tenant type: https://{DIRECTORY NAME}.ciamlogin.com/{TENANT ID}/v2.0
// Authority format {AUTHORITY} for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0
//
jwtOptions.Authority = "{AUTHORITY}";
//
Expand All @@ -20,6 +21,7 @@
// app's registration in the Azure portal.
//
// Audience format {AUDIENCE} for ME-ID tenant type: api://{CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for ME External ID tenant type: {CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for B2C tenant type: https://{DIRECTORY NAME}.onmicrosoft.com/{CLIENT ID (WEB API APP)}
//
jwtOptions.Audience = "{AUDIENCE}";
Expand Down
6 changes: 4 additions & 2 deletions 8.0/BlazorWebAppOidcServer/MinimalApiJwt/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
//
// Authority format {AUTHORITY} matches the issurer (`iss`) of the JWT returned by the identity provider.
//
// Authority format {AUTHORITY} for ME-ID tenant type: https://sts.windows.net/{TENANT ID}/
// Authority format {AUTHORITY} for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0/
// Authority format {AUTHORITY} for ME-ID tenant type: https://sts.windows.net/{TENANT ID}
// Authority format {AUTHORITY} for ME External ID tenant type: https://{DIRECTORY NAME}.ciamlogin.com/{TENANT ID}/v2.0
// Authority format {AUTHORITY} for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0
//
jwtOptions.Authority = "{AUTHORITY}";
//
Expand All @@ -17,6 +18,7 @@
// app's registration in the Azure portal.
//
// Audience format {AUDIENCE} for ME-ID tenant type: api://{CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for ME External ID tenant type: {CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for B2C tenant type: https://{DIRECTORY NAME}.onmicrosoft.com/{CLIENT ID (WEB API APP)}
//
jwtOptions.Audience = "{AUDIENCE}";
Expand Down
6 changes: 4 additions & 2 deletions 9.0/BlazorWebAppEntra/MinimalApiJwt/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
//
// Authority format {AUTHORITY} matches the issurer (`iss`) of the JWT returned by the identity provider.
//
// Authority format {AUTHORITY} for ME-ID tenant type: https://sts.windows.net/{TENANT ID}/
// Authority format {AUTHORITY} for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0/
// Authority format {AUTHORITY} for ME-ID tenant type: https://sts.windows.net/{TENANT ID}
// Authority format {AUTHORITY} for ME External ID tenant type: https://{DIRECTORY NAME}.ciamlogin.com/{TENANT ID}/v2.0
// Authority format {AUTHORITY} for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0
//
jwtOptions.Authority = "{AUTHORITY}";
//
Expand All @@ -17,6 +18,7 @@
// app's registration in the Azure portal.
//
// Audience format {AUDIENCE} for ME-ID tenant type: api://{CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for ME External ID tenant type: {CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for B2C tenant type: https://{DIRECTORY NAME}.onmicrosoft.com/{CLIENT ID (WEB API APP)}
//
jwtOptions.Audience = "{AUDIENCE}";
Expand Down
12 changes: 7 additions & 5 deletions 9.0/BlazorWebAppEntraBff/MinimalApiJwt/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@
{
// {TENANT ID} in the following examples is the directory (tenant) ID.
//
// Authority format '{AUTHORITY}' matches the issurer (`iss`) of the JWT returned by the identity provider.
// Authority format {AUTHORITY} matches the issurer (`iss`) of the JWT returned by the identity provider.
//
// Authority format '{AUTHORITY}' for ME-ID tenant type: https://sts.windows.net/{TENANT ID}/
// Authority format '{AUTHORITY}' for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0/
// Authority format {AUTHORITY} for ME-ID tenant type: https://sts.windows.net/{TENANT ID}
// Authority format {AUTHORITY} for ME External ID tenant type: https://{DIRECTORY NAME}.ciamlogin.com/{TENANT ID}/v2.0
// Authority format {AUTHORITY} for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0
//
jwtOptions.Authority = "{AUTHORITY}";
//
// The following should match just the path of the Application ID URI configured when adding the "Weather.Get" scope
// under "Expose an API" in the Azure or Entra portal. {CLIENT ID} is the application (client) ID of this
// app's registration in the Azure portal.
//
// Audience format '{AUDIENCE}' for ME-ID tenant type: api://{CLIENT ID (WEB API APP)}
// Audience format '{AUDIENCE}' for B2C tenant type: https://{DIRECTORY NAME}.onmicrosoft.com/{CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for ME-ID tenant type: api://{CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for ME External ID tenant type: {CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for B2C tenant type: https://{DIRECTORY NAME}.onmicrosoft.com/{CLIENT ID (WEB API APP)}
//
jwtOptions.Audience = "{AUDIENCE}";
});
Expand Down
6 changes: 4 additions & 2 deletions 9.0/BlazorWebAppOidc/MinimalApiJwt/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
//
// Authority format {AUTHORITY} matches the issurer (`iss`) of the JWT returned by the identity provider.
//
// Authority format {AUTHORITY} for ME-ID tenant type: https://sts.windows.net/{TENANT ID}/
// Authority format {AUTHORITY} for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0/
// Authority format {AUTHORITY} for ME-ID tenant type: https://sts.windows.net/{TENANT ID}
// Authority format {AUTHORITY} for ME External ID tenant type: https://{DIRECTORY NAME}.ciamlogin.com/{TENANT ID}/v2.0
// Authority format {AUTHORITY} for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0
//
jwtOptions.Authority = "{AUTHORITY}";
//
Expand All @@ -17,6 +18,7 @@
// app's registration in the Azure portal.
//
// Audience format {AUDIENCE} for ME-ID tenant type: api://{CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for ME External ID tenant type: {CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for B2C tenant type: https://{DIRECTORY NAME}.onmicrosoft.com/{CLIENT ID (WEB API APP)}
//
jwtOptions.Audience = "{AUDIENCE}";
Expand Down
6 changes: 4 additions & 2 deletions 9.0/BlazorWebAppOidcBff/MinimalApiJwt/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
//
// Authority format {AUTHORITY} matches the issurer (`iss`) of the JWT returned by the identity provider.
//
// Authority format {AUTHORITY} for ME-ID tenant type: https://sts.windows.net/{TENANT ID}/
// Authority format {AUTHORITY} for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0/
// Authority format {AUTHORITY} for ME-ID tenant type: https://sts.windows.net/{TENANT ID}
// Authority format {AUTHORITY} for ME External ID tenant type: https://{DIRECTORY NAME}.ciamlogin.com/{TENANT ID}/v2.0
// Authority format {AUTHORITY} for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0
//
jwtOptions.Authority = "{AUTHORITY}";
//
Expand All @@ -20,6 +21,7 @@
// app's registration in the Azure portal.
//
// Audience format {AUDIENCE} for ME-ID tenant type: api://{CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for ME External ID tenant type: {CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for B2C tenant type: https://{DIRECTORY NAME}.onmicrosoft.com/{CLIENT ID (WEB API APP)}
//
jwtOptions.Audience = "{AUDIENCE}";
Expand Down
6 changes: 4 additions & 2 deletions 9.0/BlazorWebAppOidcServer/MinimalApiJwt/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
//
// Authority format {AUTHORITY} matches the issurer (`iss`) of the JWT returned by the identity provider.
//
// Authority format {AUTHORITY} for ME-ID tenant type: https://sts.windows.net/{TENANT ID}/
// Authority format {AUTHORITY} for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0/
// Authority format {AUTHORITY} for ME-ID tenant type: https://sts.windows.net/{TENANT ID}
// Authority format {AUTHORITY} for ME External ID tenant type: https://{DIRECTORY NAME}.ciamlogin.com/{TENANT ID}/v2.0
// Authority format {AUTHORITY} for B2C tenant type: https://login.microsoftonline.com/{TENANT ID}/v2.0
//
jwtOptions.Authority = "{AUTHORITY}";
//
Expand All @@ -17,6 +18,7 @@
// app's registration in the Azure portal.
//
// Audience format {AUDIENCE} for ME-ID tenant type: api://{CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for ME External ID tenant type: {CLIENT ID (WEB API APP)}
// Audience format {AUDIENCE} for B2C tenant type: https://{DIRECTORY NAME}.onmicrosoft.com/{CLIENT ID (WEB API APP)}
//
jwtOptions.Audience = "{AUDIENCE}";
Expand Down