Skip to content
Merged
Prev Previous commit
Next Next commit
fix: crash with InvalidAuthBlockingTokenError (wrong audience)
  • Loading branch information
exaby73 committed Oct 10, 2023
commit ccc4d7e3b32b19383acf7862e4179e78856a42a0
8 changes: 4 additions & 4 deletions src/firebase_functions/private/_identity_fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ def _auth_user_info_from_token_data(token_data: dict[str, _typing.Any]):

def _auth_user_metadata_from_token_data(token_data: dict[str, _typing.Any]):
from firebase_functions.identity_fn import AuthUserMetadata
creation_time = int(token_data["creation_time"]) / 1000.0
last_sign_in_time = int(token_data["last_sign_in_time"]) / 1000.0
return AuthUserMetadata(
creation_time=_dt.datetime.utcfromtimestamp(
token_data["creation_time"] / 1000.0),
last_sign_in_time=_dt.datetime.utcfromtimestamp(
token_data["last_sign_in_time"] / 1000.0),
creation_time=_dt.datetime.utcfromtimestamp(creation_time),
last_sign_in_time=_dt.datetime.utcfromtimestamp(last_sign_in_time),
)


Expand Down
4 changes: 2 additions & 2 deletions src/firebase_functions/private/token_verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ def verify(self, token, request):
'Firebase {0} has incorrect algorithm. Expected "RS256" but got '
'"{1}". {2}'.format(self.short_name, header.get('alg'),
verify_id_token_msg))
elif self.expected_audience and self.expected_audience not in audience:
elif not emulated and self.expected_audience and self.expected_audience not in audience:
error_message = (
'Firebase {0} has incorrect "aud" (audience) claim. Expected "{1}" but '
'got "{2}". {3} {4}'.format(self.short_name,
self.expected_audience, audience,
project_id_match_msg,
verify_id_token_msg))
elif not self.expected_audience and audience != self.project_id:
elif not emulated and not self.expected_audience and audience != self.project_id:
error_message = (
'Firebase {0} has incorrect "aud" (audience) claim. Expected "{1}" but '
'got "{2}". {3} {4}'.format(self.short_name, self.project_id,
Expand Down