Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update example with firebase auth #8127

Merged
merged 4 commits into from
Jul 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions examples/with-firebase-authentication/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
5 changes: 2 additions & 3 deletions examples/with-firebase-authentication/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
Expand All @@ -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,
Expand Down
Empty file.