-
Notifications
You must be signed in to change notification settings - Fork 22
Fix/sl-verification #332
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
Fix/sl-verification #332
Conversation
Signed-off-by: Mirko Mollik <[email protected]>
Signed-off-by: Mirko Mollik <[email protected]>
Signed-off-by: Mirko Mollik <[email protected]>
Signed-off-by: Mirko Mollik <[email protected]>
|
@charsleysa please have a look if this approach is fine for you |
|
This code is redundant currently because of the That calls into the JWT validation code which already has all those checks |
Signed-off-by: Mirko Mollik <[email protected]>
Signed-off-by: Mirko Mollik <[email protected]>
|
Oh you are right (no work without coffee in the morning), I removed also the redundant exp check. Instead of the first fix, I appended all error messages during the verify function so it is clear when the sl jwt fails, it is clear from the error message. Thank you for reviewing!!! |
|
That would work. Though one downside is that it would suppress custom errors (you wouldn't be able to use instanceof checks). Maybe it's better for the status list not to use the jwt verify at all and instead have it's own independent implementation. |
this would end up in code duplication that I want to avoid. We may define a new Exception type like SLException? |
Signed-off-by: Mirko Mollik <[email protected]>
Signed-off-by: Mirko Mollik <[email protected]>
That would still result in the suppression of custom errors from the user supplied verifier function. Though it does help in identifying exactly status list specific errors. My thinking is the best way to avoid duplication would be to have check helper functions which return boolean results which can then be used from the status list verify function and it is the responsibility of the status list verify function to throw the errors. |
With: await slJWT
.verify(
this.userConfig.statusVerifier ??
(this.userConfig.verifier as Verifier),
options,
)
.catch((err) => {
throw new SLException(
`Status List JWT verification failed: ${err.message}`, err.details
);
});
```
I would not say it is supressed, but appended. I agree that the type of the error gets overwritten, but the error message gets passed as defined in your custom statusVerifier or verifier
Eg. with your verifier:
```ts
verifier(data: string, sig: string) {
throw Error("it's always false");
}Will result in an error message like |
Signed-off-by: Mirko Mollik <[email protected]>
Signed-off-by: Mirko Mollik <[email protected]>
|
That's correct, though if you throw a custom error class any other custom features would be lost too. For example, if you had an ErrorWithKeyDetails class where the I'm not entirely opposed to the proposed solution, however I think it's important to document that only the message will ever be propagated and instance checks won't work. |
lukasjhan
left a comment
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.
Looks good to me, Thanks.
Could you fix the lint error plz?
the sdjwtexception and slexception allow to pass a message and also an object. This object is passed so no information except the type of exception is lost |
Signed-off-by: Mirko Mollik <[email protected]>
lukasjhan
left a comment
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.
Thank you
Ah, so the expectation is for users to throw SDJWTException or SLException instead of their own error class so that information can be correctly propagated? |
yes, we should add this to the documentation. Since the own function that can be inserted are quite small, it should not be a problem to have the tradeoff to not be able to "throw up" your own exception class, as long as all relevant informations are passed. But I am open for an update once someone struggles there |
charsleysa
left a comment
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.
Looks good!
| (this.userConfig.verifier as Verifier), | ||
| options, | ||
| ) | ||
| .catch((err: SLException) => { |
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 think casting this as an SLException is unsafe, since the method could throw other errors as well (since a custom statusVerifier can be passed).
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 think it should rather be implemented as if (err instance SLException) {} else {}
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 made a suggestion with a fix here
@TimoGlastra can you please verify it if this was your intention? I agree that we should give the flexibility of throwing own exceptions.
Fixes #331
Signed-off-by: Mirko Mollik [email protected]