Skip to content

Commit 2522c35

Browse files
authored
Merge branch 'master' into davidmotson.release_job_fix
2 parents ce53c6d + 734adc0 commit 2522c35

File tree

49 files changed

+1259
-552
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1259
-552
lines changed

.github/workflows/semver-check.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Semver Check
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- 'releases/**'
8+
9+
jobs:
10+
build-artifacts:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Perform gradle build
16+
run: |
17+
./gradlew semverCheckForRelease -PpublishConfigFilePath=release.cfg -PpublishMode=RELEASE

.github/workflows/sessions-e2e.yml

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
name: Firebase Sessions E2E Tests
22

33
on:
4-
workflow_dispatch: # allow triggering the workflow manually
4+
schedule:
5+
- cron: 24 */4 * * * # every 4 hours at 24 minutes past the hour
6+
workflow_dispatch: # allow triggering the workflow manually
57

68
concurrency:
79
group: ${{ github.workflow }}
@@ -10,29 +12,33 @@ env:
1012
SESSIONS_E2E_GOOGLE_SERVICES: ${{ secrets.SESSIONS_E2E_GOOGLE_SERVICES }}
1113

1214
jobs:
13-
build:
15+
test:
1416

1517
runs-on: ubuntu-latest
1618

1719
steps:
18-
- name: Checkout firebase-sessions
19-
uses: actions/checkout@v3
20-
with:
21-
ref: 'firebase-sessions'
22-
23-
- name: set up JDK 11
24-
uses: actions/setup-java@v3
25-
with:
26-
java-version: '11'
27-
distribution: 'temurin'
28-
cache: gradle
29-
30-
- name: Add google-services.json
31-
run: |
32-
echo $SESSIONS_E2E_GOOGLE_SERVICES | base64 -d > google-services.json
33-
34-
- name: Grant execute permission for gradlew
35-
run: chmod +x gradlew
36-
37-
- name: Run sessions end-to-end tests
38-
run: ./gradlew firebase-sessions:deviceCheck withErrorProne -PtargetBackend="prod"
20+
- name: Checkout firebase-sessions
21+
uses: actions/checkout@v3
22+
with:
23+
ref: 'firebase-sessions'
24+
25+
- name: set up JDK 11
26+
uses: actions/setup-java@v3
27+
with:
28+
java-version: '11'
29+
distribution: 'temurin'
30+
cache: gradle
31+
32+
- name: Add google-services.json
33+
run: |
34+
echo $SESSIONS_E2E_GOOGLE_SERVICES | base64 -d > google-services.json
35+
36+
- uses: google-github-actions/auth@v0
37+
with:
38+
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT }}
39+
- uses: google-github-actions/setup-gcloud@v0
40+
- name: Run sessions end-to-end tests
41+
env:
42+
FTL_RESULTS_BUCKET: fireescape
43+
run: |
44+
./gradlew :firebase-sessions:test-app:deviceCheck withErrorProne -PtargetBackend="prod"

appcheck/firebase-appcheck/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Unreleased
2+
* [feature] Added `getLimtedUseAppCheckToken()` for obtaining limited-use tokens
3+
for protecting non-Firebase backends.
24

35
# 16.1.2
46
* [unchanged] Updated to keep [app_check] SDK versions aligned.

appcheck/firebase-appcheck/api.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ package com.google.firebase.appcheck {
2121
method @NonNull public abstract com.google.android.gms.tasks.Task<com.google.firebase.appcheck.AppCheckToken> getAppCheckToken(boolean);
2222
method @NonNull public static com.google.firebase.appcheck.FirebaseAppCheck getInstance();
2323
method @NonNull public static com.google.firebase.appcheck.FirebaseAppCheck getInstance(@NonNull com.google.firebase.FirebaseApp);
24+
method @NonNull public abstract com.google.android.gms.tasks.Task<com.google.firebase.appcheck.AppCheckToken> getLimitedUseAppCheckToken();
2425
method public abstract void installAppCheckProviderFactory(@NonNull com.google.firebase.appcheck.AppCheckProviderFactory);
2526
method public abstract void installAppCheckProviderFactory(@NonNull com.google.firebase.appcheck.AppCheckProviderFactory, boolean);
2627
method public abstract void removeAppCheckListener(@NonNull com.google.firebase.appcheck.FirebaseAppCheck.AppCheckListener);

appcheck/firebase-appcheck/src/main/java/com/google/firebase/appcheck/FirebaseAppCheck.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,29 @@ public abstract void installAppCheckProviderFactory(
7575
* Requests a Firebase App Check token. This method should be used ONLY if you need to authorize
7676
* requests to a non-Firebase backend. Requests to Firebase backends are authorized automatically
7777
* if configured.
78+
*
79+
* <p>If your non-Firebase backend exposes sensitive or expensive endpoints that has low traffic
80+
* volume, consider protecting it with <a
81+
* href=https://firebase.google.com/docs/app-check/custom-resource-backend#replay-protection>Replay
82+
* Protection</a>. In this case, use the #getLimitedUseAppCheckToken() instead to obtain a
83+
* limited-use token.
7884
*/
7985
@NonNull
8086
public abstract Task<AppCheckToken> getAppCheckToken(boolean forceRefresh);
8187

88+
/**
89+
* Requests a Firebase App Check token. This method should be used ONLY if you need to authorize
90+
* requests to a non-Firebase backend.
91+
*
92+
* <p>Returns limited-use tokens that are intended for use with your non-Firebase backend
93+
* endpoints that are protected with <a
94+
* href=https://firebase.google.com/docs/app-check/custom-resource-backend#replay-protection>Replay
95+
* Protection</a>. This method does not affect the token generation behavior of the
96+
* #getAppCheckToken() method.
97+
*/
98+
@NonNull
99+
public abstract Task<AppCheckToken> getLimitedUseAppCheckToken();
100+
82101
/**
83102
* Registers an {@link AppCheckListener} to changes in the token state. This method should be used
84103
* ONLY if you need to authorize requests to a non-Firebase backend. Requests to Firebase backends

appcheck/firebase-appcheck/src/main/java/com/google/firebase/appcheck/internal/DefaultFirebaseAppCheck.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,19 @@ public Task<AppCheckToken> getAppCheckToken(boolean forceRefresh) {
229229
});
230230
}
231231

232+
@NonNull
233+
@Override
234+
public Task<AppCheckToken> getLimitedUseAppCheckToken() {
235+
if (appCheckProvider == null) {
236+
return Tasks.forException(new FirebaseException("No AppCheckProvider installed."));
237+
}
238+
239+
// We explicitly do not call the fetchTokenFromProvider helper method, as that method includes
240+
// side effects such as notifying listeners, updating the cached token, and scheduling token
241+
// refresh.
242+
return appCheckProvider.getToken();
243+
}
244+
232245
/** Fetches an {@link AppCheckToken} via the installed {@link AppCheckProvider}. */
233246
Task<AppCheckToken> fetchTokenFromProvider() {
234247
return appCheckProvider

appcheck/firebase-appcheck/src/test/java/com/google/firebase/appcheck/internal/DefaultFirebaseAppCheckTest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,13 @@ public void testGetAppCheckToken_noFactoryInstalled_taskFails() throws Exception
228228
assertThat(tokenTask.isSuccessful()).isFalse();
229229
}
230230

231+
@Test
232+
public void testGetLimitedUseAppCheckToken_noFactoryInstalled_taskFails() throws Exception {
233+
Task<AppCheckToken> tokenTask = defaultFirebaseAppCheck.getLimitedUseAppCheckToken();
234+
assertThat(tokenTask.isComplete()).isTrue();
235+
assertThat(tokenTask.isSuccessful()).isFalse();
236+
}
237+
231238
@Test
232239
public void testGetToken_factoryInstalled_proxiesToAppCheckFactory() {
233240
defaultFirebaseAppCheck.installAppCheckProviderFactory(mockAppCheckProviderFactory);
@@ -396,4 +403,23 @@ public void testGetAppCheckToken_existingInvalidToken_requestsNewToken() {
396403

397404
verify(mockAppCheckProvider).getToken();
398405
}
406+
407+
@Test
408+
public void testGetLimitedUseAppCheckToken_noExistingToken_requestsNewToken() {
409+
defaultFirebaseAppCheck.installAppCheckProviderFactory(mockAppCheckProviderFactory);
410+
411+
defaultFirebaseAppCheck.getLimitedUseAppCheckToken();
412+
413+
verify(mockAppCheckProvider).getToken();
414+
}
415+
416+
@Test
417+
public void testGetLimitedUseAppCheckToken_existingToken_requestsNewToken() {
418+
defaultFirebaseAppCheck.setCachedToken(validDefaultAppCheckToken);
419+
defaultFirebaseAppCheck.installAppCheckProviderFactory(mockAppCheckProviderFactory);
420+
421+
defaultFirebaseAppCheck.getLimitedUseAppCheckToken();
422+
423+
verify(mockAppCheckProvider).getToken();
424+
}
399425
}

appcheck/firebase-appcheck/test-app/src/main/java/com/googletest/firebase/appcheck/MainActivity.java

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class MainActivity extends AppCompatActivity {
4747
private Button installSafetyNetButton;
4848
private Button installDebugButton;
4949
private Button getAppCheckTokenButton;
50+
private Button getLimitedUseTokenButton;
5051
private Button listStorageFilesButton;
5152

5253
@Override
@@ -74,7 +75,7 @@ private void initFirebase() {
7475
new AppCheckListener() {
7576
@Override
7677
public void onAppCheckTokenChanged(@NonNull AppCheckToken token) {
77-
Log.d(TAG, "onAppCheckTokenChanged");
78+
Log.d(TAG, "onAppCheckTokenChanged: " + token.getToken());
7879
}
7980
};
8081

@@ -86,6 +87,7 @@ private void initViews() {
8687
installSafetyNetButton = findViewById(R.id.install_safety_net_app_check_button);
8788
installDebugButton = findViewById(R.id.install_debug_app_check_button);
8889
getAppCheckTokenButton = findViewById(R.id.exchange_app_check_button);
90+
getLimitedUseTokenButton = findViewById(R.id.limited_use_app_check_button);
8991
listStorageFilesButton = findViewById(R.id.storage_list_files_button);
9092

9193
setOnClickListeners();
@@ -134,20 +136,55 @@ public void onClick(View v) {
134136
new OnSuccessListener<AppCheckToken>() {
135137
@Override
136138
public void onSuccess(AppCheckToken appCheckToken) {
137-
Log.d(TAG, "Successfully retrieved AppCheck token.");
138-
showToast("Successfully retrieved AppCheck token.");
139+
// Note: Logging App Check tokens is bad practice and should NEVER be done in a
140+
// production application. We log the token here in our unpublished test
141+
// application for easier debugging.
142+
Log.d(
143+
TAG, "Successfully retrieved App Check token: " + appCheckToken.getToken());
144+
showToast("Successfully retrieved App Check token.");
139145
}
140146
});
141147
task.addOnFailureListener(
142148
new OnFailureListener() {
143149
@Override
144150
public void onFailure(@NonNull Exception e) {
145-
Log.d(TAG, "AppCheck token exchange failed with error: " + e.getMessage());
146-
showToast("AppCheck token exchange failed.");
151+
Log.d(TAG, "App Check token exchange failed with error: " + e.getMessage());
152+
showToast("App Check token exchange failed.");
147153
}
148154
});
149155
}
150156
});
157+
158+
getLimitedUseTokenButton.setOnClickListener(
159+
new OnClickListener() {
160+
@Override
161+
public void onClick(View v) {
162+
Task<AppCheckToken> task = firebaseAppCheck.getLimitedUseAppCheckToken();
163+
task.addOnSuccessListener(
164+
new OnSuccessListener<AppCheckToken>() {
165+
@Override
166+
public void onSuccess(AppCheckToken appCheckToken) {
167+
// Note: Logging App Check tokens is bad practice and should NEVER be done in a
168+
// production application. We log the token here in our unpublished test
169+
// application for easier debugging.
170+
Log.d(
171+
TAG,
172+
"Successfully retrieved limited-use App Check token: "
173+
+ appCheckToken.getToken());
174+
showToast("Successfully retrieved limited-use App Check token.");
175+
}
176+
});
177+
task.addOnFailureListener(
178+
new OnFailureListener() {
179+
@Override
180+
public void onFailure(@NonNull Exception e) {
181+
Log.d(TAG, "App Check token exchange failed with error: " + e.getMessage());
182+
showToast("App Check token exchange failed.");
183+
}
184+
});
185+
}
186+
});
187+
151188
listStorageFilesButton.setOnClickListener(
152189
new OnClickListener() {
153190
@Override

appcheck/firebase-appcheck/test-app/src/main/res/layout/activity_main.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
android:layout_width="wrap_content"
2727
android:layout_height="wrap_content"
2828
android:text="@string/exchange_app_check_button_text"/>
29+
<Button
30+
android:id="@+id/limited_use_app_check_button"
31+
android:layout_width="wrap_content"
32+
android:layout_height="wrap_content"
33+
android:text="@string/limited_use_app_check_button_text"/>
2934
<Button
3035
android:id="@+id/storage_list_files_button"
3136
android:layout_width="wrap_content"

appcheck/firebase-appcheck/test-app/src/main/res/values/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<string name="install_play_integrity_app_check_button_text">Install PlayIntegrityAppCheckProvider</string>
44
<string name="install_safety_net_app_check_button_text">Install SafetyNetAppCheckProvider</string>
55
<string name="install_debug_app_check_button_text">Install DebugAppCheckProvider</string>
6-
<string name="exchange_app_check_button_text">Exchange attestation for App Check token</string>
6+
<string name="exchange_app_check_button_text">Get App Check token</string>
7+
<string name="limited_use_app_check_button_text">Get limited-use App Check token</string>
78
<string name="storage_list_files_button_text">List Cloud Storage files with App Check token</string>
89
</resources>

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ buildscript {
3636
}
3737

3838
dependencies {
39-
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.14'
39+
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.2'
4040
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:1.3.0'
4141
classpath 'gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.9'
4242
classpath 'com.google.gms:google-services:4.3.15'

buildSrc/build.gradle.kts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,31 @@ ktfmt {
4040
googleStyle()
4141
}
4242

43+
java {
44+
sourceCompatibility = JavaVersion.VERSION_1_8
45+
targetCompatibility = JavaVersion.VERSION_1_8
46+
}
47+
4348
dependencies {
4449
// Firebase performance plugin, it should be added here because of how gradle dependency
4550
// resolution works, otherwise it breaks Fireperf Test Apps.
4651
// See https://github.com/gradle/gradle/issues/12286
4752
implementation("com.google.firebase:perf-plugin:$perfPluginVersion")
48-
4953
implementation("com.google.auto.value:auto-value-annotations:1.8.1")
5054
annotationProcessor("com.google.auto.value:auto-value:1.6.5")
5155
implementation(kotlin("gradle-plugin", "1.7.10"))
5256
implementation("org.json:json:20210307")
5357

5458
implementation("org.eclipse.aether:aether-api:1.0.0.v20140518")
5559
implementation("org.eclipse.aether:aether-util:1.0.0.v20140518")
60+
implementation("org.ow2.asm:asm-tree:9.5")
5661
implementation("org.eclipse.aether:aether-impl:1.0.0.v20140518")
5762
implementation("org.eclipse.aether:aether-connector-basic:1.0.0.v20140518")
5863
implementation("org.eclipse.aether:aether-transport-file:1.0.0.v20140518")
5964
implementation("org.eclipse.aether:aether-transport-http:1.0.0.v20140518")
6065
implementation("org.eclipse.aether:aether-transport-wagon:1.0.0.v20140518")
6166
implementation("org.apache.maven:maven-aether-provider:3.1.0")
62-
67+
6368
implementation("org.eclipse.jgit:org.eclipse.jgit:6.3.0.202209071007-r")
6469

6570
implementation("com.google.code.gson:gson:2.8.9")
@@ -110,9 +115,3 @@ tasks.withType<Test> {
110115
val enablePluginTests: String? by rootProject
111116
enabled = enablePluginTests == "true"
112117
}
113-
114-
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
115-
kotlinOptions {
116-
jvmTarget = "11"
117-
}
118-
}

buildSrc/src/main/java/com/google/firebase/gradle/plugins/FirebaseLibraryPlugin.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,12 @@ class FirebaseLibraryPlugin : BaseFirebaseLibraryPlugin() {
9696
aarAndroidFile.value(true)
9797
filePath.value(project.file("semver/previous.aar").absolutePath)
9898
}
99-
99+
val artifact = firebaseLibrary.artifactId.get()
100+
val releaseAar = if (artifact.contains("-ktx")) "ktx-release.aar" else "${artifact}-release.aar"
100101
project.tasks.register<Copy>("extractCurrentClasses") {
101102
dependsOn("bundleReleaseAar")
102103

103-
from(project.zipTree("build/outputs/aar/${firebaseLibrary.artifactId.get()}-release.aar"))
104+
from(project.zipTree("build/outputs/aar/${releaseAar}"))
104105
into(project.file("semver/current-version"))
105106
}
106107
project.tasks.register<Copy>("extractPreviousClasses") {

buildSrc/src/main/java/com/google/firebase/gradle/plugins/ci/Coverage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static void apply(FirebaseLibraryExtension firebaseLibrary) {
3636
JacocoPluginExtension jacoco = project.getExtensions().getByType(JacocoPluginExtension.class);
3737

3838
jacoco.setToolVersion("0.8.8");
39-
jacoco.setReportsDir(reportsDir);
39+
jacoco.getReportsDirectory().set(reportsDir);
4040
project
4141
.getTasks()
4242
.withType(

buildSrc/src/main/java/com/google/firebase/gradle/plugins/license/GenerateLicensesTask.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import org.gradle.api.tasks.Input;
3333
import org.gradle.api.tasks.OutputDirectory;
3434
import org.gradle.api.tasks.TaskAction;
35-
import org.gradle.api.tasks.incremental.IncrementalTaskInputs;
35+
import org.gradle.work.InputChanges;
3636

3737
abstract class GenerateLicensesTask extends DefaultTask {
3838
private static final int NEW_LINE_LENGTH = "\n".getBytes().length;
@@ -56,7 +56,7 @@ public GenerateLicensesTask() {
5656
}
5757

5858
@TaskAction
59-
void execute(IncrementalTaskInputs inputs) {
59+
void execute(InputChanges inputs) {
6060
Set<URI> licenseUris = new HashSet<URI>();
6161
for (ThirdPartyLicensesExtension.CustomLicense license : getadditionalLicenses()) {
6262
licenseUris.addAll(license.licenseUris);

0 commit comments

Comments
 (0)