我正在设计一个基于VueJs(用于UI)+ NodeJs(用于后端,将在Google Cloud Platform中运行)+ Firestore(用于auth +数据库)的应用程序(我们称之为TodoList应用程序).
我已经浏览了Google的大量文档(有时是多余的!)来实现应该有用的东西,但我不确定它是否符合生产要求.
情况:
我在Firestore数据库上设置了一些安全规则:
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId}/{document=**} {
allow read, write: if request.auth.uid == userId;
}
}
}
Run Code Online (Sandbox Code Playgroud)
这样我就不希望任何记录的用户访问其他用户的数据.
题:
由于Firebase Admin SDK对我的Firestore数据库具有完全权限,因此如何确保不会出现任何安全问题.现在,我只是验证请求中发送的accessToken到我的后端,但......有些东西让我觉得这个错了!
码:
在客户端:
auth.onAuthStateChanged((user) => {
if (user) {
// Save the user credentials
}
}
Run Code Online (Sandbox Code Playgroud)
在服务器端:
// idToken comes from the client app (shown above)
// …Run Code Online (Sandbox Code Playgroud) authentication node.js firebase firebase-admin google-cloud-firestore
我最近发现了Firebase可调用函数,它允许我从客户端调用HTTPS触发器(和auth()支持).
我很难在我现有的Firebase Web客户端应用程序中实现这一新功能.
我有一些运行的云函数,其中有一些我希望转换为HTTPS可调用函数的HTTPS函数(带有functions.https.onCall).
文件表明:
Set up your client development environment
<script src="https://www.gstatic.com/firebasejs/4.12.0/firebase.js"></script>
<script src="https://www.gstatic.com/firebasejs/4.12.0/firebase-functions.js"></script>
Run Code Online (Sandbox Code Playgroud)
我的代码是:
import firebase from 'firebase';
import 'firebase/firestore';
const firebaseApp = firebase.initializeApp({
apiKey: '....',
authDomain: '....',
databaseURL: '....',
projectId: '....',
storageBucket: '....',
messagingSenderId: '....',
});
const db = firebaseApp.firestore();
const auth = firebaseApp.auth();
const functions = firebaseApp.functions();
export { db, auth, functions };
Run Code Online (Sandbox Code Playgroud)
当我运行我的应用程序时,我收到以下错误:
Uncaught TypeError: firebaseApp.functions is not a function
Run Code Online (Sandbox Code Playgroud)
我曾尝试yarn add firebase-functions,然后import 'firebase-functions但随后的应用需要firebase-admin.我担心这对客户端应用来说太过分了,所以我可能会走错方向.
有人可以帮我解决这个问题吗?(!)这个问题是 …
我正在进行按位操作(在C中),我想知道如何检查一个位是否在前一个值和新值之间切换.
Example :
oldValue = 0x0FF //0000 1111 1111 in binary
newValue = 0x100 //0001 0000 0000 in binary
Run Code Online (Sandbox Code Playgroud)
在这个例子中,我想检查bit8(第9位)是否已从0切换到1.
我知道如果我想知道是否设置了一下,可以使用:
value & (1 << 8)
Run Code Online (Sandbox Code Playgroud)
那么,这是正确的吗?:
if( (oldValue & (1 << 8)) == (newValue & (1 << 8)) ) //return 0 if toggled
Run Code Online (Sandbox Code Playgroud) 我是vuejs + webpack + electron的新手,我正在用这些工具开始一个新项目.
我很难在我的标签中检索资产的路径.
我的项目结构如下:
/my-project
/app
/components
componentA.vue
...
App.vue
main.js
/dist
/assets
logo.png
package.json
webpack.config.js
...
Run Code Online (Sandbox Code Playgroud)
我的webpack.config.js看起来像:
module.exports = {
// This is the "main" file which should include all other modules
entry: './app/main.js',
// Where should the compiled file go?
output: {
// To the `dist` folder
path: './dist',
// With the filename `build.js` so it's dist/build.js
filename: 'build.js'
},
module: {
loaders: [
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.js$/,
loader: 'babel-loader', …Run Code Online (Sandbox Code Playgroud)