redwoodjs / learn.redwoodjs.com

Multilingual docs site for learning RedwoodJS
https://learn.redwoodjs.com/
55 stars 56 forks source link

Netlify Authentication Discussion - Auth Token update #85

Closed jacebenson closed 3 years ago

jacebenson commented 3 years ago

I ran through the tutorial from beginning to deployment the other day and noted that the Auth Docs bit token needs an update. ) doesn't line up with the content form the invite email. Netlify no longer emails a link ending in #invite_token, instead it's a link like this;

https://mandrillapp.com/track/click/31128206/stoic-knuth-4c4640.netlify.app?p=eyJzIjoiVXprcy1JSEhUckhhWkNEM1d1VlZfM0FkazlFIiwidiI6MSwicCI6IntcInVcIjozMTEyODIwNixcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvc3RvaWMta251dGgtNGM0NjQwLm5ldGxpZnkuYXBwXFxcLyNpbnZpdGVfdG9rZW49V0dTRW5BWUR3OGE0X3k5RXFpN29wUVwiLFwiaWRcIjpcImQ0YTdlM2RjMjVhNjRmMDZiOWRjMTA0NzE5NGZlYmM1XCIsXCJ1cmxfaWRzXCI6W1wiOWViNjRkZGFlMTdmMmRiODA2ZDY0ZDk0OTY0MTFkODRkZTAzNTY3Y1wiXX0ifQ

If you copy the p attribute and base64 decode it, and parse it, you get an object like so;

{
    "s": "Uzks-IHHTrHaZCD3WuVV_3Adk9E",
    "v": 1,
    "p": "{\"u\":31128206,\"v\":1,\"url\":\"http:\\/\\/stoic-knuth-4c4640.netlify.app\\/#invite_token=WGSEnAYDw8a4_y9Eqi7opQ\",\"id\":\"d4a7e3dc25a64f06b9dc1047194febc5\",\"url_ids\":[\"9eb64ddae17f2db806d64d9496411d84de03567c\"]}"
}

You can see the #invite_token in there but it's not as clear.

I tried using the ?p=eyJzIjoiVXprcy1JSEhUckhhWkNEM1d1VlZfM0FkazlFIiwidiI6MSwicCI6IntcInVcIjozMTEyODIwNixcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvc3RvaWMta251dGgtNGM0NjQwLm5ldGxpZnkuYXBwXFxcLyNpbnZpdGVfdG9rZW49V0dTRW5BWUR3OGE0X3k5RXFpN29wUVwiLFwiaWRcIjpcImQ0YTdlM2RjMjVhNjRmMDZiOWRjMTA0NzE5NGZlYmM1XCIsXCJ1cmxfaWRzXCI6W1wiOWViNjRkZGFlMTdmMmRiODA2ZDY0ZDk0OTY0MTFkODRkZTAzNTY3Y1wiXX0ifQ on my localhost but that did not seem to work for me.

My proposal

But if you look at the URL it will end in something like #invite_token=6gFSXhugtHCXO5Whlc5V. Copy that (including the #) and append it to your localhost URL:

Becomes

But if you look at the URL it will end in ?p=SOMELONGSTRING. Copy that p value and paste it into your favorite base64 decoder (or this if you dont know https://codebeautify.org/base64-decode) look in the payload for the #invite_token=SOMEOTHERSTRING. Copy that (including the #) and append it to your localhost URL http://localhost:8910/#invite_token=6gFSXhugtHCXO5Whlc5Vg

jacebenson commented 3 years ago

Looking furhter at the email source I can see the original link for the content-type: text/plain

Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

== You have been invited ==

 You have been invited to create a user on
http://stoic-knuth-4c4640.netlify.app. Follow this link to accept the
invite:

 Accept the invite
<http://stoic-knuth-4c4640.netlify.app/#invite_token=WGSEnAYDw8a4_y9Eqi7opQ>
--_av-XVwmRfiJpPU41Sb7hJ6yjg
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit

<h2>You have been invited</h2>

<p>You have been invited to create a user on http://stoic-knuth-4c4640.netlify.app. Follow this link to accept the invite:</p>
<p><a href="https://mandrillapp.com/track/click/31128206/stoic-knuth-4c4640.netlify.app?p=eyJzIjoiVXprcy1JSEhUckhhWkNEM1d1VlZfM0FkazlFIiwidiI6MSwicCI6IntcInVcIjozMTEyODIwNixcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvc3RvaWMta251dGgtNGM0NjQwLm5ldGxpZnkuYXBwXFxcLyNpbnZpdGVfdG9rZW49V0dTRW5BWUR3OGE0X3k5RXFpN29wUVwiLFwiaWRcIjpcImQ0YTdlM2RjMjVhNjRmMDZiOWRjMTA0NzE5NGZlYmM1XCIsXCJ1cmxfaWRzXCI6W1wiOWViNjRkZGFlMTdmMmRiODA2ZDY0ZDk0OTY0MTFkODRkZTAzNTY3Y1wiXX0ifQ">Accept the invite</a></p><img src="https://mandrillapp.com/track/open.php?u=31128206&id=d4a7e3dc25a64f06b9dc1047194febc5" height="1" width="1">
--_av-XVwmRfiJpPU41Sb7hJ6yjg--
cannikin commented 3 years ago

Did you try clicking the link in the email? That should open the browser, follow the crazy mandrillapp.com link, then redirect to the “plain” URL where you can just copy the invite token from the address bar.

That’s what we tell people to do in the tutorial itself, were you trying to cheat? ;)

jacebenson commented 3 years ago

I misread the first thing to do. Go find that and click the accept the invite link I must have thought it said "find that and copy that link"