3434_event_type_updated = "google.firebase.database.ref.v1.updated"
3535_event_type_deleted = "google.firebase.database.ref.v1.deleted"
3636
37+ AuthType = _typing .Literal ["app_user" , "admin" , "unauthenticated" , "unknown" ]
38+
3739
3840@_dataclass .dataclass (frozen = True )
3941class Event (_core .CloudEvent [T ]):
@@ -67,6 +69,16 @@ class Event(_core.CloudEvent[T]):
6769 Only named capture groups are populated - {key}, {key=*}, {key=**}
6870 """
6971
72+ auth_type : AuthType
73+ """
74+ The type of principal that triggered the event.
75+ """
76+
77+ auth_id : str
78+ """
79+ The unique identifier for the principal.
80+ """
81+
7082
7183_E1 = Event [Change [_typing .Any | None ]]
7284_E2 = Event [_typing .Any | None ]
@@ -104,6 +116,10 @@ def _db_endpoint_handler(
104116 ** ref_pattern .extract_matches (event_ref ),
105117 ** instance_pattern .extract_matches (event_instance ),
106118 }
119+
120+ event_auth_type = event_attributes ["authtype" ]
121+ event_auth_id = event_attributes ["authid" ]
122+
107123 database_event = Event (
108124 firebase_database_host = event_attributes ["firebasedatabasehost" ],
109125 instance = event_instance ,
@@ -120,6 +136,8 @@ def _db_endpoint_handler(
120136 data = database_event_data ,
121137 subject = event_attributes ["subject" ],
122138 params = params ,
139+ auth_type = event_auth_type ,
140+ auth_id = event_auth_id ,
123141 )
124142 _core ._with_init (func )(database_event )
125143
0 commit comments