-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Implement "login with device" #3592
Conversation
52e060c
to
3cb534b
Compare
Logging in on mobile, and approving on mobile also works fine now over mobile push notifications. Somehow it only works when my timezone of the approving device (all platforms) is on UTC. I need to check which timestamp format is expected. |
Ok, most things are working now, still missing:
@BlackDex, as I understand, Since no user has the new anonymous hub endpoint in their proxy, there does not need to be a similar separate server for the anonymous hub right? Just using rocket to handle it should be enough. (Currently this PR only handles the anonymous hub connections over rocket). |
The current rewrite rule looks like this according to https://github.com/dani-garcia/vaultwarden/wiki/Proxy-examples:
I believe this rule is incorrect, because
So how would the ws server differentiate between this connection and yours? If we were to analogously use a rewrite rule
the web socket server would either retrieve P.S.: It seems that all proxy examples only send data to the root of the websocket connection. So I have no idea how |
The current main/testing version doesn't need a separate port anymore. So all can go via the main port now. Also, the negotiate endpoint doesn't exist anymore for a long time already. We kept it for a while because of backwards compatibility, but it can be removed now i think.
In general, we tend to fully remove the old port. But not yet next release, at least not for the web-socket notifications just yet. |
Thanks for the reply.
Right, but I didn't see a description how to reverse proxy this, nor how this is activated in the config. Or maybe I missed it.
Good to know. Thanks.
Right, I understand that. So only the query string is "forwarded" to the |
You do not need any proxy rewrite rules. Not for the regular WebSocket hub and not for the new, anonymous hub. The rewrite rule was needed for the WebSocket endpoint on port 3012 (and still works for compatibility) but you do not need it anymore. At least using Traefik, it just works out of the box for this PR. I'm not sure whether you have to enable WebSocket support on other proxies.
To establish the WebSocket connection, first a HTTP GET request is made to wss://my.bitwarden.server.com/notifications/anonymous-hub?Token=UUID The Vaultwarden internal routing is done by rocket, thus |
This is exactly my point. I am using
So what happens is, if a request is sent to the proxy
The proxy makes this request to the backend:
P.S.: It's the same with the nginx rules on the wiki page. Same behavior. |
Yes, this was necessary as rocket did not have built in websocket support before. The port 3012 endpoint is dedicated to only the websocket hub, that's why the path is not necessary. Vaultwarden internally has 2 ways to process the websocket notifications, once via the old 3012 endpoint (ws://server:3012/notifications/hub, and once via the rocket endpoint (ws://server:80/notifications/hub).
Exactly, since 127.0.0.1:3012 in this case is vaultwarden's dedicated TCP port, only for websockets, no path is needed. Now that Rocket websocket support is merged, this rewrite is not required.
For the anonymous hub of this PR, only rocket notifications are supported. So if you want to rewrite, you would have to use something like my example, but as I said, I don't think any rewrite rules are necessary beyond what's needed to get the HTTP requests to vaultwarden. |
I am still not sure what the correct way is. So let's say I want to use the "new" way of things. How do I set:
and then no more rewrite stuff in Apache? Maybe we should add a wiki page for that, because these 2 ways of doing notifications is a bit strange when we use both of them at the same time. |
I think what you describe should work, although I have not tested with Apache yet. I have removed my WebSocket proxy rule from traefik, and set WEBSOCKET_ENABLED to false and the notifications still work.
Well, there is https://github.com/dani-garcia/vaultwarden/wiki/Enabling-WebSocket-notifications, but I think the page can be removed entirely in the future since WebSockets do not require special proxy configuration anymore. |
That page can indeed be removed in the future. |
I think that is a good idea. I also think we might still need rewrite rules: Anyway, I'll stop spamming this PR with my questions. I guess I should start a discussion instead... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll probably want to remove the "copy" part from the migration folder, right?
@BlackDex just asking, would this be a feature that will be in next release? Would be nice, as we have the other push notification part ready! |
From my side this is mostly done. I didn't have time yet to test on postgresql or mysql yet though. Also beware that on the current vaultwarden web-build it will not show the option (all other clients do still immediately benefit from it though, desktop, browser-extension, and mobile), that will only be the case in the next version of the web-build. |
93fe8cd
to
6281e6b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is finished? Maybe rebase your changes? I'll gladly test your changes once this is done
@GeekCornerGH, yes, pretty much. It is now up-to-date with the latest main branch. I still had to test on mariadb and postgres, which is now done. The postgres migration had an incorrect type, which is now fixed. Other than that it is also working on mariadb / postgres. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested against Chrome Extension v2023.5.1 and Windows Desktop app v2023.5.1
@dani-garcia does this look good to you? |
mind sharing which traefik rules you remove ? is this enough ?
|
@qymab I created a discussion How to reverse proxy websockets? People might rather read discussions than PR comments, so I believe you have a better chance to get an answer there. I haven't used traefik for a while, so I won't be of much help. I don't know if traefik needs a directive to upgrade connections or if this is done automatically. But if you are only removing these 3 lines, websockets still only exist for path |
5026418
to
04d551a
Compare
04d551a
to
85eba6f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I have done some checks, and it seems to work for the most part.
There are some changes which can be removed, and there are some additions needed.
I have not looked yet at the layout of the code if there could be some improvements there.
But the changes i mentioned can be addressed already i think :).
Ok, I found a few more items. Anyway, not that important i think. Looks good overall from my opinion. |
@quexten, Ok this looks good to me. The only thing I would like is to have this PR squashed into one commit to keep the history a bit cleaner. |
c1331e7
to
212b20c
Compare
Done. |
212b20c
to
8d7b3db
Compare
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [vaultwarden/server](https://togithub.com/dani-garcia/vaultwarden) | stage | patch | `1.29.1-alpine` -> `1.29.2-alpine` | --- ### Release Notes <details> <summary>dani-garcia/vaultwarden (vaultwarden/server)</summary> ### [`v1.29.2`](https://togithub.com/dani-garcia/vaultwarden/releases/tag/1.29.2) [Compare Source](https://togithub.com/dani-garcia/vaultwarden/compare/1.29.1...1.29.2) Minor release to fix an issue forcing user to set amaster password when logging in even when it's already set #### What's Changed - Fix .env.template file by [@​BlackDex](https://togithub.com/BlackDex) in [https://github.com/dani-garcia/vaultwarden/pull/3734](https://togithub.com/dani-garcia/vaultwarden/pull/3734) - Fix UserOrg status during LDAP Import by [@​BlackDex](https://togithub.com/BlackDex) in [https://github.com/dani-garcia/vaultwarden/pull/3740](https://togithub.com/dani-garcia/vaultwarden/pull/3740) - Update images to Bookworm and PQ15 and Rust v1.71 by [@​BlackDex](https://togithub.com/BlackDex) in [https://github.com/dani-garcia/vaultwarden/pull/3573](https://togithub.com/dani-garcia/vaultwarden/pull/3573) - Implement "login with device" by [@​quexten](https://togithub.com/quexten) in [https://github.com/dani-garcia/vaultwarden/pull/3592](https://togithub.com/dani-garcia/vaultwarden/pull/3592) - chore: Bump web vault to v2023.7.1 and bump Rust by [@​GeekCornerGH](https://togithub.com/GeekCornerGH) in [https://github.com/dani-garcia/vaultwarden/pull/3769](https://togithub.com/dani-garcia/vaultwarden/pull/3769) - Optimized Favicon downloading by [@​BlackDex](https://togithub.com/BlackDex) in [https://github.com/dani-garcia/vaultwarden/pull/3751](https://togithub.com/dani-garcia/vaultwarden/pull/3751) - add UserDecryptionOptions to login response by [@​stefan0xC](https://togithub.com/stefan0xC) in [https://github.com/dani-garcia/vaultwarden/pull/3813](https://togithub.com/dani-garcia/vaultwarden/pull/3813) - add new secretsmanager plan for web-v2023.8.x by [@​stefan0xC](https://togithub.com/stefan0xC) in [https://github.com/dani-garcia/vaultwarden/pull/3797](https://togithub.com/dani-garcia/vaultwarden/pull/3797) - Allow Authorization header for Web Sockets by [@​BlackDex](https://togithub.com/BlackDex) in [https://github.com/dani-garcia/vaultwarden/pull/3806](https://togithub.com/dani-garcia/vaultwarden/pull/3806) - Update admin interface by [@​BlackDex](https://togithub.com/BlackDex) in [https://github.com/dani-garcia/vaultwarden/pull/3730](https://togithub.com/dani-garcia/vaultwarden/pull/3730) **Full Changelog**: dani-garcia/vaultwarden@1.29.1...1.29.2 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "on saturday" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/arthurgeek/vaultwarden-fly-template). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi42OC4xIiwidXBkYXRlZEluVmVyIjoiMzYuNjguMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [vaultwarden/server](https://togithub.com/dani-garcia/vaultwarden) | stage | patch | `1.29.1-alpine` -> `1.29.2-alpine` | --- ### Release Notes <details> <summary>dani-garcia/vaultwarden (vaultwarden/server)</summary> ### [`v1.29.2`](https://togithub.com/dani-garcia/vaultwarden/releases/tag/1.29.2) [Compare Source](https://togithub.com/dani-garcia/vaultwarden/compare/1.29.1...1.29.2) Minor release to fix an issue forcing user to set amaster password when logging in even when it's already set ##### What's Changed - Fix .env.template file by [@​BlackDex](https://togithub.com/BlackDex) in [https://github.com/dani-garcia/vaultwarden/pull/3734](https://togithub.com/dani-garcia/vaultwarden/pull/3734) - Fix UserOrg status during LDAP Import by [@​BlackDex](https://togithub.com/BlackDex) in [https://github.com/dani-garcia/vaultwarden/pull/3740](https://togithub.com/dani-garcia/vaultwarden/pull/3740) - Update images to Bookworm and PQ15 and Rust v1.71 by [@​BlackDex](https://togithub.com/BlackDex) in [https://github.com/dani-garcia/vaultwarden/pull/3573](https://togithub.com/dani-garcia/vaultwarden/pull/3573) - Implement "login with device" by [@​quexten](https://togithub.com/quexten) in [https://github.com/dani-garcia/vaultwarden/pull/3592](https://togithub.com/dani-garcia/vaultwarden/pull/3592) - chore: Bump web vault to v2023.7.1 and bump Rust by [@​GeekCornerGH](https://togithub.com/GeekCornerGH) in [https://github.com/dani-garcia/vaultwarden/pull/3769](https://togithub.com/dani-garcia/vaultwarden/pull/3769) - Optimized Favicon downloading by [@​BlackDex](https://togithub.com/BlackDex) in [https://github.com/dani-garcia/vaultwarden/pull/3751](https://togithub.com/dani-garcia/vaultwarden/pull/3751) - add UserDecryptionOptions to login response by [@​stefan0xC](https://togithub.com/stefan0xC) in [https://github.com/dani-garcia/vaultwarden/pull/3813](https://togithub.com/dani-garcia/vaultwarden/pull/3813) - add new secretsmanager plan for web-v2023.8.x by [@​stefan0xC](https://togithub.com/stefan0xC) in [https://github.com/dani-garcia/vaultwarden/pull/3797](https://togithub.com/dani-garcia/vaultwarden/pull/3797) - Allow Authorization header for Web Sockets by [@​BlackDex](https://togithub.com/BlackDex) in [https://github.com/dani-garcia/vaultwarden/pull/3806](https://togithub.com/dani-garcia/vaultwarden/pull/3806) - Update admin interface by [@​BlackDex](https://togithub.com/BlackDex) in [https://github.com/dani-garcia/vaultwarden/pull/3730](https://togithub.com/dani-garcia/vaultwarden/pull/3730) **Full Changelog**: dani-garcia/vaultwarden@1.29.1...1.29.2 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "on saturday" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/arthurgeek/vaultwarden-fly). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi42OC4xIiwidXBkYXRlZEluVmVyIjoiMzYuNjguMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@stefan0xC I don't know where the problem is either. There will be the error mentioned above on the phone, and there will be no error reported on the desktop, but the login has not been successful. |
I'm just testing Login with Device. The first attempt to log in on my browser, no notification came up on my phone. I had to go into settings and into Pending Login Requests. I confirmed and it let me in. |
I apologize in advance before "someone" bites my head off. I don't know if this is the right place to point it out given the many duplicate reports surrounding this topic, but I'll try anyway. I have noticed that "login with device" does not work if your device is still on iOS 14. In fact I still have my iPhone running iOS 14 and there "login with device" does not work. If I then try this with a device that has iOS 16, and with the Bitwarden app reinstalled it does work. But if I then want to use this again the next day it no longer works. When I log out of the iOS 16 app and log back in then it works again. By the way this is not the case with iOS 14, there this does not help, neither log out or reinstall the app. |
If you would have read all those duplicate reports, you would have seen that updating to the |
HAHAHA I didn't expect any other answer from you.... |
Amazing work implementing device login so quick. |
This is behaviour is dictated by upstream (bitwarden). It works the same on vault.bitwarden.com. Since vaultwarden aims to be compatible with upstream, if you want this feature you would need to bring it up with bitwarden instead. |
When I click "Confirm login" on the desktop app to approve the login request made for example from the web vault, it fails and in the log I see this line
|
@mada199122 this has already been fixed in #3831 (currently available in |
Ah ok thank you!!! |
This is a very WIP pull-request for login-with-device. To run this, you need a new client version, for the web client this is 2023.06 (or latest master as of today) since login-with-device was disabled for self-hosted installations previously.
Basic login-with-device on WebSocket clients (desktop/web/webextension) works, but there is still quite some work to be done.
Screencast from 2023-06-17 23-53-39.webm
This PR implements a few components to make the login-with-device work, each still partially incomplete.
Aside from the points missing mentioned above, mobile push is not implemented yet, and a lot of code clean-up needs to be done.
Feel free to comment general comments, keep in mind the PR is very WIP so a lot of parts are missing and there is a lot of clean-up to be done.
I will squash the PR when it is done.