(This article, originally published on Auth0.com, is reprinted with permission.)
This two-part tutorial demonstrates building a secure application using Auth0 for authentication, a Node.js backend, and an Angular frontend. The application will also securely authenticate with a Firebase Cloud Firestore database using custom tokens, enabling users to post real-time comments after logging in via Auth0.
The Angular application code is available on GitHub at angular-firebase, and the Node API is at firebase-auth0-nodeserver.
Part 1: Securing Firebase and Angular with Auth0
This tutorial covers:
Firebase and Auth0: A Synergistic Approach
Firebase, a Google-owned platform, offers cloud-hosted NoSQL databases (Realtime Database and Cloud Firestore) with real-time capabilities. Auth0 is a cloud-based platform providing authentication and authorization as a service, simplifying the implementation of secure login and authorization in applications.
Why Auth0 with Firebase?
While Firebase offers built-in authentication, integrating Auth0 with custom tokens provides several advantages:
Use Firebase's built-in authentication if:
Consider Auth0 with custom Firebase tokens if:
Application Overview: Popular Dogs
This tutorial builds a Node.js API (secured by Auth0) that mints Firebase custom tokens and returns data on dog breeds. An Angular frontend ("Popular Dogs") displays information about popular dog breeds, secured by Auth0. The app fetches dog data and Firebase tokens from the API, allowing users to add/delete real-time comments in Cloud Firestore. The app utilizes shared modules and lazy loading.
Prerequisites:
(The remainder of the tutorial details setting up the Angular CLI, Auth0 client and API, the Firebase project, the Node API, the Angular app architecture, shared modules, routing, lazy loading, components, authentication logic, and core application logic, similar to the original article. Due to the length, it's not feasible to reproduce the entire code here. Refer to the provided GitHub links for complete code examples.)
Conclusion:
This first part establishes the foundation. Part 2 will cover displaying dog data and implementing real-time comments with Firebase. Additional resources on testing, Firebase, Auth0, and Angular are linked in the original article.
The above is the detailed content of Authenticating Firebase and Angular with Auth0: Part 1. For more information, please follow other related articles on the PHP Chinese website!