首页 > 解决方案 > 节点 js 中的 Firebase 授权

问题描述

我有简单的 html、css 和 js 前端和 node.js 后端。我在后端使用 firebase 进行身份验证。现在如何保护或授权某些路由。

如果有人试图在没有适当身份验证的情况下访问路由(比如仪表板),那么他必须重定向到登录页面或任何错误消息页面。

标签: node.jsfirebase-authenticationauthorization

解决方案


服务器的 firebase 实例本身发生了什么,它正在被验证,而不是向客户端返回验证数据。您应该做的是在请求中返回客户端身份验证令牌。这里有一节介绍服务器身份验证

https://firebase.google.com/docs/auth/admin/#custom_token_creation

还是问题?

https://firebase.google.com/docs/auth/web/google-signin


推荐阅读