Skip to content

Commit 88997b3

Browse files
authored
Convert to C# configuration (#536)
1 parent de446b7 commit 88997b3

File tree

4 files changed

+30
-35
lines changed

4 files changed

+30
-35
lines changed

9.0/BlazorWebAppEntra/BlazorWebAppEntra/Program.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,21 @@
1616
.AddAuthenticationStateSerialization(options => options.SerializeAllClaims = true);
1717

1818
builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
19-
.AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd"))
19+
.AddMicrosoftIdentityWebApp(msIdentityOptions =>
20+
{
21+
msIdentityOptions.CallbackPath = "/signin-oidc";
22+
msIdentityOptions.ClientId = "{CLIENT ID (BLAZOR APP)}";
23+
msIdentityOptions.Domain = "{DIRECTORY NAME}.onmicrosoft.com";
24+
msIdentityOptions.Instance = "https://login.microsoftonline.com/";
25+
msIdentityOptions.ResponseType = "code";
26+
msIdentityOptions.TenantId = "{TENANT ID}";
27+
})
2028
.EnableTokenAcquisitionToCallDownstreamApi()
21-
.AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi"))
29+
.AddDownstreamApi("DownstreamApi", configOptions =>
30+
{
31+
configOptions.BaseUrl = "{BASE URL}";
32+
configOptions.Scopes = [ "{APP ID URI}/Weather.Get" ];
33+
})
2234
.AddInMemoryTokenCaches();
2335

2436
builder.Services.AddAuthorization();
Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
11
{
2-
/*
3-
The following identity settings need to be configured
4-
before the project can be successfully executed.
5-
For more info see https://aka.ms/dotnet-template-ms-identity-platform
6-
*/
7-
"AzureAd": {
8-
"CallbackPath": "/signin-oidc",
9-
"ClientId": "{CLIENT ID}",
10-
"Domain": "{TENANT DOMAIN}",
11-
"Instance": "https://login.microsoftonline.com/",
12-
"ResponseType": "code",
13-
"TenantId": "{TENANT ID}"
14-
},
152
"Logging": {
163
"LogLevel": {
174
"Default": "Information",
185
"Microsoft.AspNetCore": "Warning"
196
}
207
},
21-
"AllowedHosts": "*",
22-
"DownstreamApi": {
23-
"BaseUrl": "{BASE ADDRESS}",
24-
"Scopes": [ "{APP ID URI}/{SCOPE NAME}" ]
25-
}
8+
"AllowedHosts": "*"
269
}

9.0/BlazorWebAppEntraBff/BlazorWebAppEntra/Program.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,21 @@
1313

1414
// Add services to the container.
1515
builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
16-
.AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd"))
16+
.AddMicrosoftIdentityWebApp(msIdentityOptions =>
17+
{
18+
msIdentityOptions.CallbackPath = "/signin-oidc";
19+
msIdentityOptions.ClientId = "{CLIENT ID (BLAZOR APP)}";
20+
msIdentityOptions.Domain = "{DIRECTORY NAME}.onmicrosoft.com";
21+
msIdentityOptions.Instance = "https://login.microsoftonline.com/";
22+
msIdentityOptions.ResponseType = "code";
23+
msIdentityOptions.TenantId = "{TENANT ID}";
24+
})
1725
.EnableTokenAcquisitionToCallDownstreamApi()
18-
.AddDownstreamApi("DownstreamApi", builder.Configuration.GetSection("DownstreamApi"))
26+
.AddDownstreamApi("DownstreamApi", configOptions =>
27+
{
28+
configOptions.BaseUrl = "{BASE URL}";
29+
configOptions.Scopes = [ "{APP ID URI}/Weather.Get" ];
30+
})
1931
.AddInMemoryTokenCaches();
2032

2133
builder.Services.AddOptions<OpenIdConnectOptions>(OpenIdConnectDefaults.AuthenticationScheme).Configure(oidcOptions =>
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
11
{
2-
"AzureAd": {
3-
"CallbackPath": "/signin-oidc",
4-
"ClientId": "{CLIENT ID}",
5-
"Domain": "{TENANT DOMAIN}",
6-
"Instance": "https://login.microsoftonline.com/",
7-
"ResponseType": "code",
8-
"TenantId": "{TENANT ID}"
9-
},
102
"Logging": {
113
"LogLevel": {
124
"Default": "Information",
135
"Microsoft.AspNetCore": "Warning"
146
}
157
},
16-
"AllowedHosts": "*",
17-
"DownstreamApi": {
18-
"BaseUrl": "{BASE ADDRESS}",
19-
"Scopes": [ "{APP ID URI}/{SCOPE}" ]
20-
}
8+
"AllowedHosts": "*"
219
}

0 commit comments

Comments
 (0)