Skip to content

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

Open
yvonnep165 wants to merge 18 commits into
devfrom
yp-verify-one-time-token
Open

feat(appcheck): Verify one-time tokens for replay protection#774
yvonnep165 wants to merge 18 commits into
devfrom
yp-verify-one-time-token

Conversation

@yvonnep165

@yvonnep165 yvonnep165 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

This PR introduces the VerifyOneTimeToken method to the appcheck package, enabling stateful replay protection for Firebase App Check.

  • Implement a new method VerifyOneTimeToken that first performs local, stateless JWT verification followed by a stateful POST request to backend endpoint to consume the token.
  • Add the AlreadyConsumed (*bool) field to the DecodedAppCheckToken struct.
  • Plumb option.ClientOption from the main app initialization down to internal.AppCheckConfig.
  • Add unit tests.

@yvonnep165 yvonnep165 changed the title feat(appcheck): verify one-time tokens for replay protection feat(appcheck): Verify one-time tokens for replay protection Aug 10, 2026

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces the VerifyOneTimeToken method to the App Check client, enabling stateful verification and consumption of one-time tokens. It also adds the AlreadyConsumed field to DecodedAppCheckToken and integrates HTTP client options. Feedback on the tests suggests using a helper function to instantiate *bool pointers to reduce verbosity, and restoring the mutated global verifyURLFormat variable to prevent potential race conditions and side effects.

Comment thread appcheck/appcheck_test.go
Comment thread appcheck/appcheck_test.go Outdated
@yvonnep165 yvonnep165 self-assigned this Aug 10, 2026
@yvonnep165 yvonnep165 added release-note release:stage Stage a release candidate labels Aug 10, 2026

@weixifan weixifan 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.

Thank you for the PR; LGTM with just a minor comment.

Comment thread appcheck/appcheck.go Outdated
const appCheckIssuer = "https://firebaseappcheck.googleapis.com/"

var (
verifyURLFormat = "https://firebaseappcheck.googleapis.com/v1beta/projects/%s:verifyAppCheckToken"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Our v1 endpoint is almost ready, and that would be our preferred URL when this SDK is released. Maybe we can just change this to v1 now?

I'm also fine with leaving this alone for now and wait until our v1 endpoint is fully published. In that case, is a TODO appropriate here?

@yvonnep165 yvonnep165 Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the quick review! Sure, we can switch to the v1 endpoint as long as we can verify and run our tests against it. Currently, we only have unit tests in place so we can just change to v1 now, but we plan to add integration tests against the live endpoint once we implement the token creation methods.

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.

One thing we should keep in mind if we do merge this as v1, is that our next release will include this whether or not the backend is ready. Lets set v1 but hold back merging until the backend is live.

@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 note on v1 endpoint. Thanks!

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.

5 participants