Skip to content

Commit 21c1ea4

Browse files
authored
Merge pull request #47 from CreateThrive/feature/facebook-google-microsoft-auth
Feature: Facebook, Google and Microsoft Authentication
2 parents d6ea06d + bd6a491 commit 21c1ea4

File tree

31 files changed

+613
-25
lines changed

31 files changed

+613
-25
lines changed

.env.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ REACT_APP_FIRE_BASE_STORAGE_BUCKET = ''
66
REACT_APP_FIRE_BASE_MESSAGING_SENDER_ID = ''
77
REACT_APP_FIRE_BASE_APP_ID = ''
88
REACT_APP_FIRE_BASE_MEASURMENT_ID = ''
9-
REACT_APP_CLOUD_FUNCTIONS_REST_API = '<FIREBASE_CLOUD_FUNCTIONS_URL>/requestsApp'
109
REACT_APP_LOGIN_PAGE_URL = 'http://localhost:3000/login'
1110
REACT_APP_FIRE_BASE_STORAGE_API = 'https://firebasestorage.googleapis.com/v0/b/${REACT_APP_FIRE_BASE_STORAGE_BUCKET}'

README.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Boilerplate with React ⚛️ and Firebase 🔥designed to quickly spin up a ful
1515
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
1616
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
1717

18+
1819
- [What is this?](#what-is-this)
1920
- [Why should I use it?](#why-should-i-use-it)
2021
- [Features](#features)
@@ -62,6 +63,17 @@ Boilerplate with React ⚛️ and Firebase 🔥designed to quickly spin up a ful
6263
- [File Upload](#file-upload)
6364
- [Image resize extension](#image-resize-extension)
6465
- [Storage Rules](#storage-rules)
66+
- [Authentication via social media accounts](#authentication-via-social-media-accounts)
67+
- [How it works?](#how-it-works)
68+
- [Can I add more login methods?](#can-i-add-more-login-methods)
69+
- [Facebook](#facebook)
70+
- [Enabling Facebook with Firebase](#enabling-facebook-with-firebase)
71+
- [Facebook for developers App configuration](#facebook-for-developers-app-configuration)
72+
- [Continuing with the Firebase setup](#continuing-with-the-firebase-setup)
73+
- [Configure Facebook sign-in/sign-up for production](#configure-facebook-sign-insign-up-for-production)
74+
- [Google](#google)
75+
- [Microsoft](#microsoft)
76+
- [Azure App configuration](#azure-app-configuration)
6577
- [Contributors](#contributors)
6678
- [License](#license)
6779

@@ -660,6 +672,106 @@ service firebase.storage {
660672
}
661673
```
662674
675+
## Authentication via social media accounts
676+
677+
In this boilerplate users have the option to login via e-mail and password but also they can sign-up/sign-in with their Facebook, Google and Microsoft accounts.
678+
679+
<p align="center">
680+
<img src="https://i.imgur.com/xQz5pSR.png">
681+
</p>
682+
683+
### How it works?
684+
685+
We implemented social media authentication using Firebase!. You can take a look at their documentation [here](https://firebase.google.com/docs/auth/web/google-signin). In the following section we will explain how to configure each of these authentication methods.
686+
687+
### Can I add more login methods?
688+
689+
Yes you can!. We already have the setup in place for more login methods like Twitter, GitHub, etc. You can add them without chaning much code at all. You can see other login methods provided by Firebase [here](https://firebase.google.com/docs/auth/web/start).
690+
691+
### Facebook
692+
693+
#### Enabling Facebook with Firebase
694+
695+
1. Go to your [Firebase console](https://console.firebase.google.com/).
696+
2. Go to the "**Develop**" option and then click on "**Authentication**".
697+
3. Go to the tab "**Sign-in method**".
698+
4. Now select the "**Facebook**" option and copy the **_OAuth redirect URL_** provided by Firebase.
699+
5. Keep this window open because we need to configure the app on Facebook's developer site.
700+
701+
#### Facebook for developers App configuration
702+
703+
Log-in/Sign-up into your [Facebook for developers](https://developers.facebook.com/) account, create an app and configure it to make Sign-in via Facebook available.
704+
705+
<ol>
706+
<li>Name your App</li>
707+
<li>Click on configure on Log in with Facebook</li>
708+
<li>Choose the Web option </li>
709+
<li>Select Web, set http://localhost:3000 as the URL</li>
710+
<li>Select Product Settings > Facebook Login config on the Side Bar</li>
711+
<li>Put your OAuth redirect URI (the one you copied in the past), you can verify your redirect URI at the buttom of this page</li>
712+
<li>Select Configuration > Basic on the Side Bar</li>
713+
<li>There you have your app id and your app secret for setting them on your project from the Firebase console</li>
714+
</ol>
715+
716+
#### Continuing with the Firebase setup
717+
718+
<ol>
719+
<li>Go to the Firebase Console window we left open in the previous steps.</li>
720+
<li>Put the app id and the app secret we recieved from the last section.</li>
721+
<li>Enable the Facebook provider.</li>
722+
</ol>
723+
724+
Now you have configured Facebook auth in you project.
725+
726+
#### Configure Facebook sign-in/sign-up for production
727+
728+
<ol>
729+
<li>Select Configuration > Basic on the Side Bar</li>
730+
<li>Put your contact email and your privacy policy URL</li>
731+
<li>At the buttom of the page, select Website and change the URL for your domain</li>
732+
<li>Save Changes</li>
733+
<li>Turn off the "on Development" switch</li>
734+
</ol>
735+
736+
You can have a more in-depth look about Facebook login with Firebase [here](https://firebase.google.com/docs/auth/web/facebook-login).
737+
738+
### Google
739+
740+
For setting your Google authentication you will only need to go to your project from the [Firebase console](https://console.firebase.google.com/), then select Authentication on the Side Bar and Sign-in method. Click the Google logo, select a Project support email, enable the Google provider and save.
741+
742+
You can have a more in-depth look about Google login with Firebase [here](https://firebase.google.com/docs/auth/web/google-signin).
743+
744+
### Microsoft
745+
746+
Go to your [Firebase console](https://console.firebase.google.com/), select the project, then select Authentication on the Side Bar and Sign-in method. Click the Microsoft logo, copy the redirect URL and keep this window open for later.
747+
748+
Before setting your Application id and the Application secret on the Microsoft Sign-in method from the Firebase console, you will need to log-in into your [Azure](https://portal.azure.com/) account, create an app and configure it to make Sign-in via Microsoft available.
749+
750+
#### Azure App configuration
751+
752+
<ol>
753+
<li>Once you are logged to your account click the left, top corner and select Azure Active Directory.</li>
754+
<li>Under Manage, select App registration.</li>
755+
<li>Name your App.</li>
756+
<li>Specify who can use the application.</li>
757+
<li>Put your redirect URL (the one you already copied).</li>
758+
<li>Select Register.</li>
759+
<li>Select Certificates & secrets from the Side Bar.</li>
760+
<li>Select Add a new client secret.</li>
761+
<li>Set the expiration time.</li>
762+
</ol>
763+
764+
For more on [Register](https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app) and [configure the app](https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-configure-app-access-web-apis).
765+
766+
**Firebase console**
767+
768+
<li>Go to the Firebase Console window from the beginning</li>
769+
<li>Put the Application id, located on Overview on your Azure App.</li>
770+
<li>Put Application secret, located on Certificates & secrets on your Azure App.</li>
771+
<li>Enable the Microsoft provider.</li>
772+
773+
You can have a more in-depth look about Microsoft login with Firebase [here](https://firebase.google.com/docs/auth/web/microsoft-oauth).
774+
663775
## Contributors
664776
665777
We'd like to thank these awesome people who made this whole thing happen:

database.rules.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"rules": {
33
"users": {
44
"$user": {
5-
".write": "auth !== null && auth.token.email_verified === true && ((auth.token.isAdmin === true && data.child('isAdmin').val() === false) || auth.uid === $user)",
6-
".read": "auth !== null && auth.token.email_verified === true && ((auth.token.isAdmin === true && data.child('isAdmin').val() === false) || auth.uid === $user)"
5+
".write": "auth !== null && ((auth.token.isAdmin === true && data.child('isAdmin').val() === false) || auth.uid === $user)",
6+
".read": "auth !== null && ((auth.token.isAdmin === true && data.child('isAdmin').val() === false) || auth.uid === $user)"
77
},
8-
".write": "auth !== null && auth.token.email_verified === true && auth.token.isAdmin === true",
9-
".read": "auth !== null && auth.token.email_verified === true && auth.token.isAdmin === true"
8+
".write": "auth !== null && auth.token.isAdmin === true",
9+
".read": "auth !== null && auth.token.isAdmin === true"
1010
}
1111
}
1212
}

package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"private": true,
55
"dependencies": {
66
"bulma": "^0.8.2",
7+
"bulma-social": "^1.1.1",
78
"classnames": "^2.2.6",
89
"cookies-js": "^1.2.3",
910
"date-fns": "^2.14.0",

src/components/DatePicker/__snapshots__/DatePicker.test.js.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ exports[`<DatePickerStyled /> rendering should render without crashing 1`] = `
4747
"Home.content": "Home content",
4848
"Home.home": "Home",
4949
"Login.email": "E-mail Address",
50+
"Login.facebook": "Continue with Facebook",
5051
"Login.forgotPassword": "Forgot Password?",
52+
"Login.google": "Continue with Google",
5153
"Login.login": "Login",
54+
"Login.microsoft": "Continue with Microsoft",
5255
"Login.password": "Password",
5356
"Login.setNewPassword": "Set your new password",
5457
"Login.setPassword": "Set Password",
@@ -97,10 +100,14 @@ exports[`<DatePickerStyled /> rendering should render without crashing 1`] = `
97100
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
98101
"Users.search": "Search:",
99102
"Users.users": "Users",
103+
"auth/account-exists-with-different-credential": "Email on another sign in method",
104+
"auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
100105
"auth/email-already-exists": "Email already in use",
101106
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
102107
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
103108
"auth/invalid-email": "Email is invalid",
109+
"auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
110+
"auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
104111
"auth/too-many-requests": "Too many attempts made, try again later",
105112
"auth/user-disabled": "User disabled",
106113
"auth/wrong-password": "Invalid credentials",

src/components/Layout/__snapshots__/Layout.test.js.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ exports[`<Layout /> rendering should render without crashing 1`] = `
4747
"Home.content": "Home content",
4848
"Home.home": "Home",
4949
"Login.email": "E-mail Address",
50+
"Login.facebook": "Continue with Facebook",
5051
"Login.forgotPassword": "Forgot Password?",
52+
"Login.google": "Continue with Google",
5153
"Login.login": "Login",
54+
"Login.microsoft": "Continue with Microsoft",
5255
"Login.password": "Password",
5356
"Login.setNewPassword": "Set your new password",
5457
"Login.setPassword": "Set Password",
@@ -97,10 +100,14 @@ exports[`<Layout /> rendering should render without crashing 1`] = `
97100
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
98101
"Users.search": "Search:",
99102
"Users.users": "Users",
103+
"auth/account-exists-with-different-credential": "Email on another sign in method",
104+
"auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
100105
"auth/email-already-exists": "Email already in use",
101106
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
102107
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
103108
"auth/invalid-email": "Email is invalid",
109+
"auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
110+
"auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
104111
"auth/too-many-requests": "Too many attempts made, try again later",
105112
"auth/user-disabled": "User disabled",
106113
"auth/wrong-password": "Invalid credentials",

src/components/Navigation/Aside/__snapshots__/Aside.test.js.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ Object {
4848
"Home.content": "Home content",
4949
"Home.home": "Home",
5050
"Login.email": "E-mail Address",
51+
"Login.facebook": "Continue with Facebook",
5152
"Login.forgotPassword": "Forgot Password?",
53+
"Login.google": "Continue with Google",
5254
"Login.login": "Login",
55+
"Login.microsoft": "Continue with Microsoft",
5356
"Login.password": "Password",
5457
"Login.setNewPassword": "Set your new password",
5558
"Login.setPassword": "Set Password",
@@ -98,10 +101,14 @@ Object {
98101
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
99102
"Users.search": "Search:",
100103
"Users.users": "Users",
104+
"auth/account-exists-with-different-credential": "Email on another sign in method",
105+
"auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
101106
"auth/email-already-exists": "Email already in use",
102107
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
103108
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
104109
"auth/invalid-email": "Email is invalid",
110+
"auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
111+
"auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
105112
"auth/too-many-requests": "Too many attempts made, try again later",
106113
"auth/user-disabled": "User disabled",
107114
"auth/wrong-password": "Invalid credentials",

src/components/Navigation/NavBar/__snapshots__/NavBar.test.js.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ exports[`<NavBar /> rendering should render without crashing 1`] = `
4747
"Home.content": "Home content",
4848
"Home.home": "Home",
4949
"Login.email": "E-mail Address",
50+
"Login.facebook": "Continue with Facebook",
5051
"Login.forgotPassword": "Forgot Password?",
52+
"Login.google": "Continue with Google",
5153
"Login.login": "Login",
54+
"Login.microsoft": "Continue with Microsoft",
5255
"Login.password": "Password",
5356
"Login.setNewPassword": "Set your new password",
5457
"Login.setPassword": "Set Password",
@@ -97,10 +100,14 @@ exports[`<NavBar /> rendering should render without crashing 1`] = `
97100
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
98101
"Users.search": "Search:",
99102
"Users.users": "Users",
103+
"auth/account-exists-with-different-credential": "Email on another sign in method",
104+
"auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
100105
"auth/email-already-exists": "Email already in use",
101106
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
102107
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
103108
"auth/invalid-email": "Email is invalid",
109+
"auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
110+
"auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
104111
"auth/too-many-requests": "Too many attempts made, try again later",
105112
"auth/user-disabled": "User disabled",
106113
"auth/wrong-password": "Invalid credentials",

src/components/UserForm/__snapshots__/UserForm.test.js.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ exports[`<UserForm /> rendering should render without crashing 1`] = `
4747
"Home.content": "Home content",
4848
"Home.home": "Home",
4949
"Login.email": "E-mail Address",
50+
"Login.facebook": "Continue with Facebook",
5051
"Login.forgotPassword": "Forgot Password?",
52+
"Login.google": "Continue with Google",
5153
"Login.login": "Login",
54+
"Login.microsoft": "Continue with Microsoft",
5255
"Login.password": "Password",
5356
"Login.setNewPassword": "Set your new password",
5457
"Login.setPassword": "Set Password",
@@ -97,10 +100,14 @@ exports[`<UserForm /> rendering should render without crashing 1`] = `
97100
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
98101
"Users.search": "Search:",
99102
"Users.users": "Users",
103+
"auth/account-exists-with-different-credential": "Email on another sign in method",
104+
"auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
100105
"auth/email-already-exists": "Email already in use",
101106
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
102107
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
103108
"auth/invalid-email": "Email is invalid",
109+
"auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
110+
"auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
104111
"auth/too-many-requests": "Too many attempts made, try again later",
105112
"auth/user-disabled": "User disabled",
106113
"auth/wrong-password": "Invalid credentials",

0 commit comments

Comments
 (0)