sure. this is actually a nice use case:
I sent an email to a new user with a link. this link contains a base64 hashed object with some data (name , email, role etc) and one spacial key with some of that data encrypted.
the link looks like this:
http://localhost:4200/auth/passwordless?p=eyJjb2RlIjoiYzI5YjdhZTcxMWZjY2YxZDBjYWU4N2ZjNzllMmVhMjk1YmU3YTJlMGQxNjcwMWQxMGY5ZDMxOTU1YjQ3N2YxZSIsImVtYWlsIjoicm9lZUBjeXBhZ28uY29tIiwiZW50aXR5IjoiMTQwZjJhM2MtNDVmOC00YWM3LWJlZTEtMjNhZWRmYjUwYjI2IiwiaWQiOiI2YjVhZGQ4Ny04MDg3LTQzN2UtYWE3MC1kZDE3Njk1MmY2YjYiLCJvcmdhbml6YXRpb24iOiJvcmdfa1JUTmJybWVKRldYYUNwVCIsInR5cGUiOiJ1YXIiLCJ1c2VyQWNjZXNzUmV2aWV3ZXJJZCI6I
once I open the base64 string I get my obj:
{
"code": "c29b7ae711fccf1d0cae87fc79e2ea295be7a2e0d16701d10f9d31955b477f1e",
"email": "roee@someemail.com",
"id": "XXX-XXX-437e-aa70-dd176952f6b6",
"YYY": "XXX",
"XXX": "XXXX",
...
}
On the passwordless page in my app I use the webAuth and send the fist email to the user. somthing like that:
this.webauth.passwordlessStart(
{
connection: "email",
send: "code",
email: email,
// authParams: authParams,
},
and the authParams will contain my object
The main idea was to use the " Pre User Registration" flow to verify the the object was not changed on the way.
Something like:
const crypto = require("crypto");
const base64Obj = // get my data from the request
const stringToHash = base64Obj.XXX + base64Obj.YYY + base64Obj.id + base64Obj.email;
// Calling createHash method
const hash = crypto.createHmac('sha256', event.secrets.PASSWORDLESS_SECRET)
// updating data
.update(stringToHash)
// Encoding to be used
.digest('hex');
if (hash !== base64Obj.code) {
api.access.deny('some error msg', event);
}
in this case I prevent the creation of the user .
Unfortunately, I was unable to pass parameters to this action, or read anything from there. I tried to use redirect_url or additional parameters defined in the connection but without successץ
now I have to sign him up. and make this validation in the Post Login flow, and delete the user if something went wrong.
This is bad in a lot of ways, since I dont want to create the user in the first place (if someone is trying to attack me), and since I am using so auth0 management scripts this also cost me with rate limit
is that making sense now?
Thanks for reading all of this, and for taking the time to help