-
-
Notifications
You must be signed in to change notification settings - Fork 158
Open
Labels
Description
Hi,
I think it would be useful to have a new option for signed cookies such that the cookie is httpOnly = false but the signature is httpOnly = true. The case for this are Single Page Apps(SPA).
- Store the authentication(session/username...) data in a cookie. An XSS attack can steal the cookie but not the signature(
httpOnly = true).- If the server checks the signature, the cookie without the signature is useless for authentication.
- The client SPA can read the cookie to see if there is an active login, and depending on the setup, which user is logged in.
- No need to query the server to know if a user is logged in. Provides an easier/cheaper way to keep the local auth state consistent in the SPA
I propose to create a new option, httpOnly = "signature", to achieve this. A quick way to implement this feature is this javiertury@ffda6e4
Note that I've used the weak comparison(==) operator.
EDIT: Better implementation
afbpinheiro and noinkling