Skip to content

Commit 628ca94

Browse files
committed
feat(app_check, android): add option to use FIREBASE_APP_CHECK_DEBUG_TOKEN env variable as debug token on Android
1 parent 2b84feb commit 628ca94

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

packages/firebase_app_check/firebase_app_check/android/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ android {
4545
defaultConfig {
4646
minSdk 19
4747
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
48+
buildConfigField "String", "FIREBASE_APP_CHECK_DEBUG_TOKEN", "\"${System.env.FIREBASE_APP_CHECK_DEBUG_TOKEN}\""
4849
}
4950

5051
compileOptions {

packages/firebase_app_check/firebase_app_check/android/src/main/java/io/flutter/plugins/firebase/appcheck/FlutterFirebaseAppRegistrar.java

+17-2
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,32 @@
55
package io.flutter.plugins.firebase.appcheck;
66

77
import androidx.annotation.Keep;
8+
9+
import com.google.firebase.appcheck.debug.InternalDebugSecretProvider;
810
import com.google.firebase.components.Component;
911
import com.google.firebase.components.ComponentRegistrar;
1012
import com.google.firebase.platforminfo.LibraryVersionComponent;
13+
14+
import java.util.Arrays;
1115
import java.util.Collections;
1216
import java.util.List;
1317

1418
@Keep
1519
public class FlutterFirebaseAppRegistrar implements ComponentRegistrar {
20+
private static final String DEBUG_SECRET_NAME = "fire-app-check-debug-secret";
21+
1622
@Override
1723
public List<Component<?>> getComponents() {
18-
return Collections.<Component<?>>singletonList(
19-
LibraryVersionComponent.create(BuildConfig.LIBRARY_NAME, BuildConfig.LIBRARY_VERSION));
24+
Component<?> library = LibraryVersionComponent.create(BuildConfig.LIBRARY_NAME,
25+
BuildConfig.LIBRARY_VERSION);
26+
27+
if (BuildConfig.FIREBASE_APP_CHECK_DEBUG_TOKEN == null)
28+
return Collections.<Component<?>>singletonList(library);
29+
30+
Component<InternalDebugSecretProvider> debugSecretProvider = Component.builder(InternalDebugSecretProvider.class)
31+
.name(DEBUG_SECRET_NAME)
32+
.factory(container -> () -> BuildConfig.FIREBASE_APP_CHECK_DEBUG_TOKEN).build();
33+
34+
return Arrays.<Component<?>>asList(library, debugSecretProvider);
2035
}
2136
}

0 commit comments

Comments
 (0)