Skip to content

Commit 7ec9157

Browse files
committed
Adding details on the manual validation process, and adding a Troubleshooting section referencing GitHub issue #22
1 parent 4b80657 commit 7ec9157

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,23 @@ Explore the sample by signing in, adding items to the To Do list, removing the u
115115

116116
## About The Code
117117

118-
The manual JWT validation occurs in the [TokenValidationHandler](https://github.com/Azure-Samples/active-directory-dotnet-webapi-manual-jwt-validation/blob/master/TodoListService-ManualJwt/Global.asax.cs#L58) implementation in the `Global.aspx.cs` file in the TodoListService-ManualJwt project.
118+
The manual JWT validation occurs in the [TokenValidationHandler](https://github.com/Azure-Samples/active-directory-dotnet-webapi-manual-jwt-validation/blob/master/TodoListService-ManualJwt/Global.asax.cs#L58) implementation in the `Global.aspx.cs` file in the TodoListService-ManualJwt project. Each time a call is done on a controller method holiding the `[Authorize]` attribute, the TokenValidationHandler.SendAsync method is called:
119+
https://github.com/Azure-Samples/active-directory-dotnet-webapi-manual-jwt-validation/blob/4b80657c5506c8cb30af67b9f61bb6aa68dfca58/TodoListService-ManualJwt/Global.asax.cs#L80
120+
121+
This method:
122+
123+
1. gets the token from the Authorization headers
124+
2. verifies that the token has not expired
125+
3. gets the open id configuration from the Azure AD discovery endpoint
126+
4. Sets the parameters to validate:
127+
128+
- the audience - the application accepts both its App Id URI and its AppID/clientID
129+
- the valid issuers - the application accepts both Azure AD V1 and Azure AD V2
130+
131+
5. Then it delegates to the `JwtSecurityTokenHandler` class (provided by the `System.IdentityModel.Tokens` library)
132+
133+
the `TokenValidationHandler` class is registered with ASP.NET in the `TodoListService-ManualJwt/Global.asx.cs` file, in the `application_start()` method :
134+
https://github.com/Azure-Samples/active-directory-dotnet-webapi-manual-jwt-validation/blob/4b80657c5506c8cb30af67b9f61bb6aa68dfca58/TodoListService-ManualJwt/Global.asax.cs#L54
119135

120136
## How To Recreate This Sample
121137

@@ -163,6 +179,10 @@ In order to run this sample on Azure Government you can follow through the steps
163179
164180
Once those changes have been accounted for, you should be able to run this sample on Azure Government.
165181

182+
## Troubleshooting
183+
184+
If you are using this sample with an Azure AD B2C custom policy, you might want to read #22, and change step 3. in the [About the code](About-the-code) paragraph.
185+
166186
## More information
167187

168188
For more information on how to acquire a token in the client application, see ADAL.NET's conceptual documentation:

0 commit comments

Comments
 (0)