Google.Cloud.Firestore can view any collection or document regardless of security rules
See original GitHub issueI have just installed Google.Cloud.Firestore 1.0.0-beta14 yesterday and started playing with it without setting up any sort of authentication. I soon discovered that I was able to access parts of my firestore database that had security rules around them.
To eliminate any sort of confusion on my part, I created a brand new Firebase project with a Firestore database in a locked mode. Sure enough, I’m able to both read & write things to it via my .net app. Here a sample code:
using System;
using System.Threading.Tasks;
using Google.Cloud.Firestore;
namespace ExerciseImagesFirestoreUploader
{
class Program
{
static async Task Main(string[] args)
{
var db = FirestoreDb.Create("my-project-id");
var collection = db.Collection("admins");
var newDoc = collection.Document("ZYpky483yuQlfcv9iVg5oROQbJn6");
await newDoc.CreateAsync(new { test = "123" });
var qs = await collection.GetSnapshotAsync();
foreach (var doc in qs.Documents)
{
Console.WriteLine("DocID: " + doc.Id);
}
}
}
}
Could someone please explain why this is happening?
Issue Analytics
- State:
- Created 5 years ago
- Comments:17
Top Results From Across the Web
Get started with Cloud Firestore Security Rules - Firebase
All Cloud Firestore Security Rules consist of match statements, which identify documents in your database, and allow expressions, which control access to ...
Read more >Structuring security rules | Firestore
Firestore Security Rules allow you to control access to documents and collections in your database. The flexible rules syntax allows you to create...
Read more >Is there any function for rules in reading all documents in a ...
Right now, the query is asking for ALL documents in the lists collection, regardless of whether or not the client has access to...
Read more >Security Rules
The basic allow read rule grants both get and list access to the documents in a collection. The allow get ...
Read more >Firestore Data Model: An Easy Guide
Firestore Data Model provides various security rules that allow users to control access to documents and collections. Security in Cloud ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@LeXa777 If you intend to play with Firestore from a .NET application from an user account, this is what you need:
I will give you an example. But before that, keep in mind that this Firestore .NET SDK is designed for server-side use. I have been using it for .NET client-side applications (WPF, Win Forms, Xamarin) for pretty a much a year, and I can tell from my experience that it works just fine for client applications too. But it is NOT officially supported, and it misses many client-side features that other official Firestore SDKs provide.
The code above is just a sample. It needs additional work, especially when it comes to handling eventual exceptions that
authProvider.SignInWithEmailAndPasswordAsync
may throw (invalid email/password, connection issues, etc).Optionally, you can authenticate to Firebase using Firebase REST API.
@BidyaSagarJena: I don’t think that’s related to this topic at all. I’ve seen the issue you reported in the dotnet-docs-samples repo, and I’ll investigate that, but please don’t add comments to unrelated issues.