-
Notifications
You must be signed in to change notification settings - Fork 54
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
Enforce strict token validation everywhere. #58
Conversation
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.
👍
|
||
if (jwtToken.Header?.Alg == null || jwtToken.Header?.Alg != SecurityAlgorithms.RsaSha256) | ||
{ | ||
throw new SecurityTokenValidationException("The alg must be RS256."); |
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.
Nitpick: Just calling it "the alg" sounds a bit slangy. Maybe "The JWT token's alg property" or "The JWT token's signing algorithm"?
{ | ||
private readonly JwtSecurityTokenHandler _handler; | ||
|
||
public StrictSecurityTokenValidator(OktaWebOptions options) |
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.
nit: Do we need the options
constructor parameter? Seems like it isn't used.
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.
good catch, this is not needed.
public int MaximumTokenSizeInBytes | ||
{ | ||
get => _handler.MaximumTokenSizeInBytes; | ||
set => throw new NotImplementedException(); |
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.
I'm wondering if we should throw something other than NotImplementedException
. Usually when I see that I see it as either a bug in the library that threw it, or an indication that a feature is only partially implemented. But in our case the code is complete, it's just that the property is readonly.
Maybe NotSupportedException
? Up to you.
As per our JWT spec validate that
alg
claim isRS256
.