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

JSON web token appears to be doing no work in app #46

Closed
rjmk opened this issue Oct 15, 2015 · 4 comments
Closed

JSON web token appears to be doing no work in app #46

rjmk opened this issue Oct 15, 2015 · 4 comments
Assignees
Labels

Comments

@rjmk
Copy link

rjmk commented Oct 15, 2015

Related to #5, but more extreme. Even within a session, it appears that the JSON web token is doing nothing. In my fork in which I have uninstalled json-web-token (https://github.com/rjmk/learn-json-web-tokens), I have identical behaviour to the web app. Namely:

  • Seeing the video when the correct credentials are supplied
  • Never being able to access '/private' (even directly after authenticating)

Perhaps more illustratively, if you add a console.log for req.headers.authorization at the top of the listener, you will see it is always undefined.

I am not sure if the way you are using the authorization header to spec (http://www.ietf.org/rfc/rfc2617.txt). It appears to be only a meaningful header on the client request. The response may feature a www-authenticate header, which I have tried using with this app but to no avail yet.

Let me know if I've misunderstood anything (which is, of course, pretty likely!)

@nelsonic nelsonic self-assigned this Oct 15, 2015
@nelsonic
Copy link
Member

Finally _someone_ is paying attention...! 😄
You are _100%_ correct Rafe. ✅
The req.headers.authorization will _always_ be undefined because the client is not saving the JWT the server is sending on auth so the client is never sending it back to the server...

What needs to be done to make this example "real wold" is:

a) need to save the token on the client (e.g. to localStorage) so it can be sent back to the server on each _subsequent request_.

b) add a link to /private on the /auth page that the person needs to explicitly _click_ in order view the "private content".

And... if the person has not authenticated then visiting /private should fail because they don't have a JWT in their header.

You have not misunderstood you've done the homework and spotted the opportunity to finish the example app. Do you have time to help "fix" this?

@rjmk
Copy link
Author

rjmk commented Oct 15, 2015

Sure, I'd love to help finish the app!

Before I get to work, it would be great to get an answer to #47 so I know which kind of storage I should use! Also, it would seem to suggest reconfiguring this app to be a one pager. I am happy to do that, but just want to check it is the appropriate approach.

@iteles
Copy link
Member

iteles commented Oct 15, 2015

@rjmk You're such a 🌟

@rjmk
Copy link
Author

rjmk commented Aug 11, 2017

This is issue is being automatically closed as it's more than a year old. Please feel free to reopen it if it's still relevant to your project.

@rjmk rjmk closed this as completed Aug 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants