forked from invertase/react-native-firebase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app-check): implement AppCheck module
- Loading branch information
Showing
45 changed files
with
2,001 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
--- | ||
title: App Check | ||
description: Installation and getting started with App Check. | ||
icon: //static.invertase.io/assets/social/firebase-logo.png | ||
next: /auth/usage | ||
previous: /analytics/screen-tracking | ||
--- | ||
|
||
# Installation | ||
|
||
This module requires that the `@react-native-firebase/app` module is already setup and installed. To install the "app" | ||
module, view the [Getting Started](/) documentation. | ||
|
||
```bash | ||
# Install & setup the app module | ||
yarn add @react-native-firebase/app | ||
|
||
# Install the app-check module | ||
yarn add @react-native-firebase/app-check | ||
|
||
# If you're developing your app using iOS, run this command | ||
cd ios/ && pod install | ||
``` | ||
|
||
App Check requires you set the minimum iOS Deployment version in `ios/Podfile` to `11.0` or greater. | ||
|
||
You may have Xcode compiler errors after including the App Check module, specifically referencing linker problems and missing directories. | ||
|
||
You may find excluding the `i386` architecture via an addition to the `ios/Podfile` `post_install` hook like the below works: | ||
|
||
```ruby | ||
installer.aggregate_targets.each do |aggregate_target| | ||
aggregate_target.user_project.native_targets.each do |target| | ||
target.build_configurations.each do |config| | ||
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO' | ||
config.build_settings['EXCLUDED_ARCHS'] = 'i386' | ||
end | ||
end | ||
aggregate_target.user_project.save | ||
end | ||
``` | ||
|
||
# What does it do | ||
|
||
App Check works alongside other Firebase services to help protect your backend resources from abuse, such as billing fraud or phishing. With App Check, devices running your app will use an app or device attestation provider that attests to one or both of the following: | ||
|
||
- Requests originate from your authentic app | ||
- Requests originate from an authentic, untampered device | ||
|
||
This attestation is attached to every request your app makes to your Firebase backend resources. | ||
|
||
<Youtube id="Fjj4fmr2t04" /> | ||
|
||
This App Check module has built-in support for using the following services as attestation providers: | ||
|
||
- DeviceCheck on iOS | ||
- SafetyNet on Android | ||
|
||
App Check currently works with the following Firebase products: | ||
|
||
- Realtime Database | ||
- Cloud Storage | ||
- Cloud Functions (callable functions) | ||
|
||
The [official Firebase App Check documentation](https://firebase.google.com/docs/app-check) has more information, including about the iOS AppAttest provider, and testing/ CI integration, it is worth a read. | ||
|
||
# Usage | ||
|
||
## Activate | ||
|
||
On iOS if you include the App Check package, it is activated by default. The only configuration possible is the token auto refresh. When you call activate, the provider (DeviceCheck by default) stays the same but the token auto refresh setting will be changed based on the argument provided. | ||
|
||
On Android, App Check is not activated until you call the activate method. The provider is not configurable here either but if your app is "debuggable", then the Debug app check provider will be installed, otherwise the SafetyNet provider will be installed. | ||
|
||
You must call activate prior to calling any firebase back-end services for App Check to function. | ||
|
||
## Automatic Data Collection | ||
|
||
App Check has an "tokenAutoRefreshEnabled" setting. This may cause App Check to attempt a remote App Check token fetch prior to user consent. In certain scenarios, like those that exist in GDPR-compliant apps running for the first time, this may be unwanted. | ||
|
||
If unset, the "tokenAutoRefreshEnabled" setting will defer to the app's "automatic data collection" setting, which may be set in the Info.plist or AndroidManifest.xml | ||
|
||
## Using App Check tokens for non-firebase services | ||
|
||
The [official documentation](https://firebase.google.com/docs/app-check/web/custom-resource) shows how to use `getToken` to access the current App Check token and then verify it in external services. | ||
|
||
## Testing Environments / CI | ||
|
||
App Check may be used in CI environments by following the upstream documentation to configure a debug token shared with your app in the CI environment. | ||
|
||
In certain react-native testing scenarios it may be difficult to access the shared secret, but the react-native-firebase testing app for e2e testing does successfully fetch App Check tokens via: | ||
|
||
- including the App Check debug test helper in the test app, along with a change to `DetoxTest` for Android | ||
- by setting an environment variable and initializing the debug provider before firebase configure in `AppDelegate.m` for iOS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Built application files | ||
android/*/build/ | ||
|
||
# Crashlytics configuations | ||
android/com_crashlytics_export_strings.xml | ||
|
||
# Local configuration file (sdk path, etc) | ||
android/local.properties | ||
|
||
# Gradle generated files | ||
android/.gradle/ | ||
|
||
# Signing files | ||
android/.signing/ | ||
|
||
# User-specific configurations | ||
android/.idea/gradle.xml | ||
android/.idea/libraries/ | ||
android/.idea/workspace.xml | ||
android/.idea/tasks.xml | ||
android/.idea/.name | ||
android/.idea/compiler.xml | ||
android/.idea/copyright/profiles_settings.xml | ||
android/.idea/encodings.xml | ||
android/.idea/misc.xml | ||
android/.idea/modules.xml | ||
android/.idea/scopes/scope_settings.xml | ||
android/.idea/vcs.xml | ||
android/*.iml | ||
|
||
# Xcode | ||
*.pbxuser | ||
*.mode1v3 | ||
*.mode2v3 | ||
*.perspectivev3 | ||
*.xcuserstate | ||
ios/Pods | ||
ios/build | ||
*project.xcworkspace* | ||
*xcuserdata* | ||
|
||
# OS-specific files | ||
.DS_Store | ||
.DS_Store? | ||
._* | ||
.Spotlight-V100 | ||
.Trashes | ||
ehthumbs.db | ||
Thumbs.dbandroid/gradle | ||
android/gradlew | ||
android/build | ||
android/gradlew.bat | ||
android/gradle/ | ||
|
||
.idea | ||
coverage | ||
yarn.lock | ||
e2e/ | ||
.github | ||
.vscode | ||
.nyc_output | ||
android/.settings | ||
*.coverage.json | ||
.circleci | ||
.eslintignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Apache-2.0 License | ||
------------------ | ||
|
||
Copyright (c) 2016-present Invertase Limited <[email protected]> & Contributors | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this library except in compliance with the License. | ||
|
||
You may obtain a copy of the Apache-2.0 License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
|
||
Creative Commons Attribution 3.0 License | ||
---------------------------------------- | ||
|
||
Copyright (c) 2016-present Invertase Limited <[email protected]> & Contributors | ||
|
||
Documentation and other instructional materials provided for this project | ||
(including on a separate documentation repository or it's documentation website) are | ||
licensed under the Creative Commons Attribution 3.0 License. Code samples/blocks | ||
contained therein are licensed under the Apache License, Version 2.0 (the "License"), as above. | ||
|
||
You may obtain a copy of the Creative Commons Attribution 3.0 License at | ||
|
||
https://creativecommons.org/licenses/by/3.0/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<p align="center"> | ||
<a href="https://rnfirebase.io"> | ||
<img width="160px" src="https://i.imgur.com/JIyBtKW.png"><br/> | ||
</a> | ||
<h2 align="center">React Native Firebase - AppCheck</h2> | ||
</p> | ||
|
||
<p align="center"> | ||
<a href="https://api.rnfirebase.io/coverage/app-check/detail"><img src="https://api.rnfirebase.io/coverage/app-check/badge?style=flat-square" alt="Coverage"></a> | ||
<a href="https://www.npmjs.com/package/@react-native-firebase/app-check"><img src="https://img.shields.io/npm/dm/@react-native-firebase/app-check.svg?style=flat-square" alt="NPM downloads"></a> | ||
<a href="https://www.npmjs.com/package/@react-native-firebase/app-check"><img src="https://img.shields.io/npm/v/@react-native-firebase/app-check.svg?style=flat-square" alt="NPM version"></a> | ||
<a href="/LICENSE"><img src="https://img.shields.io/npm/l/react-native-firebase.svg?style=flat-square" alt="License"></a> | ||
<a href="https://lerna.js.org/"><img src="https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg?style=flat-square" alt="Maintained with Lerna"></a> | ||
</p> | ||
|
||
<p align="center"> | ||
<a href="https://invertase.link/discord"><img src="https://img.shields.io/discord/295953187817521152.svg?style=flat-square&colorA=7289da&label=Chat%20on%20Discord" alt="Chat on Discord"></a> | ||
<a href="https://twitter.com/rnfirebase"><img src="https://img.shields.io/twitter/follow/rnfirebase.svg?style=flat-square&colorA=1da1f2&colorB=&label=Follow%20on%20Twitter" alt="Follow on Twitter"></a> | ||
<a href="https://www.facebook.com/groups/rnfirebase"><img src="https://img.shields.io/badge/Follow%20on%20Facebook-4172B8?logo=facebook&style=flat-square&logoColor=fff" alt="Follow on Facebook"></a> | ||
</p> | ||
|
||
--- | ||
|
||
AppCheck description. | ||
|
||
[> Learn More](https://firebase.google.com/products/app-check/) | ||
|
||
## Installation | ||
|
||
Requires `@react-native-firebase/app` to be installed. | ||
|
||
```bash | ||
yarn add @react-native-firebase/app-check | ||
``` | ||
|
||
## Documentation | ||
|
||
- [Guides](#TODO) | ||
- [Installation](#TODO) | ||
- [Reference](#TODO) | ||
|
||
## License | ||
|
||
- See [LICENSE](/LICENSE) | ||
|
||
--- | ||
|
||
<p> | ||
<img align="left" width="75px" src="https://static.invertase.io/assets/invertase-logo-small.png"> | ||
<p align="left"> | ||
Built and maintained with 💛 by <a href="https://invertase.io">Invertase</a>. | ||
</p> | ||
</p> | ||
|
||
--- |
Oops, something went wrong.