Skip to content

Caution - firebase 8.6.2 has issue with authentication - avoid in angularfire? #2857

Closed
@Tommertom

Description

@Tommertom

Hi

maybe not an coding issue for angularfire, but I recently ng added angular fire on an angular 12 app and the authentication flow succeeded, but I could not query collection any more due to an issue (to be confirmed) on firebase 8.6.2.

Maybe better to avoid 8.6.2 on angulfire until resolved?

firebase/firebase-js-sdk#4996

Edit: below the issue as reported on firebase js sdk - where it is mentioned that it might be an angularfire issue.

Reported workaround seems indeed downgrading the firebase dependency to max 8.6.1. I went for 8.3.0.

@google-oss-bot - > this better? :)

Hi,

I like to open a ticket related to the error message reported in firebase/firebase-js-sdk#1491

Error in console.log:

FirebaseError: Missing or insufficient permissions.
    at new e (prebuilt-109c6673-0f51e182.js:188)
    at prebuilt-109c6673-0f51e182.js:10416
    at prebuilt-109c6673-0f51e182.js:10417
    at e.onMessage (prebuilt-109c6673-0f51e182.js:10439)
    at prebuilt-109c6673-0f51e182.js:10356
    at prebuilt-109c6673-0f51e182.js:10387
    at prebuilt-109c6673-0f51e182.js:15194
    at ZoneDelegate.invoke (zone.js:400)
    at Zone.run (zone.js:160)
    at zone.js:1318

Running
NodeJS : v14.16.0 (C:\Program Files\nodejs\node.exe)
npm : 7.6.3
OS : Windows 10

Chrome Version 91.0.4472.77 (Official Build) (64-bit)
Firebase Auth, Firestore

Versions in cli:

      "firebase": "^8.6.5",
     "@angular/fire": "^6.1.5",

Getting above mentioned error trying to access data in firestore - using a simple starter app to access data in firestore

Firestore rules:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
        allow read, write: if request.auth!=null;
    }
  }
}

High level flow - user authentication using Facebook login (via Firebase) and then a simple query on a collection in the store.

If I change the rules to say:
allow read,write: if true; or
allow read,write: if request.auth==null;
all works fine. If I transplant the angular code of this small project into a copy of a production app, the code works fine (full swap contents of src folder): after login, the query delivers the requested data.

With these two experiments I assume to have demonstrated an issue with the dependencies related to angular, angularfire and or the firebase sdk - most likely firebase given the things mentioned in firebase/firebase-js-sdk#1491 and the fact that angualar/angularfire only wraps the firebase js sdk. But I could be wrong of course.

package.json for the project which gives errors:

{
    "name": "k2",
    "version": "0.0.1",
    "author": "Ionic Framework",
    "homepage": "https://ionicframework.com/",
    "scripts": {
        "dev": "ionic serve -w chrome --ssl",
        "deploy": "ionic build --prod &&  firebase deploy --only hosting",
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e"
    },
    "private": true,
    "dependencies": {
        "@angular/common": "~12.0.1",
        "@angular/core": "~12.0.1",
        "@angular/fire": "^6.1.5",
        "@angular/forms": "~12.0.1",
        "@angular/platform-browser": "~12.0.1",
        "@angular/platform-browser-dynamic": "~12.0.1",
        "@angular/router": "~12.0.1",
        "@capacitor/cli": "^3.0.0",
        "@capacitor/core": "^3.0.0",
        "@ionic/angular": "^5.5.2",
        "@ngneat/until-destroy": "^8.0.4",
        "firebase": "^8.6.5",
        "rxjs": "~6.6.0",
        "tslib": "^2.0.0",
        "zone.js": "~0.11.4"
    },
    "devDependencies": {
        "@angular-devkit/architect": ">= 0.900 < 0.1300",
        "@angular-devkit/build-angular": "~12.0.1",
        "@angular-eslint/builder": "~12.0.0",
        "@angular-eslint/eslint-plugin": "~12.0.0",
        "@angular-eslint/eslint-plugin-template": "~12.0.0",
        "@angular-eslint/template-parser": "~12.0.0",
        "@angular/cli": "~12.0.1",
        "@angular/compiler": "~12.0.1",
        "@angular/compiler-cli": "~12.0.1",
        "@angular/language-service": "~12.0.1",
        "@ionic/angular-toolkit": "^4.0.0",
        "@types/jasmine": "~3.6.0",
        "@types/jasminewd2": "~2.0.3",
        "@types/node": "^12.11.1",
        "@typescript-eslint/eslint-plugin": "4.16.1",
        "@typescript-eslint/parser": "4.16.1",
        "eslint": "^7.6.0",
        "eslint-plugin-import": "2.22.1",
        "eslint-plugin-jsdoc": "30.7.6",
        "eslint-plugin-prefer-arrow": "1.2.2",
        "firebase-tools": "^8.0.0 || ^9.0.0",
        "fuzzy": "^0.1.3",
        "inquirer": "^6.2.2",
        "inquirer-autocomplete-prompt": "^1.0.1",
        "jasmine-core": "~3.7.1",
        "jasmine-spec-reporter": "~5.0.0",
        "jsonc-parser": "^3.0.0",
        "karma": "~6.3.2",
        "karma-chrome-launcher": "~3.1.0",
        "karma-coverage": "~2.0.3",
        "karma-coverage-istanbul-reporter": "~3.0.2",
        "karma-jasmine": "~4.0.0",
        "karma-jasmine-html-reporter": "^1.5.0",
        "open": "^7.0.3",
        "protractor": "~7.0.0",
        "ts-node": "~8.3.0",
        "typescript": "~4.2.4"
    },
    "description": "An Ionic project"
}

package.json from the production app (which works, also with the simple code):

{
    "name": "xx",
    "version": "0.0.1",
    "author": "Ionic Framework",
    "homepage": "https://ionicframework.com/",
    "scripts": {
        "ng": "ng",
        "dev": "ionic serve -w chrome --ssl",
        "deploy": "ionic build --prod &&  firebase deploy --only hosting",
       "start": "ng serve",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e"
    },
    "private": true,
    "dependencies": {
        "@angular/animations": "^11.2.6",
        "@angular/common": "~11.2.6",
        "@angular/core": "~11.2.6",
        "@angular/fire": "^6.1.4",
        "@angular/forms": "~11.2.6",
        "@angular/google-maps": "^11.2.4",
        "@angular/platform-browser": "~11.2.6",
        "@angular/platform-browser-dynamic": "~11.2.6",
        "@angular/router": "~11.2.6",
        "@angular/service-worker": "~11.2.0",
        "@capacitor/core": "2.4.7",
        "@ionic/angular": "^5.5.2",
        "@ionic/storage": "^3.0.2",
        "@ionic/storage-angular": "^3.0.2",
        "@ngneat/until-destroy": "^8.0.4",
        "firebase": "^7.0 || ^8.0",
        "idb": "^3.0.2",
        "rxjs": "~6.6.0",
        "tslib": "^2.0.0",
        "zone.js": "~0.10.2"
    },
    "devDependencies": {
        "@angular-devkit/architect": ">= 0.900 < 0.1200",
        "@angular-devkit/build-angular": "~0.1102.4",
        "@angular/cli": "~11.2.4",
        "@angular/compiler": "~11.2.6",
        "@angular/compiler-cli": "~11.2.6",
        "@angular/language-service": "~11.2.6",
        "@capacitor/cli": "2.4.7",
        "@ionic/angular-toolkit": "^3.1.1",
        "@types/jasmine": "~3.6.0",
        "@types/jasminewd2": "~2.0.3",
        "@types/node": "^12.11.1",
        "codelyzer": "^6.0.0",
        "firebase-tools": "^8.0.0",
        "fuzzy": "^0.1.3",
        "inquirer": "^6.2.2",
        "inquirer-autocomplete-prompt": "^1.0.1",
        "jasmine-core": "~3.6.0",
        "jasmine-spec-reporter": "~5.0.0",
        "karma": "~5.2.0",
        "karma-chrome-launcher": "~3.1.0",
        "karma-coverage": "~2.0.3",
        "karma-coverage-istanbul-reporter": "~3.0.2",
        "karma-jasmine": "~4.0.0",
        "karma-jasmine-html-reporter": "^1.5.0",
        "open": "^7.0.3",
        "protractor": "~7.0.0",
        "ts-node": "~8.3.0",
        "tslint": "~6.1.0",
        "typescript": "~4.0.2"
    },
    "description": "A project"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions