Skip to content
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

Sample not working - ValidationKeyGetter - cannot use as jwt.Keyfunc value in struct literal #95

Closed
b-venter opened this issue Jul 6, 2021 · 7 comments

Comments

@b-venter
Copy link

b-venter commented Jul 6, 2021

Description

image

Reproduction

  1. Download sample from Auth0 tutorial
  2. Extract and cd into folder
  3. go mod init test
go get github.com/codegangsta/negroni
go get github.com/auth0/go-jwt-middleware
go get github.com/dgrijalva/jwt-go
go get github.com/gorilla/mux
go get github.com/joho/godotenv
go get github.com/rs/cors
mv main.go test.go
go test

Open with VS Code and the error will appear.

Environment

Please provide the following:

  • Version of this library used: v1.0.1 (according to go.mod)
  • Version of the platform or framework used, if applicable: Go 1.16
  • Other relevant versions (language, server software, OS, browser): OpenSUSE 15.2
  • Other modules/plugins/libraries that might be involved: N/A

I hope I have not missed something obvious. I tested and the function is acceptable to jwt.Parse (which also takes a jwt.Keyfunc type). Please help! :)

@grounded042
Copy link
Contributor

Thanks for surfacing this issue @b-venter. We'll get this fixed!

@b-venter
Copy link
Author

b-venter commented Jul 7, 2021

I did a bit more exploring and this seems linked to the NOTE of this repository: the unmaintained jwt library. To test, I cloned the jwtmiddleware.go file, and changed the jwt library to github.com/golang-jwt/jwt. This appears to have solved the problem I was experiencing, but I am not sure if it will introduce an incompatibility elsewhere? At least for the tutorial, it did not appear to introduce further issues.

If you want to give it a quick test, I put it together for easy running at https://github.com/b-venter/auth0-go-jwt for now.

@grounded042
Copy link
Contributor

Yes, you are on the right track there. Pulling in github.com/form3tech-oss/jwt-go should fix the issue.

@b-venter
Copy link
Author

b-venter commented Jul 7, 2021

Actually, I removed github.com/form3tech-oss/jwt-go and put in github.com/golang-jwt/jwt. I guess this error is a further symptom of #73 ?

@grounded042
Copy link
Contributor

Yeah, it's from that change (see #69 for more details). form3tech was added because there was no other fix at that point. Since then the community has rallied around golang-jwt.

We've got a new version of this package coming out very soon and it uses golang-jwt instead of form3tech. If you're interested in checking it out, https://github.com/auth0/go-jwt-middleware/tree/v2 should point you in the right direction. Using golang-jwt for validation is not in the README, but you can find an example in that branch here: https://github.com/auth0/go-jwt-middleware/blob/v2/validate/jwt-go/examples/main.go

@b-venter
Copy link
Author

b-venter commented Jul 7, 2021

Thanks @grounded042! The support has been great - which is why I chose to explore Auth0 more in the first place! :)
I suspect the above will also address the matter for #96.
Should close this issue?

@grounded042
Copy link
Contributor

@b-venter happy to help! Yes, go ahead and close this since we've solved it for you. I've got a PR open to fix quickstarts code: auth0-samples/auth0-golang-api-samples#35.

And yes, this was the same issue faced in that issue as well.

Thanks for bringing this to our attention!

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

No branches or pull requests

2 participants