Skip to content

Commit 8a1fd6a

Browse files
author
Tiago Brenck
authored
Merge pull request #84 from Azure-Samples/tibre/fix82
Sync README with code
2 parents ed5b48f + ff86fae commit 8a1fd6a

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

2-Call-OwnApi/README.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -265,26 +265,18 @@ The relevant code for this sample is in the `Program.cs` file, in the `RunAsync(
265265

266266
### TodoList Web API Code
267267

268-
The relevant code for the Web API is in the `Startup.cs` class. We are using the method `AddMicrosoftWebApiAuthentication` to configure the Web API to authenticate using bearer tokens, validate them and protect the API from non authorized calls. These are the steps:
268+
The relevant code for the Web API is in the `Startup.cs` class. We are using the method `AddMicrosoftWebApi` to configure the Web API to authenticate using bearer tokens, validate them and protect the API from non authorized calls. These are the steps:
269269

270270
1. Configuring the API to authenticate using bearer tokens
271271

272272
```CSharp
273-
// By default, the claims mapping will map claim names in the old format to accommodate older SAML applications.
274-
// 'http://schemas.microsoft.com/ws/2008/06/identity/claims/role' instead of 'roles'
275-
JwtSecurityTokenHandler.DefaultMapInboundClaims = false;
276-
277-
services.AddMicrosoftWebApiAuthentication(Configuration);
278-
279-
services.Configure<JwtBearerOptions>(JwtBearerDefaults.AuthenticationScheme, options =>
280-
{
281-
options.TokenValidationParameters.RoleClaimType = "roles";
282-
});
273+
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
274+
.AddMicrosoftWebApi(Configuration);
283275
```
284276

285277
2. Validating the tokens
286278

287-
As a result of the above `AddMicrosoftWebApiAuthentication` method, some audience and issuer validation is set up. More information can be found in [Microsoft Identity Web](https://github.com/AzureAD/microsoft-identity-web) project.
279+
As a result of the above `AddMicrosoftWebApi` method, some audience and issuer validation is set up. More information can be found in [Microsoft Identity Web](https://github.com/AzureAD/microsoft-identity-web) project.
288280
289281
```CSharp
290282
if (options.TokenValidationParameters.AudienceValidator == null
@@ -308,7 +300,7 @@ The relevant code for the Web API is in the `Startup.cs` class. We are using the
308300

309301
3. Protecting the Web API
310302

311-
Only apps that have added the **application role** created on **Azure Portal** for the `TodoList-webapi-daemon-v2`, will contain the claim `roles` on their tokens
303+
Only apps that have added the **application role** created on **Azure Portal** for the `TodoList-webapi-daemon-v2`, will contain the claim `roles` on their tokens. This is also taken care by [Microsoft Identity Web](https://github.com/AzureAD/microsoft-identity-web)
312304
313305
```CSharp
314306
var tokenValidatedHandler = options.Events.OnTokenValidated;

0 commit comments

Comments
 (0)