Limited Use Tokens in Functions by AustinBenoit · Pull Request #1840 · firebase/firebase-cpp-sdk
Summary of Changes
Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request enhances Firebase Functions by integrating support for limited-use App Check tokens. This feature provides an additional layer of security, specifically for replay protection, by allowing requests to callable functions to be made with tokens that are valid for a single use. The changes involve updating the API to accept new options, modifying internal token handling mechanisms, and ensuring compatibility across all supported platforms.
Highlights
- Limited Use App Check Tokens: Introduced the
HttpsCallableOptionsstruct, allowing developers to specify whether a callable function request should utilize a limited-use App Check token for enhanced security, particularly against replay attacks. - API Extension: Extended the public
FunctionsAPI with overloadedGetHttpsCallableandGetHttpsCallableFromURLmethods that accept the newHttpsCallableOptions. - Cross-Platform Implementation: Implemented the logic for fetching and applying limited-use App Check tokens across desktop, Android, and iOS platforms, ensuring consistent behavior.
- Integration Testing: Added new integration tests to thoroughly verify the functionality of calling Firebase Functions with limited-use App Check tokens.
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.
Changelog
- app/src/function_registry.h
- Added
FnAppCheckGetLimitedUseTokenAsyncto theFunctionIdenum.
- Added
- app_check/src/common/common.h
- Added
kAppCheckFnGetLimitedUseAppCheckStringInternalto theAppCheckFnenum.
- Added
- app_check/src/desktop/app_check_desktop.cc
- Implemented
GetLimitedUseAppCheckTokenStringInternalto fetch limited-use App Check tokens. - Registered and unregistered
FnAppCheckGetLimitedUseTokenAsyncwith the function registry.
- Implemented
- app_check/src/desktop/app_check_desktop.h
- Declared
GetLimitedUseAppCheckTokenStringInternaland its static registry function.
- Declared
- functions/integration_test/src/integration_test.cc
- Added two new integration tests to verify calling functions with limited-use App Check tokens.
- functions/src/android/functions_android.cc
- Defined new JNI method lookups for
GetHttpsCallableandGetHttpsCallableFromURLthat acceptHttpsCallableOptions. - Added JNI method lookups for
HttpsCallableOptions$Buildermethods.
- Defined new JNI method lookups for
- functions/src/android/functions_android.h
- Declared overloaded
GetHttpsCallableandGetHttpsCallableFromURLmethods that acceptHttpsCallableOptions.
- Declared overloaded
- functions/src/common/functions.cc
- Implemented new
GetHttpsCallableandGetHttpsCallableFromURLoverloads to passHttpsCallableOptionsto the internal implementation.
- Implemented new
- functions/src/desktop/callable_reference_desktop.cc
- Modified constructors and assignment operators to store
HttpsCallableOptions. - Updated the
Callmethod to conditionally use limited-use App Check tokens based on the provided options.
- Modified constructors and assignment operators to store
- functions/src/desktop/callable_reference_desktop.h
- Updated the constructor to accept
HttpsCallableOptions. - Added a
options_member to storeHttpsCallableOptions.
- Updated the constructor to accept
- functions/src/desktop/functions_desktop.cc
- Implemented new
GetHttpsCallableandGetHttpsCallableFromURLoverloads to createHttpsCallableReferenceInternalinstances withHttpsCallableOptions.
- Implemented new
- functions/src/desktop/functions_desktop.h
- Declared new
GetHttpsCallableandGetHttpsCallableFromURLoverloads that acceptHttpsCallableOptions.
- Declared new
- functions/src/include/firebase/functions.h
- Added public API overloads for
GetHttpsCallableandGetHttpsCallableFromURLthat includeHttpsCallableOptions.
- Added public API overloads for
- functions/src/include/firebase/functions/callable_reference.h
- Defined the
HttpsCallableOptionsstruct, including thelimited_use_app_check_tokenfield.
- Defined the
- functions/src/ios/functions_ios.h
- Declared new
GetHttpsCallableandGetHttpsCallableFromURLoverloads that acceptHttpsCallableOptions.
- Declared new
- functions/src/ios/functions_ios.mm
- Implemented new
GetHttpsCallableandGetHttpsCallableFromURLoverloads, translatingHttpsCallableOptionstoFIRHTTPSCallableOptionsfor iOS.
- Implemented new
- release_build_files/readme.md
- Updated the "Upcoming" release notes to mention the addition of limited use tokens in Functions.
Activity
- New integration tests were added to validate the functionality of limited-use App Check tokens with Firebase Functions.
- The changes were manually tested on macOS, Android, and iOS platforms, with screenshots provided for verification.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩