[FR] Use firebase emulator for TenantManagementService

Open
#910 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Locate _TenantManagementService and its TENANT_MGT_URL, then trace how FIREBASE_AUTH_EMULATOR_HOST is handled for comparison. Check the existing tenant-management behavior against the Firebase emulator and verify that the proposed FIREBASE_TENANT_EMULATOR_HOST setting supports the emulated tenant endpoints without changing production behavior.

Written by the indexing model from the issue text.

Description

type: feature request

Is your feature request related to a problem? Please describe.
Currently only the Auth client supports running against the firebase emulator when setting the FIREBASE_AUTH_EMULATOR_HOST environment variable. However when wanting to list for example tenants with TenantManagementService you cannot do that and it forcibly uses TENANT_MGT_URL = 'https://identitytoolkit.googleapis.com/v2'. The emulator itself however emulates some of these endpoints (like /projects/{project_id}/tenants) so some of those are supported.

Describe the solution you'd like
Add support for setting FIREBASE_TENANT_EMULATOR_HOST and use that in _TenantManagementService

Describe alternatives you've considered
Doing direct HTTP REST API calls to the emulator or extending the management service manually like

class EmulatedTenantManagementService(tenant_mgt._TenantManagementService):
    TENANT_MGT_URL = (
        f"http://{firebase_auth_emulator_host}/identitytoolkit.googleapis.com/v2"
    )

    def __init__(self, app: firebase_admin.App):
        super().__init__(app)
        credential = _utils.EmulatorAdminCredentials()
        version_header = f"Python/Admin/{firebase_admin.__version__}"
        base_url = f"{self.TENANT_MGT_URL}/projects/{app.project_id}"
        self.client = _http_client.JsonHttpClient(
            credential=credential,
            base_url=base_url,
            headers={"X-Client-Version": version_header},
        )

app = firebase_admin.get_app()
service = EmulatedTenantManagementService(app)
app._services[tenant_mgt._TENANT_MGT_ATTRIBUTE] = service
Dominant language
Python
Stars
1.2k
Forks
359
Avg merge
5d 6m
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from firebase/firebase-admin-python

All issues in firebase/firebase-admin-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.