strapi-plugin-firebase-authentication 1.0.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +415 -191
- package/dist/_chunks/App-Bl6D4TFu.mjs +6197 -0
- package/dist/_chunks/App-HfsY_18f.js +6181 -0
- package/dist/_chunks/{api-4hcml0jk.mjs → api-B01IAVEC.mjs} +14 -3
- package/dist/_chunks/{api-DPtT1Bpu.js → api-BSejy8nn.js} +14 -3
- package/dist/_chunks/index-4hUrKd7Y.mjs +815 -0
- package/dist/_chunks/index-BbVqBI3M.js +859 -0
- package/dist/_chunks/index-BqF9RRVF.mjs +859 -0
- package/dist/_chunks/index-DgfRCyyQ.js +814 -0
- package/dist/admin/index.js +6 -1
- package/dist/admin/index.mjs +7 -2
- package/dist/admin/src/components/PasswordResetButton/PasswordResetButton.d.ts +11 -0
- package/dist/admin/src/components/PasswordResetButton/index.d.ts +1 -0
- package/dist/admin/src/components/common/Header/Header.d.ts +12 -0
- package/dist/admin/src/components/common/index.d.ts +3 -0
- package/dist/admin/src/components/forms/CreateUserForm/CreateUserForm.d.ts +2 -0
- package/dist/admin/src/components/forms/EditUserForm/EditUserForm.d.ts +6 -0
- package/dist/admin/src/components/forms/index.d.ts +4 -0
- package/dist/admin/src/components/forms/shared/UserFormFields/UserFormFields.d.ts +17 -0
- package/dist/admin/src/components/forms/shared/UserFormLayout/UserFormLayout.d.ts +7 -0
- package/dist/admin/src/components/index.d.ts +5 -0
- package/dist/admin/src/components/search/SearchURLQuery/SearchURLQuery.d.ts +6 -0
- package/dist/admin/src/components/search/index.d.ts +1 -0
- package/dist/admin/src/components/{DynamicTable → table/FirebaseTable}/FirebaseTable.d.ts +3 -2
- package/dist/admin/src/components/{DynamicTable → table}/FirebaseTableRows/FirebaseTableRows.d.ts +2 -2
- package/dist/admin/src/components/table/index.d.ts +3 -0
- package/dist/admin/src/components/user-management/ResetPassword/ResetPassword.d.ts +12 -0
- package/dist/admin/src/components/user-management/index.d.ts +2 -0
- package/dist/admin/src/hooks/useBulkSelection.d.ts +14 -0
- package/dist/admin/src/hooks/useUserForm.d.ts +18 -0
- package/dist/admin/src/pages/CreateView.d.ts +1 -0
- package/dist/admin/src/pages/EditView.d.ts +1 -0
- package/dist/admin/src/pages/ListView/index.d.ts +3 -5
- package/dist/admin/src/pages/Settings/api.d.ts +20 -1
- package/dist/admin/src/pages/utils/api.d.ts +4 -1
- package/dist/admin/src/utils/hasPasswordProvider.d.ts +15 -0
- package/dist/admin/src/utils/validation.d.ts +16 -0
- package/dist/model/Request.d.ts +2 -0
- package/dist/model/User.d.ts +6 -0
- package/dist/server/index.js +8466 -2851
- package/dist/server/index.mjs +8465 -2867
- package/dist/server/src/config/index.d.ts +36 -1
- package/dist/server/src/constants/index.d.ts +107 -0
- package/dist/server/src/content-types/index.d.ts +82 -0
- package/dist/server/src/controllers/firebaseController.d.ts +32 -2
- package/dist/server/src/controllers/index.d.ts +16 -10
- package/dist/server/src/controllers/settingsController.d.ts +2 -0
- package/dist/server/src/controllers/userController.d.ts +1 -0
- package/dist/server/src/index.d.ts +194 -27
- package/dist/server/src/migrations/migrate-firebase-user-data.d.ts +30 -0
- package/dist/server/src/routes/admin.d.ts +1 -1
- package/dist/server/src/routes/content-api.d.ts +1 -0
- package/dist/server/src/routes/content-internal-api.d.ts +1 -1
- package/dist/server/src/routes/index.d.ts +3 -2
- package/dist/server/src/routes/settingsRoutes.d.ts +1 -1
- package/dist/server/src/services/autoLinkService.d.ts +29 -0
- package/dist/server/src/services/emailService.d.ts +32 -0
- package/dist/server/src/services/firebaseService.d.ts +87 -13
- package/dist/server/src/services/firebaseStrapiLinkService.d.ts +34 -0
- package/dist/server/src/services/firebaseUserDataService.d.ts +26 -0
- package/dist/server/src/services/index.d.ts +91 -16
- package/dist/server/src/services/settingsService.d.ts +55 -0
- package/dist/server/src/services/templateService.d.ts +21 -0
- package/dist/server/src/services/userService.d.ts +2 -1
- package/dist/server/src/templates/defaults/index.d.ts +2 -0
- package/dist/server/src/templates/defaults/magic-link.d.ts +2 -0
- package/dist/server/src/templates/defaults/password-reset.d.ts +2 -0
- package/dist/server/src/templates/types.d.ts +30 -0
- package/dist/server/src/utils/fetch-me.d.ts +2 -10
- package/dist/server/src/utils/get-user-by-id.d.ts +1 -5
- package/dist/server/src/utils/users.d.ts +14 -0
- package/package.json +32 -22
- package/dist/_chunks/App-B2LtHk9g.js +0 -5062
- package/dist/_chunks/App-B3HcVa5j.mjs +0 -5081
- package/dist/_chunks/index-CALp4X47.mjs +0 -110
- package/dist/_chunks/index-CrGRt-Ya.mjs +0 -191
- package/dist/_chunks/index-DMBPEFUy.js +0 -109
- package/dist/_chunks/index-DmTKNKJB.js +0 -191
- package/dist/admin/src/components/SearchURLQuery/SearchURLQuery.d.ts +0 -18
- package/dist/admin/src/components/UserManagement/ResetPassword.d.ts +0 -8
- /package/dist/admin/src/components/{Initializer.d.ts → common/Initializer/Initializer.d.ts} +0 -0
- /package/dist/admin/src/components/{PluginIcon.d.ts → common/PluginIcon/PluginIcon.d.ts} +0 -0
- /package/dist/admin/src/components/{DynamicTable → table/FirebaseTable}/TableHeaders.d.ts +0 -0
- /package/dist/admin/src/components/{UserManagement → user-management/DeleteAccount}/DeleteAccount.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,297 +1,521 @@
|
|
|
1
1
|
# Strapi Plugin Firebase Authentication
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
this plugin with iOS and Android apps. This plugin would be enabled by default for super admins only.
|
|
3
|
+
[](https://www.npmjs.com/package/strapi-plugin-firebase-authentication)
|
|
4
|
+
[](https://www.npmjs.com/package/strapi-plugin-firebase-authentication)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
A production-ready Strapi v5 plugin that seamlessly integrates Firebase Authentication with your Strapi Headless CMS. Authenticate users via Firebase (Google, Apple, Email/Password, Phone, Magic Link) and automatically sync them with Strapi's user system.
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
## Features at a Glance
|
|
10
|
+
|
|
11
|
+
- **Multiple Authentication Methods**: Google Sign-In, Apple Sign-In, Email/Password, Phone-only, Magic Link (passwordless)
|
|
12
|
+
- **Automatic User Sync**: Creates and updates Strapi users from Firebase authentication
|
|
13
|
+
- **Password Reset Flow**: Complete password reset with email verification
|
|
14
|
+
- **Phone-Only Support**: Configurable email handling for phone-based authentication
|
|
15
|
+
- **Admin Panel**: Manage Firebase users directly from Strapi admin
|
|
16
|
+
- **Secure Configuration**: AES-256 encrypted Firebase credentials
|
|
17
|
+
- **Email Service**: Three-tier fallback (Strapi Email Plugin → Firebase Extension → Console)
|
|
18
|
+
- **Flexible User Lookup**: Multiple strategies (Firebase UID, email, phone, Apple relay email)
|
|
13
19
|
|
|
14
20
|
## Table of Contents
|
|
15
21
|
|
|
16
|
-
1. [
|
|
17
|
-
2. [
|
|
18
|
-
3. [
|
|
19
|
-
4. [
|
|
20
|
-
5. [
|
|
22
|
+
1. [Quick Reference](#quick-reference)
|
|
23
|
+
2. [Installation](#installation)
|
|
24
|
+
3. [Configuration](#configuration)
|
|
25
|
+
4. [Features & Authentication Flows](#features--authentication-flows)
|
|
26
|
+
5. [API Reference](#api-reference)
|
|
27
|
+
6. [Admin Panel](#admin-panel)
|
|
28
|
+
7. [Client Integration](#client-integration)
|
|
29
|
+
8. [Email Templates](#email-templates)
|
|
30
|
+
9. [Architecture & Database](#architecture--database)
|
|
31
|
+
10. [Security](#security)
|
|
32
|
+
11. [Troubleshooting](#troubleshooting)
|
|
33
|
+
12. [Best Practices](#best-practices)
|
|
34
|
+
13. [Support](#support)
|
|
35
|
+
|
|
36
|
+
## Quick Reference
|
|
37
|
+
|
|
38
|
+
### Essential Endpoints
|
|
39
|
+
|
|
40
|
+
**Authentication:**
|
|
41
|
+
|
|
42
|
+
- `POST /api/firebase-authentication` - Exchange Firebase token for Strapi JWT
|
|
43
|
+
- `POST /api/firebase-authentication/emailLogin` - Direct email/password login
|
|
44
|
+
- `POST /api/firebase-authentication/forgotPassword` - Request password reset
|
|
45
|
+
- `POST /api/firebase-authentication/resetPassword` - Reset with JWT token
|
|
46
|
+
- `POST /api/firebase-authentication/requestMagicLink` - Passwordless login
|
|
47
|
+
- `GET /api/firebase-authentication/config` - Get public configuration
|
|
48
|
+
|
|
49
|
+
### Minimal Configuration
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
// config/plugins.js
|
|
53
|
+
module.exports = () => ({
|
|
54
|
+
"firebase-authentication": {
|
|
55
|
+
enabled: true,
|
|
56
|
+
config: {
|
|
57
|
+
FIREBASE_JSON_ENCRYPTION_KEY: process.env.FIREBASE_JSON_ENCRYPTION_KEY,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# .env
|
|
65
|
+
FIREBASE_JSON_ENCRYPTION_KEY=your-secure-32-character-key-here
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Required Setup Steps
|
|
69
|
+
|
|
70
|
+
1. **Install:** `yarn add strapi-plugin-firebase-authentication`
|
|
71
|
+
2. **Configure:** Add plugin config to `config/plugins.js`
|
|
72
|
+
3. **Build:** `yarn build && yarn develop`
|
|
73
|
+
4. **Upload:** Settings → Firebase Authentication → Upload service account JSON
|
|
74
|
+
5. **Permissions:** Settings → Users & Permissions → Public → `firebase-authentication.authenticate` ✓
|
|
75
|
+
|
|
76
|
+
### Admin Access
|
|
77
|
+
|
|
78
|
+
- **Settings:** Settings → Firebase Authentication
|
|
79
|
+
- **User Management:** Plugins → Firebase Authentication
|
|
80
|
+
|
|
81
|
+
---
|
|
21
82
|
|
|
22
83
|
## Installation
|
|
23
84
|
|
|
24
|
-
|
|
85
|
+
### Prerequisites
|
|
86
|
+
|
|
87
|
+
Before installing, ensure you have:
|
|
88
|
+
|
|
89
|
+
- Strapi v5 project (this plugin is for v5 only)
|
|
90
|
+
- Firebase project with Authentication enabled ([Create one](https://console.firebase.google.com/))
|
|
91
|
+
- Node.js 18+ and npm/yarn installed
|
|
92
|
+
|
|
93
|
+
### Step 1: Install Plugin
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
yarn add strapi-plugin-firebase-authentication
|
|
97
|
+
# or
|
|
98
|
+
npm install strapi-plugin-firebase-authentication
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Verify:** Check that the plugin appears in your `package.json` dependencies.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
### Step 2: Create Encryption Key
|
|
25
106
|
|
|
26
|
-
|
|
107
|
+
Generate a secure 32+ character encryption key for storing Firebase credentials:
|
|
27
108
|
|
|
28
109
|
```bash
|
|
29
|
-
|
|
110
|
+
# Generate a random key (save this!)
|
|
111
|
+
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
|
|
30
112
|
```
|
|
31
113
|
|
|
32
|
-
|
|
114
|
+
**Common Mistake:** Using a weak or short key. The key MUST be at least 32 characters.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### Step 3: Configure Plugin
|
|
119
|
+
|
|
120
|
+
Create or edit `config/plugins.js`:
|
|
121
|
+
|
|
122
|
+
```javascript
|
|
123
|
+
module.exports = () => ({
|
|
124
|
+
"firebase-authentication": {
|
|
125
|
+
enabled: true,
|
|
126
|
+
config: {
|
|
127
|
+
FIREBASE_JSON_ENCRYPTION_KEY: process.env.FIREBASE_JSON_ENCRYPTION_KEY,
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Add to `.env` file:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
FIREBASE_JSON_ENCRYPTION_KEY=your-generated-key-from-step-2
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Verify:** Run `echo $FIREBASE_JSON_ENCRYPTION_KEY` to confirm it's set.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
### Step 4: Build and Start
|
|
33
144
|
|
|
34
145
|
```bash
|
|
35
146
|
yarn build
|
|
36
147
|
yarn develop
|
|
37
148
|
```
|
|
38
149
|
|
|
39
|
-
|
|
150
|
+
**What happens:**
|
|
40
151
|
|
|
41
|
-
|
|
42
|
-
|
|
152
|
+
- Plugin compiles (admin + server)
|
|
153
|
+
- Strapi restarts with plugin enabled
|
|
154
|
+
- "Firebase Authentication" appears in Plugins sidebar
|
|
155
|
+
|
|
156
|
+
**Verify:** Check console output for:
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
✔ Building admin panel (XX.Xs)
|
|
160
|
+
Firebase Authentication plugin initialized
|
|
43
161
|
```
|
|
44
162
|
|
|
45
|
-
|
|
163
|
+
**If build fails:** Run `yarn build --clean` to clear cache.
|
|
46
164
|
|
|
47
|
-
|
|
165
|
+
---
|
|
48
166
|
|
|
49
|
-
|
|
167
|
+
### Step 5: Download Firebase Service Account
|
|
50
168
|
|
|
51
|
-
|
|
169
|
+
1. Go to [Firebase Console](https://console.firebase.google.com/)
|
|
170
|
+
2. Select your project
|
|
171
|
+
3. Navigate to: **Project Settings** (⚙️ icon) → **Service Accounts** tab
|
|
172
|
+
4. Click **"Generate New Private Key"**
|
|
173
|
+
5. Download and save the JSON file securely (you'll upload this next)
|
|
52
174
|
|
|
53
|
-
|
|
54
|
-
plugin. If the file doesn't exist, create it manually. If you already have configurations for other plugins, add
|
|
55
|
-
the `firebase-auth` section to your existing `plugins` configuration.
|
|
175
|
+
**Important:** This JSON contains sensitive credentials. Never commit it to Git.
|
|
56
176
|
|
|
57
|
-
|
|
177
|
+
---
|
|
58
178
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
179
|
+
### Step 6: Upload to Strapi
|
|
180
|
+
|
|
181
|
+
1. Navigate to: **Settings → Firebase Authentication** (left sidebar)
|
|
182
|
+
2. Click **"Upload Configuration"** button
|
|
183
|
+
3. Select the downloaded service account JSON file
|
|
184
|
+
4. Wait for "Configuration uploaded successfully" message
|
|
185
|
+
5. **Restart Strapi:** `yarn develop` (important!)
|
|
186
|
+
|
|
187
|
+
**Verify:** You should see in console:
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
Firebase Admin SDK initialized successfully
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**If initialization fails:** Check [Troubleshooting](#troubleshooting) section.
|
|
194
|
+
|
|
195
|
+
---
|
|
62
196
|
|
|
63
|
-
|
|
197
|
+
### Step 7: Configure Permissions
|
|
198
|
+
|
|
199
|
+
Navigate to: **Settings → Users & Permissions → Roles → Public**
|
|
200
|
+
|
|
201
|
+
Enable these permissions:
|
|
202
|
+
|
|
203
|
+
- `firebase-authentication` → `authenticate` ✓
|
|
204
|
+
|
|
205
|
+
**Why:** This allows unauthenticated users to exchange Firebase tokens for Strapi JWTs.
|
|
206
|
+
|
|
207
|
+
**Verify:** The permission checkbox should be checked and saved.
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
### Step 8: Test Your Setup
|
|
212
|
+
|
|
213
|
+
Create a simple test to verify everything works:
|
|
214
|
+
|
|
215
|
+
**Option 1: Test with Firebase Token**
|
|
216
|
+
|
|
217
|
+
1. Get a Firebase ID token from your client app (or Firebase Console)
|
|
218
|
+
2. Send POST request to: `http://localhost:1337/api/firebase-authentication`
|
|
219
|
+
3. Body: `{ "idToken": "your-firebase-token-here" }`
|
|
220
|
+
4. Expected: `200 OK` with `{ user, jwt }` response
|
|
221
|
+
|
|
222
|
+
**Option 2: Test with Email/Password** (if configured)
|
|
223
|
+
|
|
224
|
+
1. Create a user in Firebase Console
|
|
225
|
+
2. Send POST to: `http://localhost:1337/api/firebase-authentication/emailLogin`
|
|
226
|
+
3. Body: `{ "email": "test@example.com", "password": "password123" }`
|
|
227
|
+
4. Expected: `200 OK` with `{ user, jwt }` response
|
|
228
|
+
|
|
229
|
+
**If tests fail:** Check [Troubleshooting](#troubleshooting) for common issues.
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
### Common Setup Mistakes
|
|
234
|
+
|
|
235
|
+
❌ **Encryption key too short** → Must be 32+ characters
|
|
236
|
+
❌ **Forgot to restart after uploading config** → Always restart Strapi
|
|
237
|
+
❌ **Wrong Firebase project** → Ensure service account matches your client app
|
|
238
|
+
❌ **Forgot to enable permissions** → Public role needs `authenticate` permission
|
|
239
|
+
❌ **Committed service account JSON to Git** → Use `.gitignore`
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
### Next Steps
|
|
244
|
+
|
|
245
|
+
After successful installation:
|
|
246
|
+
|
|
247
|
+
1. **Configure additional settings** (optional):
|
|
248
|
+
- Password requirements: **Settings → Firebase Authentication**
|
|
249
|
+
- Magic link settings (passwordless auth)
|
|
250
|
+
- Email templates for password reset
|
|
251
|
+
|
|
252
|
+
2. **Integrate with your client app** (see [Client Integration](#client-integration))
|
|
253
|
+
|
|
254
|
+
3. **Set up email service** for password reset (see [Email Templates](#email-templates))
|
|
255
|
+
|
|
256
|
+
4. **Review security best practices** (see [Best Practices](#best-practices))
|
|
257
|
+
|
|
258
|
+
## Configuration
|
|
259
|
+
|
|
260
|
+
The plugin is configured in two places: `config/plugins.js` and the Strapi admin panel.
|
|
261
|
+
|
|
262
|
+
**Minimal Configuration** (`config/plugins.js`):
|
|
263
|
+
|
|
264
|
+
```javascript
|
|
265
|
+
module.exports = () => ({
|
|
266
|
+
"firebase-authentication": {
|
|
64
267
|
enabled: true,
|
|
65
|
-
config: {
|
|
268
|
+
config: {
|
|
269
|
+
FIREBASE_JSON_ENCRYPTION_KEY: process.env.FIREBASE_JSON_ENCRYPTION_KEY,
|
|
270
|
+
},
|
|
66
271
|
},
|
|
67
|
-
|
|
68
|
-
// ...
|
|
69
272
|
});
|
|
70
273
|
```
|
|
71
274
|
|
|
72
|
-
|
|
275
|
+
**Admin Panel Settings** (Settings → Firebase Authentication):
|
|
276
|
+
|
|
277
|
+
- Firebase Web API Key (for email/password login)
|
|
278
|
+
- Password requirements (regex + message)
|
|
279
|
+
- Password reset URL & email subject
|
|
280
|
+
- Magic link settings (enable, URL, subject, expiry)
|
|
281
|
+
- Phone-only user handling (`emailRequired: false` for phone-only apps)
|
|
73
282
|
|
|
74
|
-
|
|
283
|
+
## API Reference
|
|
75
284
|
|
|
76
|
-
|
|
285
|
+
### Public Endpoints
|
|
77
286
|
|
|
78
|
-
|
|
287
|
+
| Method | Endpoint | Purpose |
|
|
288
|
+
| ------ | ----------------------------------------------- | -------------------------------------- |
|
|
289
|
+
| POST | `/api/firebase-authentication` | Exchange Firebase token for Strapi JWT |
|
|
290
|
+
| POST | `/api/firebase-authentication/emailLogin` | Email/password login (no SDK required) |
|
|
291
|
+
| POST | `/api/firebase-authentication/forgotPassword` | Request password reset email |
|
|
292
|
+
| POST | `/api/firebase-authentication/resetPassword` | Reset password with JWT token |
|
|
293
|
+
| POST | `/api/firebase-authentication/requestMagicLink` | Request passwordless login email |
|
|
294
|
+
| GET | `/api/firebase-authentication/config` | Get public configuration |
|
|
79
295
|
|
|
80
|
-
|
|
296
|
+
### Admin Endpoints
|
|
81
297
|
|
|
82
|
-
|
|
298
|
+
**User Management:**
|
|
299
|
+
| Method | Endpoint | Purpose |
|
|
300
|
+
|--------|----------|---------|
|
|
301
|
+
| GET | `/api/firebase-authentication/content-internal-api/users` | List/search users |
|
|
302
|
+
| POST | `/api/firebase-authentication/content-internal-api/users` | Create user |
|
|
303
|
+
| GET | `/api/firebase-authentication/content-internal-api/users/:id` | Get user |
|
|
304
|
+
| PUT | `/api/firebase-authentication/content-internal-api/users/:id` | Update user |
|
|
305
|
+
| DELETE | `/api/firebase-authentication/content-internal-api/users/:id` | Delete user |
|
|
306
|
+
| PUT | `/api/firebase-authentication/content-internal-api/users/resetPassword/:id` | Reset password |
|
|
83
307
|
|
|
84
|
-
|
|
308
|
+
**Settings Management:**
|
|
309
|
+
| Method | Endpoint | Purpose |
|
|
310
|
+
|--------|----------|---------|
|
|
311
|
+
| GET/POST/DELETE | `/api/firebase-authentication/settings/firebase-config` | Manage Firebase config |
|
|
312
|
+
| POST | `/api/firebase-authentication/settings/password-config` | Update password/magic link settings |
|
|
85
313
|
|
|
86
|
-
|
|
314
|
+
---
|
|
87
315
|
|
|
88
|
-
|
|
316
|
+
## Usage
|
|
89
317
|
|
|
90
|
-
|
|
91
|
-
the `.json` [service account key file](https://firebase.google.com/docs/app-distribution/authenticate-service-account).
|
|
92
|
-
This key is essential for Firebase Authentication to work properly.
|
|
318
|
+
**Basic Flow:**
|
|
93
319
|
|
|
94
|
-
|
|
320
|
+
1. User authenticates with Firebase Client SDK
|
|
321
|
+
2. Client gets Firebase ID token
|
|
322
|
+
3. Client sends token to Strapi: `POST /api/firebase-authentication`
|
|
323
|
+
4. Plugin returns Strapi JWT for API access
|
|
95
324
|
|
|
96
|
-
|
|
325
|
+
**Example (JavaScript):**
|
|
97
326
|
|
|
98
|
-
```
|
|
99
|
-
|
|
327
|
+
```javascript
|
|
328
|
+
// After Firebase authentication
|
|
329
|
+
const idToken = await firebaseUser.getIdToken();
|
|
330
|
+
|
|
331
|
+
// Exchange with Strapi
|
|
332
|
+
const response = await fetch("https://your-api.com/api/firebase-authentication", {
|
|
333
|
+
method: "POST",
|
|
334
|
+
headers: { "Content-Type": "application/json" },
|
|
335
|
+
body: JSON.stringify({ idToken }),
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
const { user, jwt } = await response.json();
|
|
339
|
+
localStorage.setItem("jwt", jwt); // Use this JWT for Strapi API calls
|
|
100
340
|
```
|
|
101
341
|
|
|
102
|
-
|
|
342
|
+
**Resources:**
|
|
103
343
|
|
|
104
|
-
|
|
344
|
+
- [Firebase Web SDK](https://firebase.google.com/docs/auth/web/start)
|
|
345
|
+
- [Firebase iOS SDK](https://firebase.google.com/docs/auth/ios/start)
|
|
346
|
+
- [Firebase Android SDK](https://firebase.google.com/docs/auth/android/start)
|
|
105
347
|
|
|
106
|
-
|
|
107
|
-
to `{Your domain or localhost}/admin/settings/users-permissions/roles/2`. Make sure to enable public access to the
|
|
108
|
-
Firebase Authentication endpoint.
|
|
348
|
+
---
|
|
109
349
|
|
|
110
|
-
|
|
350
|
+
## Architecture
|
|
111
351
|
|
|
112
|
-
|
|
352
|
+
The plugin validates Firebase ID tokens and syncs users between Firebase and Strapi. Users authenticate via Firebase on the client, then exchange their Firebase token for a Strapi JWT to access your API.
|
|
353
|
+
|
|
354
|
+
**Security:**
|
|
355
|
+
|
|
356
|
+
- Firebase service account JSON encrypted with AES-256
|
|
357
|
+
- All tokens validated server-side via Firebase Admin SDK
|
|
358
|
+
- Passwords managed by Firebase (not Strapi)
|
|
359
|
+
- User responses automatically sanitized
|
|
360
|
+
|
|
361
|
+
## Troubleshooting
|
|
362
|
+
|
|
363
|
+
### 🔴 "Firebase is not initialized"
|
|
364
|
+
|
|
365
|
+
**Solution:**
|
|
366
|
+
|
|
367
|
+
1. Verify `FIREBASE_JSON_ENCRYPTION_KEY` in `config/plugins.js` (min 32 characters)
|
|
368
|
+
2. Upload Firebase service account JSON: **Settings → Firebase Authentication**
|
|
369
|
+
3. Restart Strapi: `yarn develop`
|
|
370
|
+
4. Check startup logs for initialization errors
|
|
371
|
+
|
|
372
|
+
---
|
|
113
373
|
|
|
114
|
-
###
|
|
374
|
+
### 🔴 "Token validation failed"
|
|
115
375
|
|
|
116
|
-
|
|
376
|
+
**Solution:**
|
|
117
377
|
|
|
118
|
-
|
|
378
|
+
1. Ensure token hasn't expired (1 hour TTL) - client should obtain fresh token
|
|
379
|
+
2. Verify client and server use the same Firebase project
|
|
380
|
+
3. Confirm service account JSON matches your Firebase project ID
|
|
381
|
+
4. Check Firebase Console for service status
|
|
119
382
|
|
|
120
|
-
|
|
383
|
+
---
|
|
121
384
|
|
|
122
|
-
|
|
123
|
-
- `lastName`
|
|
124
|
-
- `phoneNumber`
|
|
125
|
-
- `email`
|
|
385
|
+
### 🔴 Email Not Sending
|
|
126
386
|
|
|
127
|
-
|
|
387
|
+
**Solution:**
|
|
128
388
|
|
|
129
|
-
|
|
389
|
+
Install and configure Strapi Email Plugin:
|
|
130
390
|
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
391
|
+
```bash
|
|
392
|
+
yarn add @strapi/provider-email-sendgrid
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
```javascript
|
|
396
|
+
// config/plugins.js
|
|
397
|
+
email: {
|
|
398
|
+
config: {
|
|
399
|
+
provider: 'sendgrid',
|
|
400
|
+
providerOptions: { apiKey: env('SENDGRID_API_KEY') },
|
|
401
|
+
settings: {
|
|
402
|
+
defaultFrom: 'noreply@yourapp.com'
|
|
403
|
+
}
|
|
139
404
|
}
|
|
140
405
|
}
|
|
141
406
|
```
|
|
142
407
|
|
|
143
|
-
|
|
408
|
+
Alternative: Install [Firebase Email Extension](https://extensions.dev/extensions/firebase/firestore-send-email)
|
|
144
409
|
|
|
145
|
-
|
|
410
|
+
---
|
|
146
411
|
|
|
147
|
-
|
|
412
|
+
**Need more help?** Check [Firebase Console](https://console.firebase.google.com/) logs or [GitHub Issues](https://github.com/meta-cto/strapi-plugin-firebase-auth/issues)
|
|
148
413
|
|
|
149
|
-
|
|
414
|
+
## Best Practices
|
|
150
415
|
|
|
151
|
-
|
|
416
|
+
- Use Firebase SDK for authentication (not `emailLogin` for production)
|
|
417
|
+
- Store JWTs in httpOnly cookies (production) or secure storage (mobile)
|
|
418
|
+
- Configure Strapi Email Plugin (SendGrid, Mailgun, SES) for production
|
|
419
|
+
- Implement rate limiting on public endpoints
|
|
420
|
+
- Enforce HTTPS for password reset URLs
|
|
421
|
+
- Monitor Firebase quotas regularly
|
|
422
|
+
- Keep dependencies updated
|
|
152
423
|
|
|
153
|
-
|
|
154
|
-
links and their brief descriptions:
|
|
424
|
+
---
|
|
155
425
|
|
|
156
|
-
|
|
157
|
-
[Link](https://firebase.google.com/docs/android/setup)
|
|
426
|
+
## Support
|
|
158
427
|
|
|
159
|
-
|
|
160
|
-
through integrating Firebase into your Android project._
|
|
428
|
+
### Questions and Issues
|
|
161
429
|
|
|
162
|
-
|
|
163
|
-
[Link](https://firebase.google.com/docs/ios/setup)
|
|
430
|
+
If you encounter problems or have questions:
|
|
164
431
|
|
|
165
|
-
|
|
166
|
-
|
|
432
|
+
1. **Check Troubleshooting Section:** Review common errors above
|
|
433
|
+
2. **Firebase Documentation:** [firebase.google.com/docs/auth](https://firebase.google.com/docs/auth)
|
|
434
|
+
3. **Strapi Documentation:** [docs.strapi.io](https://docs.strapi.io)
|
|
435
|
+
4. **GitHub Issues:** [github.com/meta-cto/strapi-plugin-firebase-auth/issues](https://github.com/meta-cto/strapi-plugin-firebase-auth/issues)
|
|
436
|
+
- Search existing issues first
|
|
437
|
+
- Provide detailed information when creating new issues
|
|
167
438
|
|
|
168
|
-
|
|
169
|
-
[Link](https://firebase.google.com/docs/web/setup)
|
|
439
|
+
### Creating a Bug Report
|
|
170
440
|
|
|
171
|
-
|
|
172
|
-
guidance on setting up Firebase in a web project. It's an essential resource for web-based authentication using
|
|
173
|
-
Firebase._
|
|
441
|
+
When reporting issues, please include:
|
|
174
442
|
|
|
175
|
-
|
|
443
|
+
1. **Plugin version:** Check `package.json`
|
|
444
|
+
2. **Strapi version:** Run `yarn strapi version`
|
|
445
|
+
3. **Node version:** Run `node --version`
|
|
446
|
+
4. **Error message:** Full error text and stack trace
|
|
447
|
+
5. **Steps to reproduce:** Detailed steps to trigger the issue
|
|
448
|
+
6. **Configuration:** Relevant plugin configuration (redact sensitive data)
|
|
449
|
+
7. **Expected behavior:** What should happen
|
|
450
|
+
8. **Actual behavior:** What actually happens
|
|
176
451
|
|
|
177
|
-
|
|
452
|
+
### Feature Requests
|
|
178
453
|
|
|
179
|
-
|
|
180
|
-
documentation: [Android Firebase Authentication with Google](https://firebase.google.com/docs/auth/android/google-signin)
|
|
181
|
-
- After signing with Google,you need to get the GoogleAuthProvider Credential and pass it to firebaseSDK to be able to get the user token
|
|
182
|
-
- Sample Code:
|
|
454
|
+
To request new features:
|
|
183
455
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
.addOnCompleteListener(this) { task ->
|
|
189
|
-
if (task.isSuccessful) {
|
|
190
|
-
val token = it.result?.token
|
|
191
|
-
// Now, you can pass the token to the Firebase plugin by exchanging the Firebase Token using the `/firebase-auth` endpoint.
|
|
192
|
-
} else {
|
|
193
|
-
// If the sign-in fails, display a message to the user.
|
|
194
|
-
Log.w(TAG, "signInWithCredential:failure", task.exception)
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
```
|
|
456
|
+
1. Search existing feature requests
|
|
457
|
+
2. Create detailed proposal with use case
|
|
458
|
+
3. Explain why feature would be beneficial
|
|
459
|
+
4. Suggest implementation approach (if applicable)
|
|
198
460
|
|
|
199
|
-
|
|
461
|
+
### Community
|
|
200
462
|
|
|
201
|
-
-
|
|
202
|
-
|
|
203
|
-
-
|
|
463
|
+
- **GitHub Discussions:** Ask questions and share experiences
|
|
464
|
+
- **Discord:** Join Strapi community Discord server
|
|
465
|
+
- **Stack Overflow:** Tag questions with `strapi` and `firebase`
|
|
204
466
|
|
|
205
|
-
|
|
467
|
+
---
|
|
206
468
|
|
|
207
|
-
|
|
208
|
-
guard let clientID = FirebaseApp.app()?.options.clientID else { return }
|
|
469
|
+
## License
|
|
209
470
|
|
|
210
|
-
|
|
211
|
-
let config = GIDConfiguration(clientID: clientID)
|
|
212
|
-
GIDSignIn.sharedInstance.configuration = config
|
|
471
|
+
This plugin is licensed under the MIT License. See `LICENSE.md` for full details.
|
|
213
472
|
|
|
214
|
-
|
|
215
|
-
GIDSignIn.sharedInstance.signIn(withPresenting: self) { [unowned self] result, error in
|
|
216
|
-
guard error == nil else {
|
|
217
|
-
// ...
|
|
218
|
-
}
|
|
473
|
+
---
|
|
219
474
|
|
|
220
|
-
|
|
221
|
-
let idToken = user.idToken?.tokenString
|
|
222
|
-
else {
|
|
223
|
-
// ...
|
|
224
|
-
}
|
|
475
|
+
## Changelog
|
|
225
476
|
|
|
226
|
-
|
|
227
|
-
accessToken: user.accessToken.tokenString)
|
|
477
|
+
See `CHANGELOG.md` for version history and release notes.
|
|
228
478
|
|
|
229
|
-
|
|
479
|
+
---
|
|
230
480
|
|
|
231
|
-
|
|
481
|
+
## Credits
|
|
232
482
|
|
|
233
|
-
|
|
234
|
-
// Now you need to pass the token to firebasePlugin using exchange the firebase Token using `/firebase-auth` endpoint
|
|
235
|
-
}
|
|
483
|
+
Developed and maintained by **Meta CTO** team.
|
|
236
484
|
|
|
485
|
+
**Contributors:**
|
|
237
486
|
|
|
238
|
-
|
|
239
|
-
|
|
487
|
+
- Firebase Admin SDK: Google
|
|
488
|
+
- Strapi Framework: Strapi Solutions SAS
|
|
489
|
+
- AES Encryption: crypto-js library
|
|
240
490
|
|
|
241
|
-
|
|
491
|
+
---
|
|
242
492
|
|
|
243
|
-
|
|
244
|
-
documentation: [Web Firebase Authentication with Google](https://firebase.google.com/docs/auth/web/google-signin)
|
|
245
|
-
- After signing with Google,you need to get the GoogleAuthProvider Credential and pass it to firebaseSDK to be able to get the user token
|
|
246
|
-
- Sample Code:
|
|
493
|
+
## Additional Resources
|
|
247
494
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
.then((result) => {
|
|
254
|
-
// This gives you a Google Access Token. You can use it to access the Google API.
|
|
255
|
-
const credential = GoogleAuthProvider.credentialFromResult(result);
|
|
256
|
-
const token = credential.accessToken;
|
|
257
|
-
// The signed-in user info.
|
|
258
|
-
const user = result.user;
|
|
259
|
-
// IdP data available using getAdditionalUserInfo(result)
|
|
260
|
-
// ...
|
|
261
|
-
})
|
|
262
|
-
.catch((error) => {
|
|
263
|
-
// Handle Errors here.
|
|
264
|
-
const errorCode = error.code;
|
|
265
|
-
const errorMessage = error.message;
|
|
266
|
-
// The email of the user's account used.
|
|
267
|
-
const email = error.customData.email;
|
|
268
|
-
// The AuthCredential type that was used.
|
|
269
|
-
const credential = GoogleAuthProvider.credentialFromError(error);
|
|
270
|
-
// ...
|
|
271
|
-
});
|
|
272
|
-
```
|
|
495
|
+
**Firebase Documentation:**
|
|
496
|
+
|
|
497
|
+
- [Firebase Authentication](https://firebase.google.com/docs/auth)
|
|
498
|
+
- [Firebase Admin SDK](https://firebase.google.com/docs/admin/setup)
|
|
499
|
+
- Platform Guides: [Web](https://firebase.google.com/docs/web/setup) | [iOS](https://firebase.google.com/docs/ios/setup) | [Android](https://firebase.google.com/docs/android/setup)
|
|
273
500
|
|
|
274
|
-
|
|
275
|
-
pass to the Firebase plugin for user authentication using `/firebase-auth` endpoint
|
|
501
|
+
**Strapi Documentation:**
|
|
276
502
|
|
|
277
|
-
|
|
503
|
+
- [Strapi v5](https://docs.strapi.io/dev-docs/intro)
|
|
504
|
+
- [Email Providers](https://market.strapi.io/providers) (SendGrid, Mailgun, Amazon SES)
|
|
278
505
|
|
|
279
|
-
|
|
506
|
+
**Firebase Extensions:**
|
|
280
507
|
|
|
281
|
-
- [
|
|
508
|
+
- [Trigger Email Extension](https://extensions.dev/extensions/firebase/firestore-send-email)
|
|
282
509
|
|
|
283
|
-
|
|
510
|
+
---
|
|
284
511
|
|
|
285
|
-
|
|
286
|
-
To ensure a smooth user login experience with Apple authentication, it’s essential to include the appleEmail field in the user object within the Strapi dashboard.
|
|
512
|
+
**Thank you for using Strapi Plugin Firebase Authentication!** 🎉
|
|
287
513
|
|
|
288
|
-
|
|
289
|
-
- iOS: [Link](https://firebase.google.com/docs/auth/ios/apple)
|
|
290
|
-
- Web: [Link](https://firebase.google.com/docs/auth/web/apple)
|
|
514
|
+
If you find this plugin helpful, please consider:
|
|
291
515
|
|
|
292
|
-
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
516
|
+
- Starring the GitHub repository
|
|
517
|
+
- Sharing with your community
|
|
518
|
+
- Contributing improvements
|
|
519
|
+
- Reporting issues to help us improve
|
|
296
520
|
|
|
297
|
-
|
|
521
|
+
Happy coding! 🚀
|