[英]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.