The sample solution and JWT.go autotests fail to verify the signature of the JWT.
This is because the jwt.Parse() function takes nil as the key function, rather than a user-defined key function which returns the secret.
Steps to reproduce:
download the sample solution
add the following line in the main() function to print a valid token on running the container
Just noting that the “localhost” in the curl commands should have “http://” in front. However, I couldn’t post as “New users can only have 2 links in a post”
I tested and it works. The solution was submitted when this challenge was based on go 1.12. We have migrated all go challenge to v1.17 and they may have cause issues when you try to run them locally.
To get sample solution working locally:
Update Dockerfile to use secdim/play-go:1.17
Overwrite src/go.* with new ones
Change imports to github.com/labstack/echo/v4
make test and make run
I made these changes and got the solution worked locally.
Interesting. I get your point and wondering how this solution passed the final test.
So the final security test (on the server, a.k.a autotest), checks exactly for this scenario if JWT signature is verified. The test generates a token using an arbitrary key and expect the app to reject it. Which in this case the app did reject it.
I’ve reviewed other solutions and they did specified the KeyFunc parameter to pass this challenge.
ok, got what was wrong. The reason the solution rejects the token is not because of signature check, it is because of the missing claim checks (line 53 of the solution, which I am not copying here).