auth0 / go-jwt-middleware

A Middleware for Go Programming Language to check for JWTs on HTTP requests
MIT License
1.08k stars 205 forks source link

Fix panic threat when using type-cast for customClaims in validator #165

Closed osamingo closed 2 years ago

osamingo commented 2 years ago

Description

The threat of panicking should be curbed by receiving a second return value when executing the type-cast.

References

Testing

Checklist

osamingo commented 2 years ago

I would appreciate it if you would approve running GitHub Actions for this PR when you have time.

osamingo commented 2 years ago

@Widcket ping

osamingo commented 2 years ago

@sergiught I fixed it, PTAL.

codecov-commenter commented 2 years ago

Codecov Report

Base: 89.05% // Head: 89.09% // Increases project coverage by +0.03% :tada:

Coverage data is based on head (2bc0d47) compared to base (e9dbfc6). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #165 +/- ## ========================================== + Coverage 89.05% 89.09% +0.03% ========================================== Files 7 7 Lines 274 275 +1 ========================================== + Hits 244 245 +1 Misses 23 23 Partials 7 7 ``` | [Impacted Files](https://codecov.io/gh/auth0/go-jwt-middleware/pull/165?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=auth0) | Coverage Δ | | |---|---|---| | [validator/validator.go](https://codecov.io/gh/auth0/go-jwt-middleware/pull/165/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=auth0#diff-dmFsaWRhdG9yL3ZhbGlkYXRvci5nbw==) | `88.75% <100.00%> (+0.14%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=auth0). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=auth0)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

sergiught commented 2 years ago

Hey @osamingo 👋🏻 thanks a lot for the changes and apologies it took so while to get back to you! Would you mind adding a test case for this as well in the validatior_test.go file? 🙏🏻

sergiught commented 2 years ago

Hey @osamingo 👋🏻 I had some time and went ahead and added the test cases missing. Thanks for the contribution again!