Skip to content

Commit 0ba646f

Browse files
author
Tiago Brenck
authored
Merge pull request #174 from Azure-Samples/tibre/mergeFixes
Merge Fixes
2 parents e6c7c61 + b651f4d commit 0ba646f

File tree

4 files changed

+20
-27
lines changed

4 files changed

+20
-27
lines changed

4-WebApp-your-API/Client/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void ConfigureServices(IServiceCollection services)
4040
// By default, the claims mapping will map claim names in the old format to accommodate older SAML applications.
4141
// 'http://schemas.microsoft.com/ws/2008/06/identity/claims/role' instead of 'roles'
4242
// This flag ensures that the ClaimsIdentity claims collection will be built from the claims in the token
43-
JwtSecurityTokenHandler.DefaultMapInboundClaims = false;
43+
//JwtSecurityTokenHandler.DefaultMapInboundClaims = false;
4444

4545
// Token acquisition service based on MSAL.NET
4646
// and chosen token cache implementation

4-WebApp-your-API/TodoListService/Startup.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,9 @@ public void ConfigureServices(IServiceCollection services)
5151
// By default, the claims mapping will map claim names in the old format to accommodate older SAML applications.
5252
// 'http://schemas.microsoft.com/ws/2008/06/identity/claims/role' instead of 'roles'
5353
// This flag ensures that the ClaimsIdentity claims collection will be built from the claims in the token
54-
JwtSecurityTokenHandler.DefaultMapInboundClaims = false;
54+
//JwtSecurityTokenHandler.DefaultMapInboundClaims = false;
5555

5656
services.AddProtectedWebApi(Configuration);
57-
services.Configure<JwtBearerOptions>(AzureADDefaults.JwtBearerAuthenticationScheme, options =>
58-
{
59-
options.TokenValidationParameters.NameClaimType = "name";
60-
});
6157

6258
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
6359
}
Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
{
2-
"AzureAd": {
3-
"Instance": "https://login.microsoftonline.com/",
4-
"Domain": "kalyankrishna.com",
5-
"TenantId": "4d39e77c-b0f3-4253-ae0b-7068ddd47949",
6-
"ClientId": "7f1d4458-72e7-41b5-ad81-103bd6e307b7",
7-
"CallbackPath": "/signin-oidc",
8-
"SignedOutCallbackPath ": "/signout-callback-oidc",
2+
"AzureAd": {
3+
"Instance": "https://login.microsoftonline.com/",
4+
"Domain": "[Enter the domain of your tenant, e.g. contoso.onmicrosoft.com]",
5+
"TenantId": "[Enter 'common', or 'organizations' or the Tenant Id (Obtained from the Azure portal. Select 'Endpoints' from the 'App registrations' blade and use the GUID in any of the URLs), e.g. da41245a5-11b3-996c-00a8-4d99re19f292]",
6+
"ClientId": "[Enter the Client Id (Application ID obtained from the Azure portal), e.g. ba74781c2-53c2-442a-97c2-3d60re42f403]",
7+
"CallbackPath": "/signin-oidc",
8+
"SignedOutCallbackPath ": "/signout-callback-oidc",
99

10-
// To call an API
11-
"ClientSecret": "9Y7lZKjDwKYZC3Ut1S8Dzg3TmAqVEJKUIbmIbH0jMdM="
12-
13-
},
14-
"Logging": {
15-
"LogLevel": {
16-
"Default": "Warning"
17-
}
18-
},
19-
"AllowedHosts": "*",
20-
"GraphApiUrl": "https://graph.microsoft.com/beta"
10+
// To call an API
11+
"ClientSecret": "[Copy the client secret added to the app from the Azure portal]"
12+
},
13+
"Logging": {
14+
"LogLevel": {
15+
"Default": "Warning"
16+
}
17+
},
18+
"AllowedHosts": "*",
19+
"GraphApiUrl": "https://graph.microsoft.com/beta"
2120
}

Microsoft.Identity.Web/WebApiServiceCollectionExtensions.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,10 @@ public static IServiceCollection AddProtectedWebApi(
4141
string configSectionName = "AzureAD",
4242
bool subscribeToJwtBearerMiddlewareDiagnosticsEvents = false)
4343
{
44-
services.Configure<AzureADOptions>(options => configuration.Bind(configSectionName, options));
4544
services.AddAuthentication(AzureADDefaults.JwtBearerAuthenticationScheme)
4645
.AddAzureADBearer(options => configuration.Bind(configSectionName, options));
4746

48-
// Add session if you are planning to use session based token cache , .AddSessionTokenCaches()
49-
// services.AddSession(); // Commented as we cannot force session on someone who wants to use an alternative token cache provider.
47+
services.AddHttpContextAccessor();
5048

5149
// Change the authentication configuration to accommodate the Microsoft identity platform endpoint (v2.0).
5250
services.Configure<JwtBearerOptions>(AzureADDefaults.JwtBearerAuthenticationScheme, options =>

0 commit comments

Comments
 (0)