diff --git a/examples/with-firebase-authentication/README.md b/examples/with-firebase-authentication/README.md index 94b118c61f314..041fa38d6e6f0 100644 --- a/examples/with-firebase-authentication/README.md +++ b/examples/with-firebase-authentication/README.md @@ -24,11 +24,21 @@ cd with-firebase-authentication Set up firebase: - Create a project at the [Firebase console](https://console.firebase.google.com/). -- Get your account credentials from the Firebase console at _settings>service accounts_, where you can click on _generate new private key_ and download the credentials as a json file. It will contain keys such as `project_id`, `client_email` and `client id`. Now copy them into your project in the `credentials/server.js` file. -- Get your authentication credentials from the Firebase console under _authentication>users>web setup_. It will include keys like `apiKey`, `authDomain` and `databaseUrl` and it goes into your project in `credentials/client.js`. -- Copy the `databaseUrl` key you got in the last step into `server.js` in the corresponding line. -- Back at the Firebase web console, go to _authentication>signup method_ and select _Google_. -- Create a database in the "Database" tab and select the realtime database. Then go to "rules" and set up your write, read rules. Examples can be found here: https://firebase.google.com/docs/database/security/quickstart#sample-rules +- Get your account credentials from the Firebase console at _project settings>service accounts_, where you can click on _generate new private key_ and download the credentials as a json file. It will contain keys such as `project_id`, `client_email` and `client id`. Now copy them into your project in the `credentials/server.js` file. +- Get your authentication credentials from the Firebase console under _project settings>general>your apps_ Add a new web app if you don't already have one. Under _Firebase SDK snippet_ choose _Config_ to get the configuration as JSON. It will include keys like `apiKey`, `authDomain` and `databaseUrl` and it goes into your project in `credentials/client.js`. +- Back at the Firebase web console, go to _Authentication>Sign-in method_ and enable _Google_. +- Create a database in the "Database" tab and select Firestore. Then go to "rules" and set up your write, read rules to this: + +``` +// Allow read/write access on all documents to any user signed in to the application +service cloud.firestore { + match /databases/{database}/documents { + match /{document=**} { + allow read, write: if request.auth.uid != null; + } + } +} +``` Install it and run: diff --git a/examples/with-firebase-authentication/server.js b/examples/with-firebase-authentication/server.js index d53a5815a9c97..a5fa483952d14 100644 --- a/examples/with-firebase-authentication/server.js +++ b/examples/with-firebase-authentication/server.js @@ -12,8 +12,7 @@ const handle = app.getRequestHandler() const firebase = admin.initializeApp( { - credential: admin.credential.cert(require('./credentials/server')), - databaseURL: '' // TODO database URL goes here + credential: admin.credential.cert(require('./credentials/server')) }, 'server' ) @@ -26,7 +25,7 @@ app.prepare().then(() => { session({ secret: 'geheimnis', saveUninitialized: true, - store: new FileStore({ path: '/tmp/sessions', secret: 'geheimnis' }), + store: new FileStore({ secret: 'geheimnis' }), resave: false, rolling: true, httpOnly: true, diff --git a/examples/with-firebase-authentication/sessions/.gitkeep b/examples/with-firebase-authentication/sessions/.gitkeep new file mode 100644 index 0000000000000..e69de29bb2d1d