简体   繁体   English

Firebase身份验证与Cloud SQL混合

[英]Firebase Authentication mixed with cloud sql

I'm developing my first app with firebase auth and Google App Engine, and I'm wondering how should I do some things. 我正在使用firebase auth和Google App Engine开发我的第一个应用程序,我想知道我该怎么做。

For example: My architecture will be in Google App engine, and I'm using Cloud SQL to store data (using sequelize). 例如:我的架构将在Google App引擎中,并且我正在使用Cloud SQL存储数据(使用sequelize)。 The app is developed with node.js and express. 该应用程序是使用node.js和express开发的。

The problem is I want to use firebase auth to make login easier. 问题是我想使用firebase auth来简化登录。

Everything for that is done client-side so.... is there any example on how should I use firebase Auth and how should I authenticate my request to my API in order to get which user it is on every request? 一切都在客户端完成,....是否有任何示例说明我应如何使用firebase Auth,以及如何向API验证我的请求以获取每个请求上的用户?

Maybe forward the token to the API? 也许将令牌转发到API? and then getting the info? 然后获取信息?

Thanks for your help. 谢谢你的帮助。

There are definitely examples of this. 肯定有这样的例子。 What you'll want to do is look at the documentation for the Firebase Admin SDK , which is the SDK that you can run on trusted environments (such as App Engine) to perform actions that require administrative access. 您需要做的是查看Firebase Admin SDK的文档,该文档可以在受信任的环境(例如App Engine)上运行,以执行需要管理访问权限的操作。

In a typica scenario you'll use the Firebase Authentication SDK to sign the user in in the app, and then pass the ID token to your App Engine back-end . 在典型情况下,您将使用Firebase身份验证SDK在应用中登录用户 ,然后将ID令牌传递到您的App Engine后端 There you'll validate and verify the token , and then perform whatever actions the user is authorized to perform according to your rules. 在那里,您将验证和验证令牌 ,然后根据您的规则执行用户被授权执行的所有操作。

If you'd be using a Firebase database (either Realtime Database or Cloud Firestore) you would be able to pass the token along and enforce authorized access in Firebase's server-side security rules. 如果您要使用Firebase数据库(实时数据库或Cloud Firestore),则可以传递令牌并在Firebase的服务器端安全规则中强制执行授权访问。 But since you're using Cloud SQL (which isn't aware of Firebase), you'll need to enforce your authorization rules in your own App Engine code. 但是,由于您使用的是Cloud SQL(不了解Firebase),因此您需要在自己的App Engine代码中强制执行授权规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Cloud Functions 中无法进行 firebase 身份验证 - In Cloud Functions not able to do firebase authentication 带有自定义令牌的身份验证流程,用于云功能上的Firebase身份验证 - Authentication flow with custom token for Firebase Authentication on cloud functions 从 Firebase 函数使用 Cloud SQL 代理 - Using Cloud SQL Proxy from Firebase function Firebase 身份验证花费太长时间在云中创建用户 function - Firebase authentication taking too long to create user in cloud function Firebase云功能触发FCM,但请求缺少必需的身份验证凭据 - Firebase cloud function triggers FCM but Request is missing required authentication credential 将 Firebase 函数与 Google Cloud SQL MYSQL 连接时出现 ECONNREFUSED - ECONNREFUSED when connecting Firebase Function with Google Cloud SQL MYSQL 有没有办法保护 Firebase 云函数在未经用户身份验证的情况下被入侵者调用? - Is there a way to protect Firebase Cloud Functions being called from intruders without user authentication? 云9上的Passport Facebook身份验证 - Passport Facebook authentication on cloud 9 (..)。然后不是函数,firebase云功能 - (..).then is not a function ,firebase cloud functions Firebase云功能未执行 - Firebase cloud functions not executing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM