Token Authentication vs. Cookies

前端 未结 8 1350
南旧
南旧 2020-11-29 14:49

What is the difference between token authentication and authentication using cookies?

I am trying to implement the Ember Auth Rails Demo but I do not understand the

8条回答
  •  星月不相逢
    2020-11-29 14:57

    • Tokens need to be stored somewhere (local/session storage or cookies)

    • Tokens can expire like cookies, but you have more control

    • Local/session storage won't work across domains, use a marker cookie

    • Preflight requests will be sent on each CORS request

    • When you need to stream something, use the token to get a signed request

    • It's easier to deal with XSS than XSRF

    • The token gets sent on every request, watch out its size

    • If you store confidential info, encrypt the token

    • JSON Web Tokens can be used in OAuth

    • Tokens are not silver bullets, think about your authorization use cases carefully

    http://blog.auth0.com/2014/01/27/ten-things-you-should-know-about-tokens-and-cookies/

    http://blog.auth0.com/2014/01/07/angularjs-authentication-with-cookies-vs-token/

提交回复
热议问题