簡體   English   中英

保護密碼客戶端Firebase

[英]Securing password client side Firebase

我目前正在關注Firebase上的此電子郵件和密碼身份驗證教程

這是使用電子郵件和密碼登錄的基本代碼:

var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
ref.authWithPassword({
  email    : "bobtony@firebase.com",
  password : "correcthorsebatterystaple"
}, function(error, authData) {
  if (error) {
    console.log("Login Failed!", error);
  } else {
    console.log("Authenticated successfully with payload:", authData);
  }
});

對於我在網站上瀏覽的每個頁面,是否需要使用電子郵件和密碼憑證重新進行身份驗證才能訪問數據庫?

如果是這樣,我如何通過網頁傳遞emailpassword ,而又不使密碼容易受到攻擊。

我對安全性很陌生,並且不想遇到任何安全性問題或數據泄漏,因此我之所以依賴第三方服務。

調用時,Firebase在瀏覽器中保留身份驗證狀態:

var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
ref.authWithPassword({
  email    : "bobtony@firebase.com",
  password : "correcthorsebatterystaple"
}, function(error, authData) {
  if (error) {
    console.error("Login Failed!", error);
  } 
});

要在頁面重新加載時檢索持久的身份驗證狀態,可以使用onAuth()方法:

// this will fire even if not authenticated and authData
// will be null
ref.onAuth(function(authData) {
  if (authData) {
    console.log(authData.uid);
  }
});

就安全性而言,Firebase需要HTTPS連接,因此所有電子郵件和密碼都將通過有線方式加密。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM