[removed] hiding contents of key

前端 未结 8 1310
梦谈多话
梦谈多话 2020-12-22 14:04

In the code below I want to hide the contents of the key(speaker) key being viewed by browser console.

var App_Version         


        
8条回答
  •  伪装坚强ぢ
    2020-12-22 15:01

    Javascript code is considered temperable so you can't really hide a password in your code. The best practice is to use oAuth2 which uses temporary tokens(to defer from passwortds) that in conjunction with things like CSRF can make you client side code more secure. Here's one library that can help you do that in JS. It does require that on your server side when accessing resources you need to validate that token (preferably on every call). To some it up if you need to store a password on the browser in order to log into a server - don't. Let the user log in and the afterwards use the token issues by the server or use a third party login and use the token you got from the third party authentication server.

提交回复
热议问题