auth0.js icon indicating copy to clipboard operation
auth0.js copied to clipboard

Universal Apps need to verify the token on the server side

Open JohnCoding94 opened this issue 9 years ago • 4 comments

As there are more and more universal applications, i think it is an important feature to be able tu use the lib on the server side.

At least to perform the parseHash method when invoking the /callback, an univesal app needs to verify the token and to apply to most appropriate redirect on the server side instead of rendering a spinner until the job can be done from the browser.

JohnCoding94 avatar Aug 01 '17 14:08 JohnCoding94

Can universal apps hide your auth0 secret effectively?

luisrudge avatar Aug 01 '17 14:08 luisrudge

No, but i don't get the point... How the ability to perform some tasks on the server side that can be already performed on the client side could be a breaking change in credentials privacy (just to be sure we share the same vision, in Universal Apps we are in SPA workflow)?

JohnCoding94 avatar Aug 01 '17 15:08 JohnCoding94

You can decode the token in the client. But, to verify the token, you need auth0's secret (which you can find in the dashboard). If you leak this secret, which will happen if you try to verify the token in a universal app, anyone could issue a token pretending to be your server or make calls pretending to be your client (both are super bad). So, you can decode, but you can't verify.

So, we try to be universal apps friendly, in a way that we don't blow up when you server render your app. But you shouldn't actively use the library when you're server rendering because we use browser specific code to handle localStorage, redirects, iframes etc. About the token verification, it's just a security vector and we won't compromise in that sense. I hope you understand 🎉

luisrudge avatar Aug 01 '17 15:08 luisrudge

You should not use the client secret to verify the token. You should use RS256 and use the public key which is a more secure approach (only Auth0 can generate RS256 tokens and both client and server can safely verify these)

sandrinodm avatar Aug 09 '17 10:08 sandrinodm