Upgrade to Pro — share decks privately, control downloads, hide ads and more …

jsconf.uy - Death to Cookies Long Live Tokens

jsconf.uy - Death to Cookies Long Live Tokens

Matias Woloski

March 15, 2014
Tweet

More Decks by Matias Woloski

Other Decks in Technology

Transcript

  1. Browser Database Today’s applications Web Server (Scala) API (Ruby) API

    (Node) Phones Tablets Realtime (Sockets) API (Facebook) C M A A A AT
  2. Cookies are coupled to the web framework ! If you

    try to reuse a cookie issued by Java in Node, not easy 2
  3. Cookies lead to CSRF attacks <iframe  style="display:none"  name="hidden"></iframe>   <form

     name="csrf"                action="http://example.org/account/edit"                method="post"                target="hidden">   <input  type="hidden"  name="email"  value="[email protected]"  />   <script>document.csrf.submit();</script> 4
  4. JWT JSON Web Tokens eyJ0eXAiOiJKV1QiLC JhbGciOiJIUzI1NiJ9   .eyJ1c2VyX2lkIjoiM TIzNDUiLCJlbWFpbCI 6ImZvb0BiYXIuY29tI

    iwiZXhwIjoxMzkyMzI zMzQwLCJpYXQiOjEzO TIzMTYxNDB9   .KQma3tquGF_zKbLdX HV4zNJAupdHJdIk6L2 g6R8kcAY   ! ! {        "typ":"JWT",      "alg":"HS256"   } {        "user_id":  "12345",      "email"  :  "[email protected]",      "exp":  1392323340,      "iat":  1392316140   } HMACSHA256(            base64UrlEncode(header)        +  "."  +      base64UrlEncode(payload),        "secret")   ! header payload signature encoded decoded