What are (if any) the security drawbacks of REST Basic Authentication with Javascript clients?

前端 未结 3 811
傲寒
傲寒 2021-01-19 16:43

I have this application that consists of a REST back-end intended to servicing requests from an HTML5/JavaScript client (which I\'m also building).

I\'m planning on

3条回答
  •  伪装坚强ぢ
    2021-01-19 17:12

    The “hard” credentials should never be stored in an area that is accessible by Javascript, otherwise you open yourself wide to XSS attacks.

    I recommend using access tokens and storing them in HTTPS-only cookies. You do an initial exchange of hard credentials for access token, then use the token (which is time limited) for subsequent requests.

    I have written a lengthly article on this subject and It covers my answer in detail: Token Based Authentication for Single Page Apps

    Hope this helps!

提交回复
热议问题