Skip to content

Added param:<name> lookup option to JWT Middleware #1296

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

Merged
merged 3 commits into from
Jun 9, 2019

Conversation

ozburo
Copy link
Contributor

@ozburo ozburo commented Mar 1, 2019

I wanted to use JWTs as "tokenized" URLs and have the Middleware locate them from their URL param names:

https//example.com/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ

With a route like:
e := echo.New()
e.GET("/:token", MyHandler)

Where "token" is the TokenLookup option in the JWT config : param:<name>

The test(s) are a little naive since I can't route the tests thru an Echo Router, but the principal is still there, and it isn't really that big a change/addition.

Hopefully others will find this useful!

@codecov
Copy link

codecov bot commented Mar 1, 2019

Codecov Report

Merging #1296 into master will decrease coverage by 0.03%.
The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1296      +/-   ##
==========================================
- Coverage   84.21%   84.17%   -0.04%     
==========================================
  Files          26       26              
  Lines        1951     1959       +8     
==========================================
+ Hits         1643     1649       +6     
- Misses        202      203       +1     
- Partials      106      107       +1
Impacted Files Coverage Δ
middleware/jwt.go 79.06% <75%> (-0.42%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 802fb5b...11aa97e. Read the comment docs.

@ozburo
Copy link
Contributor Author

ozburo commented Mar 1, 2019

Looks like my Codecov is showing a bunch of red, any help on how to make it happy is appreciated 💃

@ozburo
Copy link
Contributor Author

ozburo commented Mar 6, 2019

Just to follow since this PR failed code coverage -- I tried to add more tests in the style currently found, but since this adds a URL router param I failed to integrate it at that level and simply set the necessary parameters directly on the Context struct.

Again, not sure the best course of action here, still think this is a valid addition to expand the use-cases for JWT.

@vishr
Copy link
Member

vishr commented Mar 7, 2019

@alexaandru @im-kulikov What is your opinion?

@stale
Copy link

stale bot commented May 6, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label May 6, 2019
@vishr vishr removed the wontfix label May 6, 2019
@ozburo
Copy link
Contributor Author

ozburo commented May 6, 2019

@vishr Thx for dealing with the Stalebot -- I still think this is a valid addition/option for Echo!

@ozburo ozburo closed this May 6, 2019
@vishr
Copy link
Member

vishr commented Jun 9, 2019

Reopen

@vishr vishr reopened this Jun 9, 2019
@vishr vishr merged commit 6b9408d into labstack:master Jun 9, 2019
@ozburo
Copy link
Contributor Author

ozburo commented Jun 14, 2019

Many thanks for approving/adding this! 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants