servicefirebase.storage{match/b/{bucket}/o{match/images/{imageId}{//Onlyallowuploadsofanyimagefilethat's less than 5MBallowwrite:ifrequest.resource.size < 5*1024*1024&&request.resource.contentType.matches('image/.*');}}}
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-08-12 UTC。"],[],[],null,["\u003cbr /\u003e\n\nTraditionally, security has been one of the most complex parts of app\ndevelopment. In most applications, developers must build and run a server that\nhandles authentication (who a user is) and authorization (what a user can do).\nAuthentication and authorization are hard to set up, harder to get right, and\ncritical to the success of your product.\n\nSimilar to how Firebase Authentication makes it easy for you to authenticate your\nusers, Firebase Security Rules for Cloud Storage makes it easy for you to authorize users\nand validate requests. Cloud Storage Security Rules manage the complexity for you by\nallowing you to specify path based permissions. In just a few lines of code, you\ncan write authorization rules that restrict Cloud Storage requests to a\ncertain user or limit the size of an upload.\n| **Note:** If you use Google App Engine and have a default Cloud Storage bucket with a name format of `*.appspot.com`, you may need to consider [how your security rules impact access to App Engine files](/docs/storage/gcp-integration#security-rules-and-app-engine-files).\n\nThe Firebase Realtime Database has a similar feature, called\n[Firebase Realtime Database Security Rules](/docs/database/security)\n\nAuthentication\n\nKnowing who your users are is an important part of building an application, and\nFirebase Authentication provides an easy to use, secure, client side only solution\nto authentication. Firebase Security Rules for Cloud Storage ties in to Firebase Authentication\nfor user based security. When a user is authenticated with Firebase Authentication,\nthe `request.auth` variable in Cloud Storage Security Rules becomes an object that\ncontains the user's unique ID (`request.auth.uid`) and all other user\ninformation in the token (`request.auth.token`). When the user is not\nauthenticated, `request.auth` is `null`. This allows you to securely control\ndata access on a per-user basis. You can learn more in the\n[Authentication](/docs/storage/security/rules-conditions#authentication) section.\n\nAuthorization\n\nIdentifying your user is only part of security. Once you know who they are, you\nneed a way to control their access to files in Cloud Storage.\n\nCloud Storage lets you specify per file and per path authorization\nrules that live on our servers and determine access to the files in your app.\nFor example, the default Cloud Storage Security Rules require Firebase Authentication in\norder to perform any `read` or `write` operations on all files: \n\n```css+lasso\nservice firebase.storage {\n match /b/{bucket}/o {\n match /someFolder/{fileName} {\n allow read, write: if request.auth != null;\n }\n }\n}\n```\n\nYou can edit these rules by selecting a Firebase app in the [Firebase console](//console.firebase.google.com/)\nand viewing the `Rules` tab of the Storage section.\n\nData Validation\n\nFirebase Security Rules for Cloud Storage can also be used for data validation, including\nvalidating file name and path as well as file metadata properties such as\n`contentType` and `size`. \n\n```gdscript\nservice firebase.storage {\n match /b/{bucket}/o {\n match /images/{imageId} {\n // Only allow uploads of any image file that's less than 5MB\n allow write: if request.resource.size \u003c 5 * 1024 * 1024\n && request.resource.contentType.matches('image/.*');\n }\n }\n}\n```\n\nNext steps\n\n- [Get started](/docs/storage/security/get-started) planning rules development\n for your Cloud Storage buckets.\n\n- Learn more about [securing your data](/docs/storage/security/core-syntax)\n using security rules."]]