Skip to content

addAuthDomains does not add multiple domains #6356

Closed

Description

@yellowhat

[REQUIRED] Environment info

firebase-tools: 12.5.3

Platform: Ubuntu

[REQUIRED] Test case

Hi,
we have multiple sites defined in our .firebaserc, ie:

{
  "projects": {
    "default": "proj"
  },
  "targets": {
    "proj": {
      "hosting": {
        "site1": [
          "site1"
        ],
        "site2": [
          "site2"
        ]
      }
    }
  }
}

[REQUIRED] Steps to reproduce

If I deploy to a channel:

$ npx [email protected] hosting:channel:deploy zzz --expires 7d --project proj --debug
...
[2023-09-12T15:58:19.040Z] <<< [apiv2][body] PATCH https://identitytoolkit.googleapis.com/admin/v2/projects/proj/config
{
    "name": "projects/123/config",
    "signIn": {
        "email": {
            "enabled": true
        },
        "hashConfig": {
            "algorithm": "SCRYPT",
            "signerKey": "key",
            "saltSeparator": "Bw==",
            "rounds": 8,
            "memoryCost": 14
        }
    },
    "notification": {
        "sendEmail": {
            "method": "DEFAULT",
            "callbackUri": "https://proj.firebaseapp.com/__/auth/action",
            "dnsInfo": {
                "customDomainState": "NOT_STARTED",
                "domainVerificationRequestTime": "1970-01-01T00:00:00Z"
            }
        },
        "sendSms": {
            "smsTemplate": {
                "content": "%LOGIN_CODE% is your verification code for %APP_NAME%."
            }
        },
        "defaultLocale": "en"
    },
    "quota": {},
    "monitoring": {
        "requestLogging": {}
    },
    "multiTenant": {},
    "authorizedDomains": [
        "localhost",
        ...
        "site1-random--zzz-p74ozsma.web.app",
        "site2-random--zzz-yehbjsw1.web.app"
    ],
    "subtype": "FIREBASE_AUTH",
    "client": {
        "apiKey": "key",
        "permissions": {},
        "firebaseSubdomain": "proj"
    },
    "mfa": {
        "state": "DISABLED"
    },
    "blockingFunctions": {},
    "smsRegionConfig": {}
}
[2023-09-12T15:48:54.800Z] [hosting] added auth domain for urls ["https://site1-random--zzz-yehbjsw1.web.app","https://site2-random--zzz-yehbjsw1.web.app"]

the logs says that 2 domains have been added but the firebase console, "Authorized domains", shows only the first site.

Instead if I deploy each site separately:

$ npx [email protected] hosting:channel:deploy zzz --only site1 --expires 7d --project proj --debug
...
$ npx [email protected] hosting:channel:deploy zzz --only site2 --expires 7d --project proj --debug
...

now both sites shows in the firebase console.

Now if I rerun:

$ npx [email protected] hosting:channel:deploy zzz --expires 7d --project proj --debug

the second site disappear from the "Authorized domains" list.

[REQUIRED] Expected behavior

Both sites are in the "Authorized domains" list

[REQUIRED] Actual behavior

Only 1 site is in "Authorize domains" list

Activity

  1. google-oss-bot commented on Sep 12, 2023

    @google-oss-bot
    Collaborator

    This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.

  2. yellowhat commented on Sep 25, 2023

    @yellowhat
    Author

    @bkendall do you require any other information?

  3. bkendall commented on Oct 17, 2023

    @bkendall
    Contributor

    I'm not able to replicate this (either on 12.5.3 or 12.7.0). I've attempted several times, but both sites get added to authorized domains every time.

    It almost sounds like you're seeing a caching issue in the console? If you hard-refresh the console page, does the domain show up after that?

    It does look like the API call is right, especially if you're seeing the domains get added there; that's why I think it might just be something in the console (and you didn't mention that you ran into this issue from auth not working, another point in favor of maybe just a visualization issue)

    (And sorry for the delay - I've got a bit on my plate on the moment, so I appreciate your patience)

  4. added
    Needs: Author Feedback
    on Oct 17, 2023
  5. yellowhat commented on Oct 18, 2023

    @yellowhat
    Author

    Thanks for your reply.

    I have just tried again:

    $ npx [email protected] hosting:channel:deploy test-test --expires 7d --project <proj> --json
    {
      "status": "success",
      "result": {
        "site0": {
          "target": "site0
          "site": "site0",
          "url": "https://site0--test-test.web.app",
          "version": "",
          "expireTime": "2023-10-25T06:38:39.946877328Z"
        },
        "site1": {
          "target": "site1",
          "site": "site1",
          "url": "https://site1--test-test.web.app",
          "version": "",
          "expireTime": "2023-10-25T06:38:39.949428751Z"
        }
      }
    }

    If I go to firebase console > Authentication > Settings > Authorized domains, still only site0--test-test shows, not site1--test-test.

    Infact if I go to the second site url (https://site1--test-test.web.app) and try to login using google, in the browser console I get:

    iframe.js:301 Info: The current domain is not authorized for OAuth operations. This will prevent signInWithPopup, signInWithRedirect, linkWithPopup and linkWithRedirect from working. Add your domain (site1-test-test-.web.app) to the OAuth redirect domains list in the Firebase console -> Authentication -> Settings -> Authorized domains tab.
    

    Is there other information I can provide to help you replicate it?

  6. added and removed
    Needs: Author Feedback
    on Oct 18, 2023
  7. bkendall commented on Oct 25, 2023

    @bkendall
    Contributor

    Since I can't replicate it, I think I'd need the full --debug logs to really see what's going on. It looks like some update isn't sticking, but I don't know if it's the CLI logic that's failing, or the API that's not accepting it.

    The best way to get us logs is probably be to file a ticket with Firebase support for Hosting and you can reference this ticket and let them know I asked for more information, and they should forward it onto our team.

  8. added
    Needs: Author Feedback
    and removed on Oct 25, 2023
  9. yellowhat commented on Oct 25, 2023

    @yellowhat
    Author

    Thanks for the reply.
    Just raised the ticket.

  10. added and removed
    Needs: Author Feedback
    on Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions