News for hackers. Stuff that matters.
Re:JSON Web Tokens vs. Sessions by lllorddino on Sunday June 19, 2016 @11:34AM (#11933297)
Is there anything wrong with saving the token in the cookie? I'm not exactly sure how to save them in the header. I'm guessing save it to localStorage and use javascript to pass it back to the server?
Re:JSON Web Tokens vs. Sessions by jastanton on Sunday June 19, 2016 @12:31PM (#11933503)
This article talked a bit about putting them in cookies:

  The header method is preferred for security reasons - cookies would be susceptible to CSRF (Cross Site Request Forgery) unless CSRF tokens were used.

  Secondly, the cookies can be sent back only to the same domain (or at most second level domain) they were issued from. If the authentication service resides on a different domain, cookies require much more wild creativeness.
As far as putting something in the header, if you're using javascript check out superagent. It's as easy as:

  request(url).set('SomeHeader', 'SomeValue');
or the latest http fetch api just do:

  var request = new Request('/users.json', {method: 'POST', 
    headers: new Headers({'Content-Type': 'text/plain'})
  });

  fetch(request).then(function() { /* handle response */ });
Re:JSON Web Tokens vs. Sessions by bigonlogn on Sunday June 19, 2016 @02:13PM (#11933922)
You can also supply an options object (including headers) as the second argument[1].

[1]https://developer.mozilla.org/en-US/docs/Web/API/GlobalFetch...