仅适用于身份验证的用户firebase
我正在使用 firebase 开发一个HTML网页,我的工作树是:
css
:带有CSS样式文件的文件夹js
:带有Javascript文件- 。
- 文件夹>
代码> app.html 仅适用于记录的用户。我已经在JavaScript中实现了一些脚本,可以使用login.html
和implyup.html
页面通过电子邮件和密码对用户进行身份验证。对于该项目,我使用提供燃料的托管工具。但是,我不确定是否需要使用托管工具,实时数据库或其他功能应用此功能。也许解决方案是将我的Web作为实时数据库资源上传,然后控制对某些路径修改database.rules.json.json
文件的访问,但是我不知道该如何实现。
感谢您的帮助 :)
I am developing an HTML webpage using Firebase, my working tree is:
css
: folder with CSS style filesjs
: folder with Javascript fileslogin.html
: logging in pagesignup.html
: signing up pageapp.html
: main application page
I would like to restrict the app.html
access only for logged users. I have implemented in Javascript some scripts to authenticate users via email and password using the login.html
and signup.html
pages. For the project, I use the hosting tool that offers Firebase. However, I'm not sure whether I need to apply this capability with the hosting tools or the real time database or other. Maybe the solution is to upload my web as a real time database resource and then, control the access to some paths modifying the database.rules.json
file, but I don't know how to implement it.
Thanks for your help :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Firebase托管上的所有内容均可公开使用。无法限制访问您的HTML或JavaScript或您在Firebase Hosting上托管的任何其他资源。
另请参阅:
可以将firebase托管限制在资源 那里的答案说,您可以通过云功能控制访问访问,但是那时它不再是静态资源。
确实,将资源放在托管未受保护的情况下,然后限制对您在页面中显示的数据的访问,这确实很常见,这些数据可能是从Firebase的一个数据库中加载的。在这种情况下,您可以控制使用安全规则的数据访问,这些规则已完全记录在这里 。如果您使用的是Firestore,还有一个 codelab 使得更易于启动。
All content on Firebase Hosting is publicly available. There is no way to restrict access to your HTML or JavaScript or any of the other resources you host on Firebase Hosting.
Also see:
As one of the answers there says, you can control access with Cloud Functions, but at that point it's not a static resource anymore.
It's pretty common indeed to leave the resources on Hosting unprotected, and then restrict access to the data that you show in the page, which may be loaded from one of Firebase's databases. In that case you can control access to the data with the security rules, which are fully documented here. If you're using Firestore, there's also a codelab making it easier to get started.