-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misc updates for the JWT sample application #1009
Conversation
…ValidationParameters from the call to AddJwtBearer
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## master #1009 +/- ##
=======================================
Coverage 93.42% 93.42%
=======================================
Files 44 44
Lines 2175 2175
Branches 366 366
=======================================
Hits 2032 2032
Misses 102 102
Partials 41 41 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
As a side note, I would prefer to add another nuget package for JWT handling to this repository, specifically for the |
Co-authored-by: Ivan Maximov <[email protected]>
// this mapping is not performed by Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler | ||
var handler = new System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler(); | ||
var tokenValidationParameters = _jwtBearerOptionsMonitor.Get(JwtBearerDefaults.AuthenticationScheme).TokenValidationParameters; | ||
var principal = handler.ValidateToken(token, tokenValidationParameters, out var securityToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No TokenValidationResult
anymore? Does ValidateToken
throw in case of any error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct; it throws in the case that the token is invalid for any reason (according to the parameters defined in tokenValidationParameters
). So for example, if TokenValidationParameters.ValidateIssuer
is true
, then the issuer must match or an exception is thrown.
TokenValidationParameters
from the call toAddJwtBearer
so that the reference to the static propertyJwtHelper.Instance
is not necessaryJwtHelper.Instance
Program.cs
to use a local variable instead of a static propertyOAuthController
to pullJwtHelper
from DI