Node-1st-gen/authorized-https-endpoint/README.md
This samples shows how to restrict an HTTPS Function to only the Firebase users of your app.
Only users who pass a valid Firebase ID token as a Bearer token in the Authorization header of the HTTP request or in a __session cookie are authorized to use the function.
Checking the ID token is done with an ExpressJs middleware that also passes the decoded ID token in the Express request object.
Once authorized the function respond with Hello <username>.
This sample comes with a simple web-based UI whose code is in public directory that lets you sign-in Firebase and initiates an authorized XHR to the Function.
authorized-https-endpoint directory.npm install -g firebase-tools and then configure it with firebase login.firebase use --add and select your project in the list.cd functions; npm install; cd -This sample comes with a web-based UI for testing the function. To test locally do:
firebase serve --only hosting,functionshttp://localhost:5000.To deploy and test on prod do:
firebase deployfirebase open hosting:site, this will open a browser.We'd love that you contribute to the project. Before doing so please read our Contributor guide.
© Google, 2017. Licensed under an Apache-2 license.