Hi Simon,
I've read the article and I cannot agree 100% with it because say that you want to have a micro service architecture where 1 component does all the security (issues tokens) and other component does some action if the token has been granted some authority.
Now in a microservice architecture it is all about decoupling, so if you have say:
*
https://api.server.com/token to issue tokens
*
https://app.server.com/perform-action to do some action
As you can see this will not work with cookies you run into the Cross Domain / CORS issues
Now say that you have lots of static content so you will add a CDN
*
https://app.mycdn-privder.comAgain the same issue the CDN will not be able to validate because of CORS
Now keeping the assumption that you have this distributed app relying on cookies then you need to do CSRF protection for your APIs since anyone could inject a iframe to hijack your cookie.
And finally if you are using frameworks such as angular you can enable an existing app to support JWT like this:
myApp.factory('authInterceptor', function ($rootScope, $q, $window) {
return {
request: function (config) {
config.headers = config.headers || {};
if ($window.sessionStorage.token) {
config.headers.Authorization = 'Bearer ' + $window.sessionStorage.token;
}
return config;
},
response: function (response) {
if (response.status === 401) {
// handle the case where the user is not authenticated
}
return response || $q.when(response);
}
};
});
myApp.config(function ($httpProvider) {
$httpProvider.interceptors.push('authInterceptor');
});
So as you can see because i used the sessionStore, only the current tab can access that memory value and once the tab is closed the token is gone from memory (and it should have never been written to disk) so you can be safe that no code either from other tabs or external to the browser has access to the token.
Now if you have just a single app that you can use cookies if you like.