Skip to content

feat(appcheck): Verify one-time tokens for replay protection - #976

Open
yvonnep165 wants to merge 6 commits into
mainfrom
yp-verify-one-time-token
Open

feat(appcheck): Verify one-time tokens for replay protection#976
yvonnep165 wants to merge 6 commits into
mainfrom
yp-verify-one-time-token

Conversation

@yvonnep165

Copy link
Copy Markdown
Contributor

This PR adds support for App Check one-time token verification for replay protection by adding an optional consume parameter to app_check.verify_token(). The returned claims dictionary will contain an already_consumed boolean key indicating whether the token was previously consumed.

@yvonnep165 yvonnep165 self-assigned this Aug 17, 2026
@yvonnep165 yvonnep165 added release-note release:stage Stage a release candidate labels Aug 17, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for stateful token verification in Firebase App Check by introducing a consume parameter to the verify_token function. When enabled, the service calls the App Check backend to mark the token as consumed, providing replay protection, and returns an already_consumed flag. Corresponding unit tests have also been added. The review feedback suggests improving error handling by using _utils.handle_platform_error_from_requests instead of _utils.handle_requests_error to propagate detailed GCP error messages to developers.

Comment thread firebase_admin/app_check.py Outdated

@jonathanedey jonathanedey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one comment, Thanks!


verified_claims['app_id'] = verified_claims.get('sub')

if consume:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's validate consume is a bool here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:stage Stage a release candidate release-note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants