Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[📚] [firebase_app_check] Play Integrity Support #9178

Closed
cnkygmr opened this issue Jul 21, 2022 · 4 comments · Fixed by flooz-link/flutterfire#1 or #9646
Closed

[📚] [firebase_app_check] Play Integrity Support #9178

cnkygmr opened this issue Jul 21, 2022 · 4 comments · Fixed by flooz-link/flutterfire#1 or #9646
Labels
good first issue Good for newcomers plugin: app_check resolution: fixed A fix has been merged or is pending merge from a PR. type: documentation Improvements or additions to documentation

Comments

@cnkygmr
Copy link

cnkygmr commented Jul 21, 2022

Please describe your documentation issue or suggested improvement in detail here and provide links to any pre-existing/relevant documentation and screenshots if necessary:
While examining it, I noticed that this plugin does not support Play Integrity. And I wonder when it will be added.

@cnkygmr cnkygmr added good first issue Good for newcomers type: documentation Improvements or additions to documentation labels Jul 21, 2022
@darshankawar darshankawar added triage Issue is currently being triaged. plugin: app_check and removed triage Issue is currently being triaged. labels Jul 21, 2022
@ghost
Copy link

ghost commented Jul 22, 2022

@cnkygmr I am not sure that is a true position that the plugin does not support Play Integrity - it does. I have built an app that uses the plugin and is correctly setup to use both Play Integrity and SafetyNet. Here is a screenshot from Firebase Console
Screen Shot 2022-07-22 at 10 46 49 PM

Here is the Flutter App Check documentation https://firebase.google.com/docs/app-check/flutter/default-providers have you had a chance to see this?

Essentially to setup both Play Integrity and SafetyNet you just need the SHA-256 certificate fingerprint of both your development and production keystores Cc @darshankawar

@cnkygmr
Copy link
Author

cnkygmr commented Jul 22, 2022

@ronnicknachok
@darshankawar
Hello,

I mean, when you browse the codes, there is nothing about playintegrity, there is only safetynet, this safety net is going up, google sent mail, I want you to change this code with safetynet.

You can check it out here:

private Task<Void> activate(Map<String, Object> arguments) {
return Tasks.call(
cachedThreadPool,
() -> {
FirebaseAppCheck firebaseAppCheck = getAppCheck(arguments);
firebaseAppCheck.installAppCheckProviderFactory(
SafetyNetAppCheckProviderFactory.getInstance());
return null;
});
}

When you activate the code, only safetynet works.

FirebaseApp.initializeApp(/*context=*/this)
val firebaseAppCheck = FirebaseAppCheck.getInstance()
firebaseAppCheck.installAppCheckProviderFactory(
    PlayIntegrityAppCheckProviderFactory.getInstance()
)

I activated playintegrity with this code, but this time firebase initializes 2 times..

Becabuse i used in main.dart

await Firebase.initializeApp(
        options: DefaultFirebaseOptions.currentPlatform);

As a result, when you use the firebase_app_check plugin, it only uses safetynet.

@ghost
Copy link

ghost commented Jul 22, 2022

@cnkygmr I think this is because you are mixing two implementations from your code above I can see Kotlin code sample from https://firebase.google.com/docs/app-check/android/play-integrity-provider#initialize which means you used the Android version of integration and not the Flutter version. The Flutter version does not require adding the Kotlin code. By any chance in your build.gradle on Android project..do you have this entry implementation 'com.google.firebase:firebase-appcheck-playintegrity' ?

As per this documentation https://firebase.google.com/docs/app-check/flutter/default-providers once you flutter pub add firebase_app_check and flutter pub get then one line of code sets it all like in this sample

import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';

// Import the firebase_app_check plugin
import 'package:firebase_app_check/firebase_app_check.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
        options: DefaultFirebaseOptions.currentPlatform);
  await FirebaseAppCheck.instance.activate(
    webRecaptchaSiteKey: 'recaptcha-v3-site-key',
  );
  runApp(App());
}

Also this is an important read https://developer.android.com/google/play/integrity/setup#apps-on-google-play. Let me know if this helped or moved further from your question. Setting up Play Integrity with Flutter is as easy as one line of code.

@cnkygmr
Copy link
Author

cnkygmr commented Jul 22, 2022

@ronnicknachok

await FirebaseAppCheck.instance.activate(
    webRecaptchaSiteKey: 'recaptcha-v3-site-key',
  );

but I showed you the code, when you use this code, only safetynet is active

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