さまざまな開発ワークフロー環境に対応した一般的なセキュリティ ガイドライン
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
このページでは、環境全体のセキュリティに関する最も重要なベスト プラクティスについて説明します。セキュリティと Firebase に関するより詳細なガイダンスについては、セキュリティ チェックリストをご覧ください。
本番前環境のセキュリティ
異なる Firebase プロジェクトで環境を分離するメリットの 1 つは、本番前環境にアクセスできる悪意のあるユーザーが、実際のユーザーデータにアクセスできないことです。本番前環境で最も重要なセキュリティ対策は次のとおりです。
本番前環境へのアクセスを制限するモバイルアプリの場合は、App Distribution または類似のアプリを使用して、特定のユーザーセットにアプリを配布します。ウェブ アプリケーションは制限が難しいため、本番前環境用にブロック機能を設定し、ドメイン固有のメールアドレスを持つユーザーにアクセスを制限します。Firebase Hosting を使用している場合は、一時的なプレビュー URL を使用して、本番前環境のワークフローを設定します。
環境を持続する必要がなく、1 人(またはテストの場合は 1 台のマシン)でのみ使用する場合は、Firebase Local Emulator Suite を使用します。これらのエミュレータは、クラウド リソースを使用する代わりに localhost で完全に動作するため、安全かつ高速です。
本番環境と同様に、本番前環境で Firebase Security Rules が設定されていることを確認します。一般に、Rules は環境全体で同一にする必要があります。ただし、ルールはコードによって変更されるため、パイプライン内で本番環境にないルールが存在している可能性があります。
本番環境のセキュリティ
本番環境データは、アプリの状態に関係なく、常にターゲットになっています。次のガイドラインは、悪意のある人物によるデータの取得を完全に防ぐものではありませんが、このガイドラインに従うことで、データの取得は非常に難しくなります。
使用しているすべてのプロダクトで App Check を有効にして適用する。App Check は、バックエンド サービスに対するリクエストが正規のアプリから送信されていることを確認します。この機能を使用するには、アプリの各バージョンを App Check に登録する必要があります。ユーザーがいない状態でも簡単に設定できるので、できるだけ早い段階で設定してください。
堅牢な Firebase Security Rules を作成します。Realtime Database、Cloud Firestore、Cloud Storage はすべて、デベロッパーが構成した Rules を使用して、データへのアクセスを許可するユーザーと禁止するユーザーを特定します。セキュリティ上、適切な Rules を記述することが重要です。方法がわからない場合は、まずこの codelab をご覧ください。
本番環境用のセキュリティの詳細については、セキュリティ チェックリストをご覧ください。
次のステップ
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-04 UTC。
[null,null,["最終更新日 2025-08-04 UTC。"],[],[],null,["This page describes the most important best practices for security across\nenvironments, but review the\n[*Security checklist*](/support/guides/security-checklist) for more detailed and\nthorough guidance about security and Firebase.\n\nSecurity for pre-production environments\n\nOne benefit of separating environments in different Firebase projects is that a\nmalicious actor who is able to access your pre-prod environments won't be able\naccess real user data. Here are the most important security precautions to take\nfor pre-production environments:\n\n- Limit access to pre-prod environments. For mobile apps, use\n [App Distribution](/docs/app-distribution) (or something similar) to distribute\n an app to a specific set of people. Web applications are harder to restrict;\n consider setting up a\n [blocking function](https://cloud.google.com/identity-platform/docs/blocking-functions)\n for the pre-prod environments that restricts access to users with email\n addresses that are specific to your domain. Or, if you're using\n Firebase Hosting, set up your pre-prod workflows to use\n [temporary preview URLs](/docs/hosting/test-preview-deploy).\n\n- When an environment doesn't need to be persisted and is only being used by one\n person (or in the case of tests, by one machine) use the\n [Firebase Local Emulator Suite](/docs/emulator-suite). These emulators are safer\n and faster because they can work entirely on localhost instead of using cloud\n resources.\n\n- Make sure that you have [Firebase Security Rules](/docs/rules) set up in pre-production\n environments, just as you do in prod. In general, the Rules should\n be the same across environments, with the caveat that since rules change with\n code, there may be rules earlier in the pipeline that don't yet exist in\n production.\n\nSecurity for production environments\n\nProduction data is always a target, even if the app is obscure. Following these\nguidelines doesn't make it impossible for a malicious actor to get your data,\nbut it makes it more difficult:\n\n- Enable and enforce [App Check](/docs/app-check) for all the products\n you're using that support it. App Check makes sure that requests to your\n backend services are coming from your genuine apps. In order to use it, you\n need to register each version of your app with App Check. It's easier to\n set up before you have users, so set it up as soon as possible.\n\n- Write robust [Firebase Security Rules](/docs/rules). Realtime Database, Cloud Firestore, and\n Cloud Storage all rely on developer-configured Rules to\n enforce who should and shouldn't be able to access data. It's essential to\n your security that you write good Rules. If you're not sure how,\n start with this [codelab](/codelabs/firebase-rules).\n\n- Review the [*Security checklist*](/support/guides/security-checklist) for more\n recommendations about security for production environments.\n\nNext steps\n\n- Review the [Firebase launch checklist](/support/guides/launch-checklist)."]]