Process Flow - Authentication-based rules
User tries to access data
Check if user is signed in
Allow access
Perform requested operation
This flow shows how Firebase checks if a user is signed in before allowing access to data.
service cloud.firestore {
match /databases/{database}/documents {
match /messages/{messageId} {
allow read, write: if request.auth != null;
}
}
}| Step | User Signed In? | Condition (request.auth != null) | Access Granted? | Action |
|---|---|---|---|---|
| 1 | Yes | True | Yes | Allow read or write |
| 2 | No | False | No | Deny read or write |
| Variable | Start | After Step 1 | After Step 2 |
|---|---|---|---|
| request.auth | null | User object (authenticated) | null |
| Access Granted | No | Yes | No |
Firebase Authentication Rules: - Use 'request.auth != null' to check if user is signed in. - Allow access only if user is authenticated. - Deny access if user is not signed in. - Applies to read and write operations. - Simple and secure way to protect data.