0
0
Firebasecloud~10 mins

Storage security rules in Firebase - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to allow read access only if the user is authenticated.

Firebase
allow read: if request.auth [1] null;
Drag options to blanks, or click blank then click option'
A!=
B==
C<=
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '!=' causes access to be denied for authenticated users.
Using comparison operators like '<=' or '>' are invalid for null checks.
2fill in blank
medium

Complete the code to allow write access only if the user is the owner of the file.

Firebase
allow write: if request.auth.uid == resource.metadata.ownerId && request.auth.uid [1] null;
Drag options to blanks, or click blank then click option'
A>
B<
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' to check for null allows unauthenticated users.
Forgetting to check authentication before ownership.
3fill in blank
hard

Fix the error in the rule that denies all access unintentionally.

Firebase
allow read, write: if request.auth.uid [1] null;
Drag options to blanks, or click blank then click option'
A===
B==
C!=
D!==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' causes access to be denied for authenticated users.
Using strict equality operators like '===' are not supported in Firebase rules.
4fill in blank
hard

Fill both blanks to allow uploads only if the file size is less than 5MB and the user is authenticated.

Firebase
allow write: if request.resource.size [1] 5 * 1024 * 1024 && request.auth [2] null;
Drag options to blanks, or click blank then click option'
A<
B>
C!=
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' instead of '<' allows files larger than 5MB.
Using '==' instead of '!=' allows unauthenticated users.
5fill in blank
hard

Fill all three blanks to allow read access only if the file is public or the user is the owner and authenticated.

Firebase
allow read: if resource.metadata.isPublic == true || (request.auth.uid [1] null && request.auth.uid [2] resource.metadata.ownerId && resource.metadata.isPublic [3] false);
Drag options to blanks, or click blank then click option'
A!=
B==
D===
Attempts:
3 left
💡 Hint
Common Mistakes
Using '===' which is not supported in Firebase rules.
Mixing up '==' and '!=' operators causing logic errors.