firebase - Firebase Authentification and Flask
问题描述
I am trying Firebase to authenticate users for a website that was initially built on Flask (using the flask login workflow with a postgres DB). However, I am not sure that I have a correct understanding of what would be considered best practices when using Firebase.
I read through this article, which I think has led me down a suboptimal path when it comes to actually managing users.
My questions are:
- Should all the Firebase authentication be handled in the javascript?
- If so, should I use the
request.headers
on the backend to verify the identity of the user?
Any tutorials (aside from the Firenotes one, which I am working through) much appreciated.
解决方案
是否应该在 javascript 中处理所有 Firebase 身份验证?
不,它不一定是 JavaScript。但总的来说,您会发现大多数使用现有 Firebase 身份验证提供程序之一的应用程序在其客户端代码中处理用户登录,并调用身份验证服务器。
如果是这样,我应该使用后端的 request.headers 来验证用户的身份吗?
在调用 REST API 时,Firebase 本身会在Authorization
标头中传递经过身份验证的用户的 ID 令牌,因此这确实是一种有效的方法。然后,您可以在服务器上验证 ID 令牌是否有效,并决定该用户有权访问哪些数据。
推荐阅读
- javascript - 如何在输入类型为数字的 onkeyup 和 onkeydown 中使用 ActionResult?
- amazon-s3 - CloudWatch 合成监视器屏幕截图在管理控制台中显示已损坏
- c# - 为服务层选择哪个服务生命周期
- python - 假设似乎不尊重 pytest 的 maxfail 论点
- java - 需要一个查询来从我的 sql 中的表中获取不同的数据
- css - 带有 CSS 布局网格的 Blazor
- python - 外部文件中的Python重新分配函数
- node.js - 为什么我的服务器无法访问我的构建文件夹?
- chrome-web-store - Chrome 扩展程序不会更新
- tkinter - tkinter - 修改主窗口上的图像位置