User Authentication
Relevant source files
The following files were used as context for generating this wiki page:User Authentication is a critical feature of the HomeSecurity system, handled primarily by the companion Android application and the Firebase cloud backend. Its purpose is to secure access to the client-side interface, ensuring that only authorized users can receive alerts, view the live video stream, and manage the system. The authentication mechanism is decoupled from the ESP32 edge device, which operates independently of user sessions.
The authentication process is managed entirely within the Cloud and Client tiers of the system architecture. This separation allows the ESP32 to focus on its core responsibilities of sensor data acquisition and local processing, while leveraging a robust, scalable, and secure cloud service for user management.
Sources: HomeSecurity/README.md:31-35, 41-69, 99-104
System Architecture for Authentication
The project follows a three-tier architecture where user authentication is a responsibility of the Client and Cloud tiers, not the Edge tier (ESP32).
| Tier | Component | Role in Authentication |
|---|---|---|
| Client | Android App | Provides the user interface for login (Login Screen) and manages the user's authenticated state. |
| Cloud | Firebase | Provides the backend service (Firebase Authentication) for user management, credential verification, and session handling. |
| Edge | ESP32 | No direct role in user authentication. It is concerned with sending alerts to a pre-configured cloud endpoint. |
Sources: HomeSecurity/README.md:41-69
The following diagram illustrates the architectural separation of concerns, with authentication residing in the Client and Cloud tiers.
This diagram shows that the Android App communicates with Firebase for authentication, while the ESP32 communicates with a Firebase Cloud Function to trigger notifications.
Sources: HomeSecurity/README.md:41-69, 287-293
Authentication Methods
The companion Android application supports two primary methods for user authentication, both facilitated by the Firebase Authentication service.
| Method | Description |
|---|---|
| Email/Password | Standard authentication allowing users to sign up and sign in with their email address and a password. |
| Google Sign-In | An OAuth-based method that allows users to authenticate using their existing Google account for a faster sign-in experience. |
These options are presented to the user on the application's Login Screen.
Sources: HomeSecurity/README.md:102, 290, 298
Authentication Flow
The authentication process is initiated by the user on the Android application. The ESP32 device is not involved in this flow.
The diagram below shows the sequence of events during a user login.
This sequence illustrates a successful login, where Firebase validates the user's credentials and the app proceeds to the main home screen.
Sources: HomeSecurity/README.md:290, 298-300
Role of Firebase in Authentication
Firebase is the central component for managing users in the HomeSecurity project.
- Service Used: Firebase Authentication
- Responsibility: User management, including creation, verification, and session persistence.
- Technology Stack: The Android application is built with Kotlin and Jetpack Compose, integrating the Firebase Auth SDK to handle all authentication-related tasks.
While the ESP32 interacts with Firebase via a Cloud Function to send notifications, this interaction is based on a pre-configured device FCM token and is independent of the authenticated user on the mobile app.