In OAuth2.0
we have to send client id and secret along side the user credential to obtain an access token from an authorization server. We have a ReactJS
web application that needs to send its request to API gateway (Main API), but problem arise when the web application wants to store the client secret for its requests:
In this scenario I am totally aware that storing the secret on web app would expose the secret to the WILD internet and everyone can create a new application from ground up and sends it request to API gateway.
What I came up with is to create a middleware gateway on server that would store the secret and its whole functionality would be to get an access token from API gateway by its secret and the client id which is given by ReactJS
web application.
The whole responsibility of
Secret Holder
is that it just keep the secret for the web application and obtain an access token for the ReactJS
app.
I've gone through all the questions below but could not satisfy myself to design an extra module for just serving access token for the web:
https://stackoverflow.com/questions/47101583/react-native-how-to-securely-store-api-client-secrets
https://stackoverflow.com/questions/1934187/oauth-secrets-in-mobile-apps
https://stackoverflow.com/questions/32894921/where-to-store-refresh-token-and-client-secret-safely
In the future we would definitely have iOS
& Android
applications too.
How do you guys handle your client id & secret in your web applications? Is the 2nd scenario good enough or is there a best practice that I'm unaware of?
I would appreciate if anyone could shed some light on this question.
Authorization Code Grant
which does not make sense when the application is owned by myself. I cannot redirect user to another page and then ask for permission grant!API Gateway
in place of ourReact Web Application
. The application is a social networking application that in the future will expose itsREST API
to third parties through client id and secret (paid plan). But if they already have access to secret key, then exposing API to 3rd parties means useless, as they can do whatever they want with theAPI Gateway
.