Skip to content

Pass the iid token to authenticate Instance-ID migration to FIS. #1099

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 134 commits into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
0d05282
Add Firebase Segmentation SDK and some skeleton code in Firebase Andr…
diwu-arete Jun 13, 2019
8881325
Implement Firebase segmentation SDK device local cache
diwu-arete Jun 13, 2019
864748f
[Firebase Segmentation] Add custom installation id cache layer and te…
diwu-arete Jun 14, 2019
0a3ebf6
Add test for updating cache
diwu-arete Jun 14, 2019
2d158ed
Switch to use SQLiteOpenHelper
diwu-arete Jun 15, 2019
f118d39
Switch to use SharedPreferences from SQLite.
diwu-arete Jun 17, 2019
4da5d31
Change the cache class to be singleton
diwu-arete Jun 18, 2019
d1ff0ec
Wrap shared pref commit in a async task.
diwu-arete Jun 18, 2019
2c5102c
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Jun 18, 2019
41fbfee
Address comments
diwu-arete Jun 18, 2019
5fd2fa0
Google format fix
diwu-arete Jun 18, 2019
e950003
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Jun 18, 2019
dc46eee
[Firebase Segmentation] Add custom installation id cache layer and te…
diwu-arete Jun 18, 2019
a73ebf9
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Jun 18, 2019
dba0c0e
Replace some deprecated code.
diwu-arete Jun 18, 2019
dc37bf8
Merge branch 'floc-master' of github.com:firebase/firebase-android-sd…
diwu-arete Jun 18, 2019
ebdd626
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Jun 18, 2019
8b7380d
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Jun 18, 2019
f26741e
Merge branch 'floc-master' of github.com:firebase/firebase-android-sd…
diwu-arete Jun 18, 2019
1274b42
Fix some deprecations (#533)
diwu-arete Jun 18, 2019
38c403f
Merge branch 'floc-master' of github.com:firebase/firebase-android-sd…
diwu-arete Jun 18, 2019
a9a43a4
Package refactor
diwu-arete Jun 18, 2019
ca6dacf
nit
diwu-arete Jun 18, 2019
e7fff81
nit
diwu-arete Jun 18, 2019
d952003
package refactor (#534)
diwu-arete Jun 18, 2019
bb8bf45
Merge branch 'floc-master' of github.com:firebase/firebase-android-sd…
diwu-arete Jun 18, 2019
b381889
Add the state machine of updating custom installation id in the local
diwu-arete Jun 19, 2019
a7b5684
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Jun 19, 2019
a72cf60
Merge branch 'floc-master' of github.com:firebase/firebase-android-sd…
diwu-arete Jun 19, 2019
1adcfbd
minor format fix
diwu-arete Jun 20, 2019
6091f82
Address comments #1
diwu-arete Jun 20, 2019
ada5577
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Jun 20, 2019
fdbbdee
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Jun 20, 2019
af5bcd1
Merge branch 'floc-master' of github.com:firebase/firebase-android-sd…
diwu-arete Jun 20, 2019
e7fb811
Add the state machine of updating custom installation id in the local…
diwu-arete Jun 24, 2019
de6fb6d
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Jun 24, 2019
75e523b
Merge branch 'floc-master' of github.com:firebase/firebase-android-sd…
diwu-arete Jun 24, 2019
dd16319
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Jun 24, 2019
0a794dc
Merge branch 'floc-master' of github.com:firebase/firebase-android-sd…
diwu-arete Jun 24, 2019
134f06e
Merge branch 'floc-master' of github.com:firebase/firebase-android-sd…
diwu-arete Jun 24, 2019
6a0f502
Http client in Firebase Segmentation SDK to call backend service.
diwu-arete Jun 26, 2019
a79cae2
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Jun 26, 2019
4ac7db5
Merge branch 'floc-master' of github.com:firebase/firebase-android-sd…
diwu-arete Jun 26, 2019
7f40978
Revert unintentional change
diwu-arete Jun 26, 2019
b2fc302
Fix connected device test
diwu-arete Jun 26, 2019
1f2ab34
Fix connected device test
diwu-arete Jun 26, 2019
402d8b6
Merge branch 'arete-floc' of github.com:firebase/firebase-android-sdk…
diwu-arete Jun 26, 2019
b4e11e9
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Jul 8, 2019
ce698cf
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Jul 8, 2019
0e0278e
Merge branch 'floc-master' of github.com:firebase/firebase-android-sd…
diwu-arete Jul 8, 2019
9880624
1. Add a few annotations to make java code Kotlin friendly
diwu-arete Jul 8, 2019
8ffb5bb
Fix java format
diwu-arete Jul 8, 2019
daf4698
Fix API version
diwu-arete Jul 8, 2019
7985e14
Change the segmentation API implementation to synchronous and put the
diwu-arete Jul 9, 2019
9f36d35
Fix a async getResult race issue.
diwu-arete Jul 9, 2019
047c0af
OkHttpClient -> HttpsUrlConnection
diwu-arete Jul 10, 2019
8b39c31
Use gzip for compressing content and fix ourput stream memory leak risk.
diwu-arete Jul 18, 2019
dc1a63c
Addressed a few comments
diwu-arete Jul 22, 2019
d07ec25
Http client in Firebase Segmentation SDK to call backend service. (#573)
diwu-arete Jul 22, 2019
8ea4861
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Jul 22, 2019
b401d31
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Jul 22, 2019
8ba1c9b
Merge branch 'floc-master' of github.com:firebase/firebase-android-sd…
diwu-arete Jul 22, 2019
64af341
Initial Code structure for FIS Android SDK (#648)
ankitaj224 Jul 24, 2019
b0a625c
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
ankitaj224 Jul 29, 2019
beccce4
Initial Code structure for FIS Android SDK (#648)
ankitaj224 Jul 24, 2019
915d532
Merge branch 'fis_sdk' of github.com:firebase/firebase-android-sdk in…
ankitaj224 Jul 29, 2019
d74f799
Initial Code structure for FIS Android SDK (#648)
ankitaj224 Jul 24, 2019
c38f503
Merge branch 'fis_sdk' of github.com:firebase/firebase-android-sdk in…
ankitaj224 Jul 29, 2019
8665301
Adding http client to call fis backend service (#659)
ankitaj224 Jul 30, 2019
9ac96db
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
ankitaj224 Jul 30, 2019
46c6614
Merge branch 'fis_sdk' of github.com:firebase/firebase-android-sdk in…
ankitaj224 Jul 30, 2019
143ed74
FirebaseSegmentation SDK
diwu-arete Jul 30, 2019
0990fee
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Jul 30, 2019
e5f0cd3
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Jul 30, 2019
a5250c1
Merge branch 'floc-master' of github.com:firebase/firebase-android-sd…
diwu-arete Jul 30, 2019
16521a1
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
ankitaj224 Jul 31, 2019
7f30aea
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Aug 5, 2019
6daae2a
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Aug 5, 2019
4d5b2de
Merge branch 'floc-master' of github.com:firebase/firebase-android-sd…
diwu-arete Aug 6, 2019
52d259d
FirebaseSegmentation SDK changes (#673)
diwu-arete Aug 6, 2019
78ce7cd
Merge branch 'floc-master' of github.com:firebase/firebase-android-sd…
diwu-arete Aug 6, 2019
d467379
Restrict Firebase API key to Android app package name.
diwu-arete Aug 6, 2019
33665b2
Restrict Firebase API key to Android app package name. (#690)
diwu-arete Aug 6, 2019
818e471
Explicitly add internet permission
diwu-arete Aug 6, 2019
e2fbc88
Merge branch 'floc-master' of github.com:firebase/firebase-android-sd…
diwu-arete Aug 6, 2019
f4ba63c
Arete floc (#691)
diwu-arete Aug 6, 2019
a7ef2db
Merge branch 'floc-master' of github.com:firebase/firebase-android-sd…
diwu-arete Aug 6, 2019
47f33ec
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
ankitaj224 Aug 7, 2019
f86ba48
Implementing cache for FIS SDK (#694)
ankitaj224 Aug 7, 2019
9794e1f
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
ankitaj224 Aug 29, 2019
c1f7dbe
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
ankitaj224 Aug 30, 2019
77b6d97
Adding Util class for FIrebaseInstallations APIs. (#676)
ankitaj224 Aug 30, 2019
1980321
Initial Code structure for FIS Android SDK (#648)
ankitaj224 Jul 24, 2019
af1e510
Adding http client to call fis backend service (#659)
ankitaj224 Jul 30, 2019
30b48c3
Implementing cache for FIS SDK (#694)
ankitaj224 Aug 7, 2019
05da0b0
Adding Util class for FIrebaseInstallations APIs. (#676)
ankitaj224 Aug 30, 2019
8520ca8
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
ankitaj224 Sep 5, 2019
18a180f
Merge branch 'fis_sdk' of github.com:firebase/firebase-android-sdk in…
ankitaj224 Sep 5, 2019
e405108
Updating api.txt to resolve api-information presubmit check.
ankitaj224 Sep 13, 2019
8059184
Adding api.txt for fisbase-installations-interop
ankitaj224 Sep 13, 2019
b9437d6
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
ankitaj224 Sep 13, 2019
7ed78a4
Updating subprojects.cfg
ankitaj224 Sep 13, 2019
6a013fa
FIS getAuthToken implementation. (#769)
ankitaj224 Sep 16, 2019
5b0acbf
FID delete() implementation. (#813)
ankitaj224 Sep 18, 2019
aa73d95
Adding headers for Chemist to check API key restriction. (#821)
ankitaj224 Sep 18, 2019
ac24fae
Enabling FIS network call timeout. (#827)
ankitaj224 Sep 19, 2019
12ae11d
Simplifying FirebaseInstallations class by adding listeners. (#847)
ankitaj224 Oct 10, 2019
8e65eae
Merging changes into fis_sdk (#910)
ankitaj224 Oct 14, 2019
42e442f
FIS error handling (#911)
ankitaj224 Oct 16, 2019
98b2aac
Reuse existing Iid as Fid (#924)
ankitaj224 Oct 25, 2019
0c1ef2c
touch file (#993)
ChaoqunCHEN Nov 21, 2019
101ee18
getAuthToken error handling for 401 & 404 response code (#961)
ankitaj224 Nov 21, 2019
3adccda
Renaming getAuthToken to getToken. (#1026)
ankitaj224 Dec 3, 2019
fdbc752
Add heartbeat to fis sdk (#1037)
VinayGuthal Dec 5, 2019
56d72ee
Fixes for multi-process access (#1042)
fredquintana Dec 10, 2019
f866315
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Dec 10, 2019
77b0dc7
Merge branch 'fis_sdk' of github.com:firebase/firebase-android-sdk in…
diwu-arete Dec 10, 2019
7d91146
Remove FirebaseSegmentation from fis_sdk branch. (was added by mistake)
diwu-arete Dec 10, 2019
e54a54e
Add separator line back
diwu-arete Dec 10, 2019
d941202
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Dec 10, 2019
2840a51
Update api info for FIS SDK
diwu-arete Dec 10, 2019
7e59264
changed the instrumentation tests into unit tests (#1053)
fredquintana Dec 14, 2019
b83e5d8
Merge branch 'master' of https://github.com/firebase/firebase-android…
fredquintana Dec 14, 2019
f801a7e
Merge branch 'fis_sdk' of https://github.com/firebase/firebase-androi…
fredquintana Dec 14, 2019
e3375f2
fixed a leak when cross process locking didn't close a file
fredquintana Jan 6, 2020
7f360d3
Merge branch 'master' of https://github.com/firebase/firebase-android…
fredquintana Jan 6, 2020
0bae43b
Merge branch 'master' of https://github.com/firebase/firebase-android…
fredquintana Jan 6, 2020
ef08161
Reading the iid token from iid shared prefs.
ankitaj224 Jan 7, 2020
e22c3ca
Merge branch 'fis_sdk' of github.com:firebase/firebase-android-sdk in…
ankitaj224 Jan 7, 2020
e69bd4d
Adding iidMigrationToken in the create installation request header. …
ankitaj224 Jan 7, 2020
84e1716
Addressing Rayo's comments
ankitaj224 Jan 7, 2020
9aeb69d
Merge branch 'fis_sdk' of github.com:firebase/firebase-android-sdk in…
ankitaj224 Jan 7, 2020
b1b8f2f
Pass the iid token to authenticate Instance-ID migration to FIS.
ankitaj224 Jan 7, 2020
7c6985c
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
ankitaj224 Jan 7, 2020
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 @@ -349,13 +349,23 @@ private String readExistingIidOrCreateFid(PersistedInstallationEntry prefs) {
/** Registers the created Fid with FIS servers and update the persisted state. */
private PersistedInstallationEntry registerFidWithServer(PersistedInstallationEntry prefs)
throws IOException {

// Note: Default value of instanceIdMigrationAuth: null
String iidToken = null;

if (prefs.getFirebaseInstallationId().equals(iidStore.readIid())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't reading from iidStore a complicated action?
Maybe checking the length of the identifier (e.g. == 11) is enough?
But in the end I don't care, just sharing my thoughts.

// For a default firebase installation, read the stored star scoped iid token. This token
// will be used for authenticating Instance-ID when migrating to FIS.
iidToken = iidStore.readToken();
}

InstallationResponse response =
serviceClient.createFirebaseInstallation(
/*apiKey= */ firebaseApp.getOptions().getApiKey(),
/*fid= */ prefs.getFirebaseInstallationId(),
/*projectID= */ firebaseApp.getOptions().getProjectId(),
/*appId= */ getApplicationId(),
/* migration-header= */ null);
/* migration-header= */ iidToken);

switch (response.getResponseCode()) {
case OK:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ public class FirebaseInstallationsTest {

public static final String TEST_INSTANCE_ID_1 = "ccccccccccc";

public static final String TEST_INSTANCE_ID_TOKEN_1 = "iid.token";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iid:token (with a colon)


public static final InstallationResponse TEST_INSTALLATION_RESPONSE =
InstallationResponse.builder()
.setUri("/projects/" + TEST_PROJECT_ID + "/installations/" + TEST_FID_1)
Expand Down Expand Up @@ -185,6 +187,7 @@ public void testGetId_noNetwork_noIid() throws Exception {
when(mockBackend.generateAuthToken(anyString(), anyString(), anyString(), anyString()))
.thenThrow(new IOException());
when(mockIidStore.readIid()).thenReturn(null);
when(mockIidStore.readToken()).thenReturn(null);

// Do the actual getId() call under test. Confirm that it returns a generated FID and
// and that the FID was written to storage.
Expand All @@ -210,11 +213,16 @@ public void testGetId_noNetwork_noIid() throws Exception {
@Test
public void testGetId_noNetwork_iidPresent() throws Exception {
when(mockBackend.createFirebaseInstallation(
anyString(), anyString(), anyString(), anyString(), any()))
TEST_API_KEY,
TEST_INSTANCE_ID_1,
TEST_PROJECT_ID,
TEST_APP_ID_1,
TEST_INSTANCE_ID_TOKEN_1))
.thenThrow(new IOException());
when(mockBackend.generateAuthToken(anyString(), anyString(), anyString(), anyString()))
.thenThrow(new IOException());
when(mockIidStore.readIid()).thenReturn(TEST_INSTANCE_ID_1);
when(mockIidStore.readToken()).thenReturn(TEST_INSTANCE_ID_TOKEN_1);

// Do the actual getId() call under test. Confirm that it returns a generated FID and
// and that the FID was written to storage.
Expand Down Expand Up @@ -340,8 +348,9 @@ public void testGetId_UnRegisteredId_IssueCreateIdCall() throws Exception {
@Test
public void testGetId_migrateIid_successful() throws Exception {
when(mockIidStore.readIid()).thenReturn(TEST_INSTANCE_ID_1);
when(mockIidStore.readToken()).thenReturn(TEST_INSTANCE_ID_TOKEN_1);
when(mockBackend.createFirebaseInstallation(
anyString(), anyString(), anyString(), anyString(), any()))
anyString(), anyString(), anyString(), anyString(), anyString()))
.thenReturn(TEST_INSTALLATION_RESPONSE_WITH_IID);

// Do the actual getId() call under test.
Expand All @@ -367,6 +376,7 @@ public void testGetId_migrateIid_successful() throws Exception {
@Test
public void testGetId_multipleCalls_sameFIDReturned() throws Exception {
when(mockIidStore.readIid()).thenReturn(null);
when(mockIidStore.readToken()).thenReturn(null);
when(mockBackend.createFirebaseInstallation(
anyString(), anyString(), anyString(), anyString(), any()))
.thenReturn(TEST_INSTALLATION_RESPONSE);
Expand Down