Hi everyones,
My goal in one sentence:
Find an existing user in my API database from a verified JWT access token
(I mean here : Find the user who send the current request)
What I have done and it works :
I have a basic web application where my frontend ask for an accessToken and store it into the local storage.
const accessToken = await this.auth0Client.getTokenSilently();
localStorage.setItem('accessToken', accessToken);
Then this token is inserted as an authorization header with all the requests sended to my personal API
I also added a rule into the auth0 web interface, thus I can retreive the email into the accessToken.
function (user, context, callback) {
context.accessToken['https://mynamespace.com/email'] = user.email;
context.accessToken['https://mynamespace.com/email_verified'] = user.email_verified;
return callback(null, user, context);
}
All of this works but seems complicated to me, I feel I am missing some points here, am I ?
Is this follow the best practices ?
I have read here it is not a good practice to store email into access token, is that true ?
Thank you for your answers !