Repository navigation
feat(identity): support IS_NOT_TENANT filtering for v2 Auth events - #319
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces support for filtering Auth event triggers to only trigger on users in the default project (no tenant) by setting tenant_id to IS_NOT_TENANT. Since Eventarc does not support empty-string filters, tenant-scoped events are filtered out at runtime. Additionally, it adds support for parsing RFC-2822 timestamps emitted by the Firebase Auth Emulator. Feedback on the changes suggests ensuring that all parsed or provided datetime objects in _parse_auth_timestamp are normalized to timezone-aware UTC datetimes to prevent returning naive datetimes or datetimes with non-UTC offsets.
shettyvarun268
force-pushed
the
shettyvarun268/auth-v2-is-not-tenant
branch
2 times, most recently
from
October 13, 2026 20:42
552a64a to
caefc5b
Compare
shettyvarun268
force-pushed
the
shettyvarun268/auth-v2-is-not-tenant
branch
5 times, most recently
from
October 13, 2026 23:05
425136d to
87cb6b6
Compare
shettyvarun268
marked this pull request as ready for review
October 13, 2026 23:13
shettyvarun268
force-pushed
the
shettyvarun268/auth-v2-is-not-tenant
branch
from
October 15, 2026 15:43
87cb6b6 to
44bbe64
Compare
shettyvarun268
force-pushed
the
shettyvarun268/auth-v2-is-not-tenant
branch
4 times, most recently
from
October 19, 2026 16:40
7aa3ce4 to
2a1224c
Compare
shettyvarun268
force-pushed
the
shettyvarun268/auth-v2-is-not-tenant
branch
from
October 19, 2026 17:06
2a1224c to
cfec286
Compare
ajperel
reviewed
Oct 20, 2026
shettyvarun268
force-pushed
the
shettyvarun268/auth-v2-is-not-tenant
branch
from
October 21, 2026 18:43
cfec286 to
54ae4f4
Compare
ajperel
approved these changes
Oct 22, 2026
shettyvarun268
force-pushed
the
shettyvarun268/auth-v2-is-not-tenant
branch
from
October 22, 2026 18:20
54ae4f4 to
39ef3ab
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
IS_NOT_TENANTsupport toAuthOptions.tenant_idso developers can scopeon_user_createdandon_user_deletedtriggers exclusively to default-project (non-tenant) users, matching the Node.js SDK (firebase-functions/v2/identity).Usage
Architectural & Implementation Details
Why
IS_NOT_TENANTUses Hybrid Deploy-Time + Runtime Filtering (options.py,identity_fn.py,private/_identity_fn.py)In Identity Platform multi-tenancy, there are three ways a developer may configure
tenant_idon an Auth trigger:tenant_id=None(default): Trigger for all users across the project and all tenants (eventFilters: {}).tenant_id="tenant-a": Trigger only for users in"tenant-a"(eventFilters: {"tenantid": "tenant-a"}).tenant_id=IS_NOT_TENANT: Trigger only for default-project users who do not belong to any tenant.Platform Constraint: Google Cloud Eventarc does not support negative filters or empty-string filters (
eventFilters: {"tenantid": ""}is rejected by the Eventarc API). To supportIS_NOT_TENANT(matching the Node SDK's implementation):SentinelType: Defined a publicSentinel(_util.Sentinel)subclass andIS_NOT_TENANT = Sentinel(...)infirebase_functions.options(and re-exportedIS_NOT_TENANTinfirebase_functions.identity_fn) so private module paths do not leak into public Sphinx docs or IDE autocomplete.AuthOptions._endpoint): Whenself.tenant_idisIS_NOT_TENANT, we omit"tenantid"fromevent_filtersinfunctions.yamlso Eventarc delivers all Auth events to the function (while rejecting any otherSentinelsuch asRESET_VALUEwith aValueError).user_event_handler): Whenoptions.tenant_id == _options.IS_NOT_TENANTand the CloudEvent's top-leveltenantidattribute is present (raw._get_attributes().get("tenantid") is not None), the handler returns immediately before parsing the CloudEvent payload or running@core.init.Verification
on_user_created(tenant_id=IS_NOT_TENANT)on_user_created(tenant_id="tenant-a")on_user_created()(tenant_id=None)tenant_id=None)tenant_id="tenant-a")tenant_id="tenant-b")pytest(all 147 tests passing, includingtest_on_user_created_is_not_tenant)mypy,ruff check,ruff format --check, and./docs/generate.shfirebase emulators:exec).on_user_created/on_user_deletedIS_NOT_TENANT, specifictenant_id, andtenant_id=None).PR Stack: