Skip to content

New option httpOnly = "signature" #89

@javiertury

Description

@javiertury

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions