如何撤销身份验证令牌?

时间:2014-02-04 18:22:02

标签: firebase firebase-security

假设我生成了一个身份验证令牌,为了节省处理和远程调用,我将来会在30天内设置它的到期数据。

现在我想从我的系统中删除此帐户,有没有办法撤销我给客户端的身份验证令牌?

我认为目前不可能,我当然可以解决这个问题(主要是没有这么高的过期时间),但我只是想确保我没有错过文档中的内容。

4 个答案:

答案 0 :(得分:10)

Firebase现在提供撤销刷新令牌的功能,它非常新鲜 - 已添加04/01/2018。 https://firebase.google.com/docs/auth/admin/manage-sessions#revoke_refresh_tokens

答案 1 :(得分:6)

你无法真正撤销该特定令牌(在使生成令牌的秘密无效之外,但这也会使该秘密发出的所有其他令牌无效 - 可能不是您想要的)。

但是,您可以依赖某些特定于令牌的信息(可能包含唯一用户ID作为令牌中的数据)并更新您的安全规则以拒绝任何与该值匹配的操作。

答案 2 :(得分:1)

添加@Alex Redwood的回答

这是重要的部分:

return admin.auth().revokeRefreshTokens(uid)`
    .then(() => {
      // Get user's tokensValidAfterTime.
      Return admin.auth().getUser(uid);
    })

文档中的示例包含各种细微差别,例如将时间戳写入数据库以防止在当前令牌到期之前进行读取,特定于实现的情况。重要的是,您在正确的revokeRefreshTokens(uid)上致电uid,并验证userRecord是否修改了userRecord.tokensValidAfterTime值。这不会使您的活动令牌失效。因此缩短攻击窗口的缩短到期时间是有价值的(比我认为检查时间戳的数据库规则更好的解决方案)。

来自:https://firebase.google.com/docs/auth/admin/manage-sessions#revoke_refresh_tokens

答案 3 :(得分:1)

使用CLI:

Page segmentation modes:
  0    Orientation and script detection (OSD) only.
  1    Automatic page segmentation with OSD.
  2    Automatic page segmentation, but no OSD, or OCR. (not implemented)
  3    Fully automatic page segmentation, but no OSD. (Default)
  4    Assume a single column of text of variable sizes.
  5    Assume a single uniform block of vertically aligned text.
  6    Assume a single uniform block of text.
  7    Treat the image as a single text line.
  8    Treat the image as a single word.
  9    Treat the image as a single word in a circle.
 10    Treat the image as a single character.
 11    Sparse text. Find as much text as possible in no particular order.
 12    Sparse text with OSD.
 13    Raw line. Treat the image as a single text line,
       bypassing hacks that are Tesseract-specific.

https://firebaseopensource.com/projects/firebase/firebase-tools/#using_with%20ci%20systems