As this example relies on Firebase authentication you must have a Firebase project and a SAML identity provider:
- Set up your SAML IDP (for a broad overview see CloudFlare's article)
- Go to Firebase's website
- Follow Firebase's instructions for setting up your project
- Enable SAML in the Google Cloud console as shown here (Firebase is run in the backend by Google cloud, we have to use the Google Cloud console because Firebase does not expose this option)
- Use the Provider ID you got in the last step to replace the example ID in backend/firebase-wrapper-app.html on the line that says "!!!!!PUT YOUR PROVIDER ID HERE!!!!!"
- Get your Firebase configuration
- Add that configuration to App.js and to firebase-wrapper-app.html on the lines that say "Add Firebase configuration here"
- Run
yarn
ornpm install
- Run
yarn start
ornpm run start
in the root directory to start the development server.
Firebase does not support SAML (or any popup/redirect) login in React Native, nor in any webview components. However through the use of a web server and dummy page we can give firebase the https protocol it is looking for, authenticate the user in that page, and then pass the auth token back to our app. Using that token we can then log the user in.
Because the request must be made from a dummy webpage you need to host the page found in the example's 'backend' directory on a public webserver. As you are already using Firebase, it may be easiest to use Firebase Hosting, otherwise you can use a web host of your choice. During development however you can run the serve
script defined in package.json using npm serve
or yarn serve
Tested on the Expo Go app for iOS and in an Android emulator. This example could theoretically be modified to work on the web as well.