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

Second device login? #5

Closed
csterritt opened this issue Aug 7, 2021 · 5 comments
Closed

Second device login? #5

csterritt opened this issue Aug 7, 2021 · 5 comments

Comments

@csterritt
Copy link

Hi -- first, thanks for doing devise-passwordless! It's a cool thing, and seems to work.

I have a use case that doesn't appear to work:

  1. I'd like to bring up the page on device 1, on which I don't have email.
  2. I'd like to put in my email, and get a link emailed to me.
  3. I'd like to read the email, and click the link, on device 2 which does have email.
  4. I'd like the session on device 1 to the be validated. It's fine if it's valid for device 2 as well.

Any clues appreciated -- Thanks!

@abevoelker
Copy link
Owner

That sounds like an interesting UX. Obviously the gem isn't built to accommodate that at the moment.

Off the cuff I think you could accomplish something like that by having the Rails server store some kind of nonce session value (think SecureRandom.base58(50)) on Device 1's cookie when Device 1 initiates the login request, and attach that nonce value to the link that gets generated and emailed. Device 1 would then busy poll an endpoint that will convert its cookie into a logged-in cookie (Devise's sign_in helper) when Device 2 visits the magic link.

Maybe there's an easier way I'm not thinking of but that's one way. You'd want to be careful your busy wait endpoint isn't vulnerable to timing attacks or things of that nature

@csterritt
Copy link
Author

csterritt commented Aug 9, 2021

Thanks @abevoelker! Good ideas. I think I may try implementing my own ideas; I don't need all the "weight" of Devise for this, as it's a (very) simple application. And, yeah, I think I'll just have it say, "Refresh this page once you've clicked the email link" to avoid a busy-wait.

Up to you if you want to close this.

@csterritt
Copy link
Author

For the record, this was inspired by a web exercise app, that let me log in to (for example) a smart-TV browser that I didn't have email set up on (nor would I want to). I also don't have email set up on my tablet.

@abevoelker
Copy link
Owner

@csterritt Got it, yeah that use case makes perfect sense then. If you don't want the full weight of Devise but want something a little more useful than session variables, you could write a Warden strategy (Devise is built on top of Warden if you didn't know). Devise requires Rails but Warden works with any Rack app. I found this RailsConf video to be a useful primer on Warden when writing this gem if you go that route.

Closing this for now since it doesn't pertain to the gem. Good luck to you on your project

@csterritt
Copy link
Author

csterritt commented Aug 10, 2021 via email

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

No branches or pull requests

2 participants