Skip to content

feat(clients): use hardware id for device verification#6857

Merged
conectado merged 21 commits intomainfrom
feat/connlib/use-hardware-id-for-device-verification
Oct 2, 2024
Merged

feat(clients): use hardware id for device verification#6857
conectado merged 21 commits intomainfrom
feat/connlib/use-hardware-id-for-device-verification

Conversation

@conectado
Copy link
Copy Markdown
Contributor

@conectado conectado commented Sep 27, 2024

We want to associate additional device information for the device verification, these are all parameters that tries to uniquely identify the hardware.

For that reason we read system information and send it as part of the query params to the portal, that way the portal can store this when device is verified and match against that later on.

These are the parameters according to each platform:

Platform Query Field Field Meaning
MacOS device_serial Hardware's Serial
MacOS device_uuid Hardware's UUID
iOS identifier_for_vendor Identifier for vendor, resets only on uninstall/install
Android firebase_installation_id Firebase installation ID, resets only on uninstall/install
Windows device_serial Motherboard's Serial
Linux device_serial Motherboard's Serial

Fixes #6837

@vercel
Copy link
Copy Markdown

vercel bot commented Sep 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 2, 2024 2:45am

@conectado conectado changed the title Feat/connlib/use hardware id for device verification feat(clients): use hardware id for device verification Sep 28, 2024
@conectado conectado force-pushed the feat/connlib/use-hardware-id-for-device-verification branch from 5a81233 to fbe3e57 Compare September 30, 2024 14:53
@conectado conectado marked this pull request as ready for review September 30, 2024 15:15
@conectado
Copy link
Copy Markdown
Contributor Author

@jamilbk this is practically ready but we should decide if we keep the fallback or maybe skip smbios completely?

@conectado
Copy link
Copy Markdown
Contributor Author

Before merging I also still need to test on iOS

@conectado
Copy link
Copy Markdown
Contributor Author

Also to note here, after merging this PR even when we fallback, due to no longer hashing the id, this will un-verify all new clients, so this might be worth a minor version change?

@jamilbk
Copy link
Copy Markdown
Member

jamilbk commented Sep 30, 2024

Also to note here, after merging this PR even when we fallback, due to no longer hashing the id, this will un-verify all new clients, so this might be worth a minor version change?

I don't think many are using this feature yet, so I'll just let the customer know directly.

Copy link
Copy Markdown
Member

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

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

Overall looks good. From the issue it sounds like there are more changes coming though :)

@conectado conectado force-pushed the feat/connlib/use-hardware-id-for-device-verification branch from 2d1fb47 to 01b9ff2 Compare October 2, 2024 02:36
@conectado conectado marked this pull request as ready for review October 2, 2024 02:45
@conectado
Copy link
Copy Markdown
Contributor Author

conectado commented Oct 2, 2024

@thomaseizinger Ready for another round of reviews

Copy link
Copy Markdown
Member

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

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

LGTM

I think we should clean up the error handling but that can happen in a follow-up!

Comment on lines +329 to +362
val executor = Executors.newSingleThreadExecutor()

executor.execute {
val deviceInfo = DeviceInfo()

runCatching {
Tasks.await(FirebaseInstallations.getInstance().id)
}.onSuccess { firebaseInstallationId ->
deviceInfo.firebaseInstallationId = firebaseInstallationId
}.onFailure { exception ->
Log.d(TAG, "Failed to obtain firebase installation id: $exception")
}

val gson: Gson =
GsonBuilder()
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
.create()

connlibSessionPtr =
ConnlibSession.connect(
apiUrl = config.apiUrl,
token = token,
deviceId = deviceId(),
deviceName = getDeviceName(),
osVersion = Build.VERSION.RELEASE,
logDir = getLogDir(),
logFilter = config.logFilter,
callback = callback,
deviceInfo = gson.toJson(deviceInfo),
)

startNetworkMonitoring()
startDisconnectMonitoring()
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This has gotten a bit verbose which was the main reason I suggested to do it elsewhere. I don't know how long it takes to fetch the Firebase ID, I guess once it is cached locally it shouldn't delay the connect much?

install_rustls_crypto_provider();

let secret = SecretString::from(token);
let device_info = serde_json::from_str(&device_info).unwrap();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
let device_info = serde_json::from_str(&device_info).unwrap();
let device_info = serde_json::from_str(&device_info)?;

let log_filter = string_from_jstring!(env, log_filter);
let device_info = string_from_jstring!(env, device_info);

let device_info = serde_json::from_str(&device_info).unwrap();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
let device_info = serde_json::from_str(&device_info).unwrap();
let device_info = serde_json::from_str(&device_info)?;

@conectado conectado added this pull request to the merge queue Oct 2, 2024
Merged via the queue into main with commit 3501d5b Oct 2, 2024
@conectado conectado deleted the feat/connlib/use-hardware-id-for-device-verification branch October 2, 2024 08:58
@jamilbk
Copy link
Copy Markdown
Member

jamilbk commented Oct 2, 2024

@conectado Hm I thought we'd cut clients before this got merged. Are the portal changes already deployed to prod? Otherwise we need to revert this, cut clients, and merge this when we can deploy them to prod right?

@conectado
Copy link
Copy Markdown
Contributor Author

conectado commented Oct 2, 2024

@conectado Hm I thought we'd cut clients before this got merged. Are the portal changes already deployed to prod? Otherwise we need to revert this, cut clients, and merge this when we can deploy them to prod right?

@jamilbk We just need to revert the changes to hashing the device id, which we should anyways, that was a left over from the first implementation. Everything else should be harmless as we only add fields not remove it.

@jamilbk
Copy link
Copy Markdown
Member

jamilbk commented Oct 2, 2024

@conectado Got it, thanks for the clarification. If the only breakage here is that it resets verified clients, I'll check prod to see who's using that feature and then just notify them directly.

@conectado
Copy link
Copy Markdown
Contributor Author

@conectado Got it, thanks for the clarification. If the only breakage here is that it resets verified clients, I'll check prod to see who's using that feature and then just notify them directly.

@jamilbk yes, that should be it. Though shouldn't we just revert that change? I'm not sure why we hashed the id in the first place but there's no point to making this change anymore

@thomaseizinger
Copy link
Copy Markdown
Member

@conectado Got it, thanks for the clarification. If the only breakage here is that it resets verified clients, I'll check prod to see who's using that feature and then just notify them directly.

@jamilbk yes, that should be it. Though shouldn't we just revert that change? I'm not sure why we hashed the id in the first place but there's no point to making this change anymore

I'll send a PR for that so we are unblocked from releasing.

@conectado
Copy link
Copy Markdown
Contributor Author

@conectado Got it, thanks for the clarification. If the only breakage here is that it resets verified clients, I'll check prod to see who's using that feature and then just notify them directly.

@jamilbk yes, that should be it. Though shouldn't we just revert that change? I'm not sure why we hashed the id in the first place but there's no point to making this change anymore

I'll send a PR for that so we are unblocked from releasing.

Thank you @thomaseizinger ! I didn't find the time to sit down and do it myself

@thomaseizinger
Copy link
Copy Markdown
Member

PR here: #6918.

github-merge-queue bot pushed a commit that referenced this pull request Oct 2, 2024
As part of iterating on the correct approach in #6857, we at some point
removed the hashing of the Firezone-generated device ID. This will break
customers because all of the device IDs as seen by the portal are
changing.

We've since settled on a different approach for device verification. To
not break anyone, we are re-introducing hashing of the device ID.

Related: #6857.
@jamilbk
Copy link
Copy Markdown
Member

jamilbk commented Oct 3, 2024

@conectado Was there a reason why we are not also pulling the SMBIOS UUID for PC systems? That way we have field parity for all desktop systems, similar to what the WARP client pulls.

I left a comment regarding this here: #6837 (comment)

@jamilbk
Copy link
Copy Markdown
Member

jamilbk commented Oct 3, 2024

Fixed here: #6921

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use hardware ID for device verification

3 participants