I’m getting an AxiosError {message: 'Network Error', name: 'AxiosError', code: 'ERR_NETWORK',...},
which is probably related to a CORS error on my request to my Auth0 API call.
I need to request my own API token from Auth0 in order to authenticate to my own database. However the CORS error below:
XMLHttpRequest at 'https://{tenant}.us.auth0.com/oauth/token' from origin 'http://localhost:8080' has been blocked by CORS policy: Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response.
is what I get.
NOTE: I already added multiple URL links to my allow list including a lot of urls such as: https://auth0.com/, https://auth0.com/, https://{tenant}/oauth/token, https://{tenant}.us.auth0.com/api/v2/ to the Allowlist for URL Fetching Domains and Allowlist panel Urls
My only thoughts on the points of error would be either on how my post request is defined, which I find hard to believe because I took it straight from the docs:
Thats taken straight from their documentation. Thanks for the insight, I later figured that would be the problem too, however I wasn’t sure how to fix it. Thanks for the tip tho. Does the twitch extension add the access-control-allow-origin to all calls outgoing, and therefore being blocked by auth0?
However I fixed this by not going through Auth0.
I’m using passport now passport-http-bearer
Thank you for the amazing feedback Barry! As always.
Sounds good, if the ClientIDs considered public, I won’t worry too much about that.
As you said, I’ll move my secrets to the server side.
I haven’t heard of requestIDShare, it might help me when implementing my login/auth. The reason I needed to Authenticate a user is because I want to protect/secure my public api on my server. I’m creating a user/pass authentication system, to request an accesstoken. This accesstoken will be used to authenticate and hit the backend api, and get/set data based on the user who is authenticated. I have the system mostly set up to generate accesstokens for users, I just need to move my secrets to the backend.
This issue can now be closed. I’ll reach out if I need more help. I appreciate the conversation about security.
This might help me save alot of time. I have to look into this more to get an understanding of the
Then validate the JWT with your extension secret.
If what you are saying is true, then the extension secret would live on the backend, so I can protect my calls from my frontend to the backend. I’ll have to look into that verification process.
At that point I can dish out my own access-tokens? Thats still something I would have to build (already built)
There should be a suitable lib for your langauge of choice check out https://jwt.io/ for a list of libs and general information.
Theres no need imo, just use the JWT with all calls saves the overheard of any faff with “a second token” or having to pass that token down to the extension to use. Just use the JWT for all calls.
There should be a suitable lib for your langauge of choice check out https://jwt.io/ for a list of libs and general information.
Awesome I’ll check that out
just use the JWT with all calls
I see… so post-verify, we should just allow the api call to go through after that. Duh! Haha. It makes sense now, I’ll probably have to do some thinking till I feel 100% on it but it makes sense.
I successfully passed the JWT token to the backend as a header, and decoded it with the secret.
However, I have a question, what’s stopping someone from getting the JWT token from the exchange between the frontend to the backend, and then using that to call my api?