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

Actually use Device Type for mails #4916

Merged
merged 1 commit into from
Sep 18, 2024

Conversation

dfunkt
Copy link
Contributor

@dfunkt dfunkt commented Sep 3, 2024

  • match Bitwarden behaviour
  • remove upcase_first, no longer needed and it would also interfere with device types like iOS, macOS

Examples:

Chrome Extension
Before -> New Device Logged In From/Incomplete Two-Step Login From/Device Type: Chrome
After -> New Device Logged In From/Incomplete Two-Step Login From/Device Type: Chrome Extension

Poco F3 (shows up as M2012K11AG)
Before -> New Device Logged In From/Incomplete Two-Step Login From/Device Type: M2012K11AG
After -> New Device Logged In From/Incomplete Two-Step Login From/Device Type: Android

@jjlin
Copy link
Contributor

jjlin commented Sep 3, 2024

If the device type is Android or iOS, the mobile client should include a device model as the name, so the notification email should ideally include that info for those device types. I'm not sure if any other device types include useful model/name info.

@dfunkt
Copy link
Contributor Author

dfunkt commented Sep 3, 2024

Let's not forget that the email template says "Device Type", not "Device Type and Name/Model" or anything like that.
Example:


Ideally I try to stick as close as possible to Bitwarden's behaviour when implementing these changes, and the emails from them don't specify the device name/model number either.

Nonetheless, let's see what others have to say about this change.

@jjlin
Copy link
Contributor

jjlin commented Sep 3, 2024

Vaultwarden does various things differently from Bitwarden, as long as they are compatible improvements. For example, Bitwarden does not even have a 2FA incomplete notification AFAIK.

@BlackDex
Copy link
Collaborator

BlackDex commented Sep 3, 2024

I agree with @jjlin.
For all the client functionality we should stay as close as possible.
Server-side specific changes should be looked at if it has no impact client side or might alter a way of working.

But for something like emails shouldn't be an issue.
I actually love it shows we the device name and not only type.
So both would be better.

I even was thinking about adding basic location detection based upon IP.

@dfunkt
Copy link
Contributor Author

dfunkt commented Sep 4, 2024

New variant with device name and device type included.
Examples:
Screenshot from 2024-09-04 14-44-43
Screenshot from 2024-09-04 14-44-58

@dfunkt dfunkt marked this pull request as draft September 4, 2024 12:08
@dfunkt dfunkt marked this pull request as ready for review September 4, 2024 12:08
src/db/models/two_factor_incomplete.rs Outdated Show resolved Hide resolved
src/db/models/two_factor_incomplete.rs Outdated Show resolved Hide resolved
src/db/schemas/mysql/schema.rs Outdated Show resolved Hide resolved
src/api/identity.rs Outdated Show resolved Hide resolved
@dfunkt
Copy link
Contributor Author

dfunkt commented Sep 4, 2024

I chose atype on purpose to match how it was in device.rs:

pub atype: i32, // https://github.com/bitwarden/server/blob/dcc199bcce4aa2d5621f6fab80f1b49d8b143418/src/Core/Enums/DeviceType.cs

Which one do you prefer @BlackDex? atype or just type?

@BlackDex
Copy link
Collaborator

BlackDex commented Sep 4, 2024

type is the correct name. The only reason there is an a in front is because you can't use that as a variable name.

@jjlin
Copy link
Contributor

jjlin commented Sep 4, 2024

I chose atype on purpose to match how it was in device.rs:

pub atype: i32, // https://github.com/bitwarden/server/blob/dcc199bcce4aa2d5621f6fab80f1b49d8b143418/src/Core/Enums/DeviceType.cs

This is only called atype because you can't have an identifier that's just called type. There are many other existing instances of device_type in the code.

@dfunkt
Copy link
Contributor Author

dfunkt commented Sep 4, 2024

Hopefully things are good now

@dfunkt dfunkt force-pushed the email-device-type branch 2 times, most recently from 783c5d0 to e123c93 Compare September 7, 2024 09:45
src/api/identity.rs Outdated Show resolved Hide resolved
src/api/identity.rs Outdated Show resolved Hide resolved
@dfunkt dfunkt force-pushed the email-device-type branch 4 times, most recently from cfdac26 to 6bc27e2 Compare September 9, 2024 10:40
@dfunkt
Copy link
Contributor Author

dfunkt commented Sep 9, 2024

@BlackDex Not sure if this is what you meant, but that's all I could come up with. I'm not particularly familiar with Rust (or programming in general tbh).

Copy link
Collaborator

@BlackDex BlackDex left a comment

Choose a reason for hiding this comment

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

Yes, that is what i mend indeed.

I just noticed something else too. Not that important, but no need to create new variables for those items actually.

src/mail.rs Outdated Show resolved Hide resolved
src/mail.rs Outdated Show resolved Hide resolved
- match Bitwarden behaviour
- add a different segment in mails for Device Name
src/mail.rs Show resolved Hide resolved
src/mail.rs Show resolved Hide resolved
src/mail.rs Show resolved Hide resolved
@dani-garcia dani-garcia merged commit 21efc08 into dani-garcia:main Sep 18, 2024
5 checks passed
@dfunkt dfunkt deleted the email-device-type branch September 18, 2024 17:59
@gbe0
Copy link

gbe0 commented Sep 19, 2024

With this merged I get the following on startup:

[2024-09-19 10:17:36.721][panic][ERROR] thread 'main' panicked at 'Error running migrations: QueryError(DieselMigrationName { name: "2024-09-04-091351_use_device_type_for_mails", version: MigrationVersion("20240904091351") }, DatabaseError(Unknown, "syntax error at or near \"`\""))': src/db/mod.rs:495
   0: vaultwarden::init_logging::{{closure}}
   1: std::panicking::rust_panic_with_hook
   2: std::panicking::begin_panic_handler::{{closure}}
   3: std::sys::backtrace::__rust_end_short_backtrace
   4: rust_begin_unwind
   5: core::panicking::panic_fmt
   6: core::result::unwrap_failed
   7: vaultwarden::db::DbPool::from_config
   8: vaultwarden::main::{{closure}}
   9: vaultwarden::main
  10: std::sys::backtrace::__rust_begin_short_backtrace
  11: main
  12: <unknown>
  13: __libc_start_main
  14: _start

My DB is PostgreSQL 16.4 on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit.

I rolled back and there are no issues.

BlackDex pushed a commit to BlackDex/vaultwarden that referenced this pull request Oct 5, 2024
- match Bitwarden behaviour
- add a different segment in mails for Device Name
@Gerardv514
Copy link

@dfunkt i just checked this out. I have an iOS device and just tried to login to the web vault using Google chrome iOS app, i closed out on the 2fa page which prompted the 2fa incomplete notification. Device type and device name both say safari, is that normal?

@dfunkt
Copy link
Contributor Author

dfunkt commented Oct 5, 2024

I think that might be due to Chrome using the same browser engine as Safari on iOS. I expect this happens with Bitwarden as well, but I don't have any iOS devices in order to test my theory.

TL;DR: I think this is expected

@Gerardv514
Copy link

I also attempted the iOS bitwarden app, and device name was iPhone 15,2 and device type was iOS.

So as you said probably normal due to browser not passing the info along.

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.

6 participants