Skip to content

Add App Check debug token management - #1167

Open
kmeretskyi wants to merge 1 commit into
beste:8.xfrom
kmeretskyi:feature/app-check-debug-tokens
Open

kmeretskyi wants to merge 1 commit into
beste:8.xfrom
kmeretskyi:feature/app-check-debug-tokens

Conversation

@kmeretskyi

Copy link
Copy Markdown

Adds support for managing App Check debug tokens via the App Check REST API v1:

  • createDebugToken() – registers a debug token; generates a random UUID4 secret if none is given. The secret is only available on the returned object, as the API never returns it again.
  • getDebugToken(), listDebugTokens() (follows pagination), updateDebugToken() (display name), deleteDebugToken()

The methods are exposed through a new transitional Kreait\Firebase\Contract\AppCheckWithDebugTokens contract (same approach as AppCheckWithReplayProtection) to keep the AppCheck contract backwards compatible. A note for the next major is added to NEXT_MAJOR_TODO.md.

Not included: exchangeDebugToken

I left out projects.apps.exchangeDebugToken on purpose. When tested against a real project, the endpoint returns 401 Request is missing required authentication credential for service account OAuth credentials, while the same credentials work for all debugTokens methods. It only accepts the app's API key, so it is meant to be called by client apps (the debug provider), not by an Admin SDK.

Testing

  • Unit tests for all methods (request method, URL, body, pagination, updateMask, UUID4 generation, error conversion)
  • Integration test AppCheckTest::testDebugTokenLifecycle (create → get → list → update → delete), run successfully against a real Firebase project
  • PHPStan, PHP-CS-Fixer, Rector and the BC check pass

Side note: the integration test bootstrap fails with UnexpectedValueException: Syntax error when TEST_REGISTRATION_TOKENS is empty (it is JSON-decoded unconditionally); setting it to [] works around it.

Adds creating, getting, listing, updating and deleting App Check
debug tokens via the App Check REST API v1. Exposed through the
transitional AppCheckWithDebugTokens contract to keep the AppCheck
contract backwards compatible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant