[FR] Use firebase emulator for TenantManagementService

Đang mở
#910 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
38/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
authentication

Hướng nghiên cứu

Xác định _TenantManagementServiceTENANT_MGT_URL của nó, sau đó lần theo cách FIREBASE_AUTH_EMULATOR_HOST được xử lý để so sánh. Kiểm tra hành vi quản lý tenant hiện có với trình mô phỏng Firebase và xác minh rằng thiết lập FIREBASE_TENANT_EMULATOR_HOST được đề xuất hỗ trợ các endpoint tenant được mô phỏng mà không thay đổi hành vi trong môi trường production.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
Python
Star
1.2k
Fork
359
Merge trung bình
5 ngày 6 phút
Pull request đã merge (30 ngày)
2

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của firebase/firebase-admin-python

Tất cả issue của firebase/firebase-admin-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.