Firebase模拟器与实际结果不符 [英] Firebase simulator does not match real-world results
问题描述
URL定义:
url1 ='https://my-firebase.firebaseio.com/users/user-id/settings';
url2 = url1 +'.json';
我测试了两种不同的安全方案 - 安全且没有安全性。在Firebase模拟器和现实生活中。如下。
without-security.json:
{
rules: {
.read:true,
.write:true
}
}
with-security.json:
{
rules:{
users :{
$ uid:{
.read:auth!= null&& auth.uid == $ uid,
.write: auth!= null&& auth.uid == $ uid,
settings:{}
}
}
}
}
现在,考虑Firebase模拟器与实际生活测试的不同结果。
测试结果:
安全模拟器现实生活
-------- ------- - ---------
url1否(未测试)失败(没有错误信息)
url2否(未测试)成功!
url1是成功!失败(没有错误信息)
url2是无效的路径。模拟中止。 POST< url2> 401(未授权)
问题
- 什么可能导致测试结果与现实生活中的这种差异?
- 我应该如何尝试才能获得真实生活场景
with-security.json
规则到位? a @ href =https://stackoverflow.com/a/34338733/1640892> @FrankvanPuffelen在这里回答:
lockquote
这两个问题都是由于您使用了两种不同的方式来访问Firebase:JavaScript SDK和REST API。虽然这两种方法可以一起使用,但您必须确保提供所需的信息。一般来说,如果您坚持使用单一客户端访问Firebase的一种方式,您将获得更轻松的体验。
For the purposes of convenience in reading this question, refer to the following URLs as follows:
URL definitions:
url1 = 'https://my-firebase.firebaseio.com/users/user-id/settings';
url2 = url1 + '.json';
I have tested two different security scenarios — with security and without security. Both in the Firebase simulator and in real life. As follows.
without-security.json:
{
"rules": {
".read": true,
".write": true
}
}
with-security.json:
{
"rules": {
"users": {
"$uid": {
".read": "auth != null && auth.uid == $uid",
".write": "auth != null && auth.uid == $uid",
"settings": {}
}
}
}
}
Now, consider the different results from the Firebase simulator vs. real life testing.
Test results:
Security Simulator Real life
-------- --------- ---------
url1 No (untested) Fails (without error message)
url2 No (untested) Success!
url1 Yes Success! Fails (without error message)
url2 Yes Invalid path. Simulation aborted. POST <url2> 401 (Unauthorized)
Questions
- What could be causing this discrepancy in test results vs. real life?
- What should I try in order to get real life scenario to work
with-security.json
rules in place?
解决方案 @FrankvanPuffelen answers here:
Both of your problems are caused by the fact that you're using two different ways of accessing Firebase: the JavaScript SDK and the REST API. While these two methods can be used together, you will have to ensure you provide the information that is needed. In general you will have an easier experience if you stick to using one way of accessing Firebase from a single client.
这篇关于Firebase模拟器与实际结果不符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
with-security.json
规则到位?lockquote
这两个问题都是由于您使用了两种不同的方式来访问Firebase:JavaScript SDK和REST API。虽然这两种方法可以一起使用,但您必须确保提供所需的信息。一般来说,如果您坚持使用单一客户端访问Firebase的一种方式,您将获得更轻松的体验。
For the purposes of convenience in reading this question, refer to the following URLs as follows:
URL definitions:url1 = 'https://my-firebase.firebaseio.com/users/user-id/settings';
url2 = url1 + '.json';
I have tested two different security scenarios — with security and without security. Both in the Firebase simulator and in real life. As follows.
without-security.json:{
"rules": {
".read": true,
".write": true
}
}
with-security.json:
{
"rules": {
"users": {
"$uid": {
".read": "auth != null && auth.uid == $uid",
".write": "auth != null && auth.uid == $uid",
"settings": {}
}
}
}
}
Now, consider the different results from the Firebase simulator vs. real life testing.
Test results: Security Simulator Real life
-------- --------- ---------
url1 No (untested) Fails (without error message)
url2 No (untested) Success!
url1 Yes Success! Fails (without error message)
url2 Yes Invalid path. Simulation aborted. POST <url2> 401 (Unauthorized)
Questions
- What could be causing this discrepancy in test results vs. real life?
- What should I try in order to get real life scenario to work
with-security.json
rules in place?
@FrankvanPuffelen answers here:
Both of your problems are caused by the fact that you're using two different ways of accessing Firebase: the JavaScript SDK and the REST API. While these two methods can be used together, you will have to ensure you provide the information that is needed. In general you will have an easier experience if you stick to using one way of accessing Firebase from a single client.
这篇关于Firebase模拟器与实际结果不符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!