Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Wenn Sie die aktualisierten Firebase Security Rules in der Firebase Console schnell testen möchten, verwenden Sie den Regel-Playground.
Der Regel-Playground ist ein praktisches Tool, mit dem Sie neue Verhaltensweisen testen oder Regeln schnell validieren können, während Sie sie schreiben. Es wird eine Meldung angezeigt, die bestätigt, dass der Zugriff gemäß den von Ihnen für die Simulation festgelegten Parametern entweder gewährt oder verweigert wurde.
Führen Sie dann in der Produktnavigation einen der folgenden Schritte aus:
Wählen Sie Realtime Database, Cloud Firestore oder Speicher aus und klicken Sie dann auf Regeln, um den Rules-Editor aufzurufen.
Wenn Sie die Änderungen vorgenommen haben, klicken Sie im Editor auf Regel-Playground.
Wählen Sie in den Einstellungen zu Regel-Playground Optionen für Ihren Test aus, wie z. B. die folgenden:
Lese- oder Schreibvorgänge testen.
Unter Standort einen bestimmten Standort in Ihrer Datenbank oder Ihrem Speicher-Bucket als Pfad.
Authentifizierungstyp: nicht authentifizierter Nutzer, authentifizierter anonymer Nutzer oder eine bestimmte Nutzer-ID.
Dokumentspezifische Daten, auf die Ihre Regeln speziell verweisen (z. B. wenn für Ihre Regeln das Vorhandensein eines bestimmten Felds erforderlich ist, bevor ein Schreibvorgang erlaubt wird).
Klicken Sie auf Ausführen und sehen Sie sich die Ergebnisse im Banner über dem Editor an.
Beispielszenario für den Regelsimulator
Testen Sie das Verhalten von Regel-Playground mit dem folgenden Beispielszenario und den grundlegenden Regeln.
Cloud Firestore
service cloud.firestore {
match /databases/{database}/documents {
// Allow only authenticated content owners access
match /some_collection/{document} {
allow read, write: if request.auth != null && request.auth.uid == request.resource.data.author_uid
}
}
}
Realtime Database
// These rules grant access to a node matching the authenticated// user's ID from the Firebase auth token{"rules":{"users":{"$uid":{".read":"$uid === auth.uid",".write":"$uid === auth.uid"}}}}
Cloud Storage
// Grants a user access to a node matching their user IDservicefirebase.storage{match/b/{bucket}/o{// Files look like: "user/<UID>/file.txt"match/user/{userId}/{fileName}{allowread,write:ifrequest.auth!=null && request.auth.uid==userId;}}}
Fügen Sie im Rules-Editor die angegebene Regel hinzu.
Wählen Sie im Drop-down-Menü Simulationstyp die Option get aus und geben Sie im Feld Speicherort einen gültigen Pfad ein.
Aktivieren Sie Authentifizierung und wählen Sie im Drop-down-Menü Anbieter einen Authentifizierungstyp aus.
Geben Sie die Details zur Nutzer-ID ein und klicken Sie auf Ausführen.
Die Ergebnisse der Simulation werden oben im Editor angezeigt. Je nach den von Ihnen eingegebenen Nutzer-ID-Details sollte ein Banner angezeigt werden, das bestätigt, ob der Lesevorgang erfolgreich zugelassen oder abgelehnt wurde.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-07-25 (UTC)."],[],[],null,["\u003cbr /\u003e\n\nTo quickly test your updated Firebase Security Rules in the Firebase console, use\nthe Rules Playground.\n| **Note:** To fully validate your app's behavior and verify your Firebase Security Rules \n| configurations, use the [Firebase Emulator](/docs/rules/emulator-setup) to run and automate unit tests in a local environment.\n\nThe Rules Playground is a convenient tool to use as you're exploring\nnew behaviors or quickly validating rules as you write them. It displays a\nmessage confirming that access was either allowed or denied according to the\nparameters you set for the simulation.\n\nUse the Rules Playground\n\n1. Open the [Firebase console](//console.firebase.google.com/) and select your project.\n2. Then, from the product navigation, do one of the following:\n - Select **Realtime Database** , **Cloud Firestore** , or **Storage** , as appropriate, then click **Rules** to navigate to the Rules editor.\n3. Once you've made your edits, click **Rules Playground** from the editor.\n4. In the *Rules Playground* settings, select options for your test, including:\n - Testing reads or writes.\n - A specific **Location** in your database or storage bucket, as a path.\n - Authentication type --- unauthenticated, authenticated anonymous user, or a specific user ID.\n - Document-specific data that your rules specifically reference (for example, if your rules require the presence of a specific field before allowing a write).\n5. Click **Run** and look for the results in the banner above the editor.\n\nSample Rules Playground scenario\n\nTest the Rules Playground behavior with the following sample scenario\nand basic rules. \n\nCloud Firestore \n\n service cloud.firestore {\n match /databases/{database}/documents {\n // Allow only authenticated content owners access\n match /some_collection/{document} {\n allow read, write: if request.auth != null && request.auth.uid == request.resource.data.author_uid\n }\n }\n }\n\nRealtime Database\n\n\u003cbr /\u003e\n\n```scilab\n // These rules grant access to a node matching the authenticated\n // user's ID from the Firebase auth token\n {\n \"rules\": {\n \"users\": {\n \"$uid\": {\n \".read\": \"$uid === auth.uid\",\n \".write\": \"$uid === auth.uid\"\n }\n }\n }\n }\n \n```\n\n\u003cbr /\u003e\n\nCloud Storage \n\n // Grants a user access to a node matching their user ID\n service firebase.storage {\n match /b/{bucket}/o {\n // Files look like: \"user/<UID>/file.txt\"\n match /user/{userId}/{fileName} {\n allow read, write: if request.auth != null && request.auth.uid == userId;\n }\n }\n }\n\n- In the Rules editor, add the rule given.\n\n-\n Select **get** from the **Simulation type** drop-down menu and enter a valid\n path in the **Location** field.\n\n- Toggle on **Authentication** and select an authentication type from the\n **Provider** drop-down.\n\n- Enter the user ID details and click **Run**.\n\nThe results of the simulation appear at the top of the editor. Depending on the\nuser ID details you entered, you should see a banner confirming the read\nwas either successfully allowed or denied."]]