Skip to content
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

Web: Clarify that OS.get_unique_id is not supported #82441

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion core/os/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ void OS::set_cmdline(const char *p_execpath, const List<String> &p_args, const L
}

String OS::get_unique_id() const {
ERR_FAIL_V("");
return "";
}

int OS::get_processor_count() const {
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/OS.xml
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@
<description>
Returns a string that is unique to the device.
[b]Note:[/b] This string may change without notice if the user reinstalls/upgrades their operating system or changes their hardware. This means it should generally not be used to encrypt persistent data as the data saved before an unexpected ID change would become inaccessible. The returned string may also be falsified using external programs, so do not rely on the string returned by [method get_unique_id] for security purposes.
[b]Note:[/b] Returns an empty string on Web, as this method isn't implemented on this platform yet.
[b]Note:[/b] Returns an empty string and prints an error on Web, as this method cannot be implemented on this platform.
Copy link
Member Author

Choose a reason for hiding this comment

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

That's my understanding at least, please confirm @Faless.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Indeed, or at least, no intended way to do this.
User/Device fingerprinting is detrimental for privacy, so web browsers actively fight against it.
There a bunch of known fingerprinting techniques (see e.g. Canvas fingerprinting), but none of those are there on purpose, and might be mitigated by browsers in the future (to the point of breaking your app).
The way I see it, the only "proper" way to implement this, would be to randomly generate an ID, and store it in local storage / cookie / etc.
The ID will change if the user delete local storage and will be always different when using a private window.

Copy link
Member Author

Choose a reason for hiding this comment

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

The way I see it, the only "proper" way to implement this, would be to randomly generate an ID, and store it in local storage / cookie / etc.
The ID will change if the user delete local storage and will be always different when using a private window.

That seems like an interesting compromise. I guess it would also mean have a different unique ID for each game, which might also be desired for privacy reason? You'll only be recognized by the game when you play that same game.

</description>
</method>
<method name="get_user_data_dir" qualifiers="const">
Expand Down
4 changes: 4 additions & 0 deletions platform/web/os_web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ int OS_Web::get_processor_count() const {
return godot_js_os_hw_concurrency_get();
}

String OS_Web::get_unique_id() const {
ERR_FAIL_V_MSG("", "OS::get_unique_id() is not available on the Web platform.");
}

bool OS_Web::_check_internal_feature_support(const String &p_feature) {
if (p_feature == "web") {
return true;
Expand Down
1 change: 1 addition & 0 deletions platform/web/os_web.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class OS_Web : public OS_Unix {
int get_process_id() const override;
bool is_process_running(const ProcessID &p_pid) const override;
int get_processor_count() const override;
String get_unique_id() const override;
int get_default_thread_pool_size() const override { return 1; }

String get_executable_path() const override;
Expand Down
Loading