Skip to content

Instantly share code, notes, and snippets.

@RobSpectre
Last active February 22, 2025 18:27
Show Gist options
  • Save RobSpectre/6a1115ca923357697a172b5e2d29ceda to your computer and use it in GitHub Desktop.
Save RobSpectre/6a1115ca923357697a172b5e2d29ceda to your computer and use it in GitHub Desktop.
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
function isSignedIn() {
return request.auth != null;
}
function isUser(userId) {
return request.auth.uid == userId;
}
// Allow initial file upload
match /uploads/{processId}/{userId}/{dateString}/{allPaths=**} {
allow write: if
isSignedIn() &&
request.resource.size <= 7 * 1024 * 1024; // 7MB limit
allow read: if false;
}
// Allow access to generated files
match /generated/{processId}/{userId}/{allPaths=**} {
allow read: if
isSignedIn() &&
isUser(resource.metadata.userId);
allow write: if false;
}
// Default deny
match /{allPaths=**} {
allow read, write: if false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment