Skip to content

feat(appcheck): Implement reCAPTCHA Enterprise App Check provider #7125

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

Merged
merged 24 commits into from
Jul 25, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e193c14
WIP: feat(appcheck): Implement initial reCAPTCHA Enterprise provider
hiteshmaurya56 Jul 8, 2025
5288e7c
WIP: feat(appcheck-recaptcha-enterprise): Add token exchange models a…
hiteshmaurya56 Jul 8, 2025
c25340b
WIP: feat(appcheck-network): Extend NetworkClient for reCAPTCHA Enter…
hiteshmaurya56 Jul 8, 2025
86c3bbb
WIP: feat(appcheck-network): Extend NetworkClient for reCAPTCHA Enter…
hiteshmaurya56 Jul 8, 2025
68ac173
WIP: feat(appcheck-recaptcha-enterprise): Implement RecaptchaEnterpri…
hiteshmaurya56 Jul 8, 2025
014dc4a
WIP: chore(appcheck-recaptcha-enterprise): Integrate module into buil…
hiteshmaurya56 Jul 8, 2025
2d2b96d
test(appcheck-recaptcha-enterprise): Add unit tests for reCAPTCHA Ent…
hiteshmaurya56 Jul 9, 2025
7a99c47
Resolves comments
hiteshmaurya56 Jul 11, 2025
c8e295b
Resolves comments
hiteshmaurya56 Jul 11, 2025
5f925b4
feat: Add new library versions
hiteshmaurya56 Jul 14, 2025
9c34a6e
Resolves build errors
hiteshmaurya56 Jul 14, 2025
290a9fb
Fix: Apply Spotless formatting to appcheck-recaptchaenterprise module
hiteshmaurya56 Jul 14, 2025
b6dea8d
Fix: Apply Spotless formatting to appcheck-recaptchaenterprise module
hiteshmaurya56 Jul 14, 2025
ff30974
Fix: Add api.txt file
hiteshmaurya56 Jul 14, 2025
874ef41
Resolves comments
hiteshmaurya56 Jul 16, 2025
f30a68e
Resolves comments
hiteshmaurya56 Jul 17, 2025
24056ce
Resolves comments
hiteshmaurya56 Jul 17, 2025
4027c4d
Resolves comments
hiteshmaurya56 Jul 18, 2025
97fc25d
Corrects Formatting
hiteshmaurya56 Jul 18, 2025
1f56a6a
Resolves Comments
hiteshmaurya56 Jul 22, 2025
8d0f5ee
Removes Map from RecaptchaEnterpriseAppCheckProviderFactory
hiteshmaurya56 Jul 23, 2025
beac8e3
Resolves Spotless formatting issue
hiteshmaurya56 Jul 24, 2025
b99b2fa
Merge branch 'main' into android-recaptchaenterprise
hiteshmaurya56 Jul 24, 2025
4160a2a
Adds existing_api.txt file
hiteshmaurya56 Jul 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,17 @@ private RecaptchaEnterpriseAppCheckProviderFactory(@NonNull String siteKey) {
/** Gets an instance of this class for installation into a {@link FirebaseAppCheck} instance. */
@NonNull
public static RecaptchaEnterpriseAppCheckProviderFactory getInstance(@NonNull String siteKey) {
return factoryInstances.computeIfAbsent(
siteKey, RecaptchaEnterpriseAppCheckProviderFactory::new);
RecaptchaEnterpriseAppCheckProviderFactory factory = factoryInstances.get(siteKey);
if (factory == null) {
synchronized (factoryInstances) {
factory = factoryInstances.get(siteKey);
if (factory == null) {
factory = new RecaptchaEnterpriseAppCheckProviderFactory(siteKey);
factoryInstances.put(siteKey, factory);
}
}
}
return factory;
}

@NonNull
Expand All @@ -56,6 +65,7 @@ public AppCheckProvider create(@NonNull FirebaseApp firebaseApp) {
ProviderMultiResourceComponent component =
firebaseApp.get(ProviderMultiResourceComponent.class);
provider = component.get(siteKey);
provider.initializeRecaptchaClient();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,17 @@ public final class ProviderMultiResourceComponent {

@NonNull
public RecaptchaEnterpriseAppCheckProvider get(@NonNull String siteKey) {
return instances.computeIfAbsent(siteKey, providerFactory::create);
RecaptchaEnterpriseAppCheckProvider provider = instances.get(siteKey);
if (provider == null) {
synchronized (instances) {
provider = instances.get(siteKey);
if (provider == null) {
provider = providerFactory.create(siteKey);
instances.put(siteKey, provider);
}
}
}
return provider;
}

@AssistedFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ public RecaptchaEnterpriseAppCheckProvider(
this.recaptchaTasksClientTask = Tasks.forResult(recaptchaTasksClient);
}

public void initializeRecaptchaClient() {
if (recaptchaTasksClientTask == null) {
synchronized (this) {
if (recaptchaTasksClientTask == null) {
Log.d(TAG, "Initializing RecaptchaTasksClient for siteKey: " + siteKey);
recaptchaTasksClientTask = Recaptcha.fetchTaskClient(application, siteKey);
}
}
}
}

@NonNull
@Override
public Task<AppCheckToken> getToken() {
Expand Down Expand Up @@ -116,13 +127,6 @@ public Task<AppCheckToken> getToken() {

@NonNull
private Task<String> getRecaptchaEnterpriseAttestation() {
if (recaptchaTasksClientTask == null) {
synchronized (this) {
if (recaptchaTasksClientTask == null) {
recaptchaTasksClientTask = Recaptcha.fetchTaskClient(application, siteKey);
}
}
}
return recaptchaTasksClientTask.continueWithTask(
blockingExecutor,
task -> {
Expand Down
Loading