사용자 데이터 삭제 확장 프로그램(delete-user-data)을 사용하면 Firebase 프로젝트에서 사용자가 삭제될 때 사용자의 데이터를 삭제할 수 있습니다. Cloud Firestore, 실시간 데이터베이스 또는 Cloud Storage 중 일부 또는 전부에서 사용자 데이터를 삭제하도록 확장 프로그램을 구성할 수 있습니다. 확장 프로그램의 데이터 삭제 트리거가 각각 사용자의 UserId와 연결됩니다.
이 확장 프로그램은 사용자 개인 정보를 보호하고 규정 준수 요구사항을 이행하는 데 유용합니다. 하지만 이 확장 프로그램을 사용한다고 해서 정부와 업계 규정의 준수가 보장되지는 않습니다.
이 확장 프로그램에 생성된 함수를 배포할 위치를 선택합니다. 일반적으로 데이터베이스에 가까운 위치가 좋습니다. 위치 선택에 대한 도움말은 위치 선택 가이드를 참조하세요.
Cloud Firestore 경로:
Cloud Firestore 인스턴스에서 사용자 데이터는 어떤 경로에 있나요? Cloud Firestore를 사용하지 않는 경우에는 비워 둡니다. 전체 경로를 쉼표로 구분하여 입력합니다. 삭제된 사용자의 사용자 ID는 {UID}로 나타낼 수 있습니다. 예를 들어 users 및 admins 컬렉션이 있고 각 컬렉션에 사용자 ID가 문서 ID인 문서가 있는 경우 users/{UID},admins/{UID}를 입력할 수 있습니다.
Cloud Firestore 삭제 모드:
(Cloud Firestore paths 파라미터를 사용하는 경우에만 적용됩니다.) Cloud Firestore 문서를 어떻게 삭제하시겠어요? 하위 컬렉션에서도 문서를 삭제하려면 이 파라미터를 recursive로 설정합니다.
실시간 데이터베이스 인스턴스:
사용자 데이터를 삭제할 실시간 데이터베이스 인스턴스는 무엇인가요?
실시간 데이터베이스 위치:
(Realtime Database instance 파라미터를 제공한 경우에만 적용됩니다.) 사용자 데이터를 삭제할 실시간 데이터베이스 위치는 무엇인가요?
실시간 데이터베이스 경로:
실시간 데이터베이스 인스턴스에서 사용자 데이터는 어떤 경로에 있나요? 실시간 데이터베이스를 사용하지 않는 경우에는 비워 둡니다. 전체 경로를 쉼표로 구분하여 입력합니다. 삭제된 사용자의 사용자 ID는 {UID}로 나타낼 수 있습니다. 예를 들면 users/{UID},admins/{UID}입니다.
Cloud Storage 경로:
Google Cloud Storage에서 사용자 데이터는 어디에 저장되나요? Cloud Storage를 사용하지 않는 경우에는 비워 둡니다. Storage 버킷의 파일 또는 디렉터리 전체 경로를 쉼표로 분리하여 입력합니다. 삭제된 사용자의 사용자 ID를 나타낼 때는{UID}를 사용하고, 기본 Storage 버킷을 나타날 때는 {DEFAULT}를 사용합니다.
다음은 일련의 예시입니다.
파일 이름 지정 스키마가 {UID}-pic.png인 기본 버킷의 모든 파일을 삭제하려면 {DEFAULT}/{UID}-pic.png를 입력합니다.
또한 파일 이름 지정 스키마가 {UID}-logs.txt인 my-app-logs라는 또 다른 버킷의 모든 파일을 삭제하려면 {DEFAULT}/{UID}-pic.png,my-app-logs/{UID}-logs.txt를 입력합니다.
또한 사용자 ID 라벨이 지정된 디렉터리와 모든 해당 파일(예: media/{UID})을 삭제하려면 {DEFAULT}/{UID}-pic.png,my-app-logs/{UID}-logs.txt,{DEFAULT}/media/{UID}를 입력합니다.
삭제할 데이터 검색
이 확장 프로그램에서 삭제할 데이터를 검색하는 데 사용하는 몇 가지 메커니즘이 있습니다. 확장 프로그램이 데이터를 삭제할 수 있도록 이 메커니즘을 명시적으로 구성해야 합니다. 확장 프로그램은 제공된 메커니즘에 따라 삭제되도록 명시적으로 구성된 데이터만 삭제합니다.
각 서비스 간의 다음과 같은 동작 차이에 유의하세요.
Cloud Firestore: 기본 동작은 문서를 얕게 삭제하는 것입니다(하위 컬렉션은 삭제되지 않음). 문서의 모든 하위 컬렉션을 재귀적으로 삭제하려면 'Cloud Firestore 삭제 모드' 옵션을 '재귀'로 설정합니다.
실시간 데이터베이스: 지정된 노드의 모든 데이터가 삭제됩니다.
스토리지: 디렉터리 경로를 지정하면 모든 파일과 하위 디렉터리가 삭제됩니다.
경로별
Cloud Firestore, 실시간 데이터베이스, Cloud Storage 경로를 구성할 때 경로에서 UID 변수를 정의하여 인증된 사용자의 UID로 대체할 수 있습니다. 사용자가 삭제되면 확장 프로그램은 지정된 경로에서 해당 UID에 연결된 모든 데이터를 삭제합니다. 예를 들면 다음과 같습니다.
확장 프로그램이 삭제할 Firestore 문서를 자동으로 검색할 수 있도록 하려면 '자동 검색 사용 설정' 구성 파라미터를 '예'로 설정합니다.
자동 탐색은 데이터베이스를 자동으로 순회하여 구성에 따라 삭제해야 하는 컬렉션과 문서를 찾는 방식으로 작동합니다. 확장 프로그램은 다음 방법으로 컬렉션과 문서를 식별합니다.
먼저 확장 프로그램은 데이터베이스의 모든 루트 컬렉션을 찾습니다. 컬렉션의 ID가 사용자의 UID와 일치하는 경우 전체 컬렉션이 삭제됩니다. 삭제는 'Cloud Firestore 삭제 모드'에 대한 확장 프로그램의 구성에 따라 재귀적이거나 얕습니다.
두 번째로 컬렉션 ID가 일치하지 않으면 확장 프로그램은 문서 ID가 사용자의 UID와 일치하는 경우 문서 식별 및 삭제를 시도합니다.
마지막으로 각 문서에 대해 다음을 수행합니다.
a. 현재 검색 심도(아래 참고)가 구성된 검색 심도보다 작거나 같으면 프로세스가 현재 문서의 모든 하위 컬렉션에 대해 반복됩니다.
b. 검색 필드가 구성된 경우 확장 프로그램은 제공된 필드가 사용자의 UID와 일치하는지 확인합니다. 일치하는 항목이 발견되면 문서가 삭제됩니다.
검색 심도
확장 프로그램은 구성 가능한 검색 심도 값(기본값: 3)을 제공합니다. 현재 검색 심도가 구성된 검색 심도보다 작거나 같은 경우에만 순회가 실행됩니다. 현재 검색 심도는 현재 컬렉션 또는 문서의 상위 수준의 심도에 따라 달라집니다. 예를 들면 다음과 같습니다.
[[["이해하기 쉬움","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-29(UTC)"],[],[],null,["\u003cbr /\u003e\n\nThe Delete User Data extension (`delete-user-data`) lets you delete a user's data when the user is deleted from your Firebase project. You can configure this extension to delete user data from any or all of the following: Cloud Firestore, Realtime Database, or Cloud Storage. Each trigger of the extension to delete data is keyed to the user's `UserId`.\n| **Note:** To use this extension, you need to manage your users with Firebase Authentication.\n\nThis extension is useful for respecting user privacy and fulfilling compliance requirements. However, using this extension does not guarantee compliance with government and industry regulations.\n\nPrerequisites\n\n- You must use [Firebase Authentication](https://firebase.google.com/docs/auth) to manage your users.\n\n- This extension only deletes data from [Cloud Firestore](https://firebase.google.com/docs/firestore), [Realtime Database](https://firebase.google.com/docs/database), and [Cloud Storage](https://firebase.google.com/docs/storage). If you store user data elsewhere, you should also delete user data from those sources when you delete users.\n\nInstall the extension\n\nTo install the extension, follow the steps on the [Install Firebase Extension](https://firebase.google.com/docs/extensions/install-extensions) page. In summary, do one of the following:\n\n- **Firebase console:** Click the following button:\n\n [Install the Delete User Data extension](https://console.firebase.google.com/project/_/extensions/install?ref=firebase%2Fdelete-user-data)\n- **CLI:** Run the following command:\n\n firebase ext:install firebase/delete-user-data --project=\u003cvar translate=\"no\"\u003eprojectId-or-alias\u003c/var\u003e\n\nDuring the installation of the extension, you will be prompted to specify a number of configuration parameters:\n\n- **Cloud Functions location:**\n\n Select the location of where you want to deploy the functions created for this extension. You usually want a location close to your database. For help selecting a location, refer to the [location selection guide](https://firebase.google.com/docs/functions/locations).\n- **Cloud Firestore paths:**\n\n Which paths in your Cloud Firestore instance contain user data? Leave empty if you don't use Cloud Firestore. Enter the full paths, separated by commas. You can represent the User ID of the deleted user with `{UID}`. For example, if you have the collections `users` and `admins`, and each collection has documents with the User ID as document IDs, then you can enter `users/{UID},admins/{UID}`.\n- **Cloud Firestore delete mode:**\n\n (Only applicable if you use the `Cloud Firestore paths` parameter.) How do you want to delete Cloud Firestore documents? To also delete documents in subcollections, set this parameter to `recursive`.\n- **Realtime Database instance:**\n\n From which Realtime Database instance do you want to delete user data?\n- **Realtime Database location:**\n\n (Only applicable if you provided the `Realtime Database instance` parameter.) From which Realtime Database location do you want to delete user data?\n- **Realtime Database paths:**\n\n Which paths in your Realtime Database instance contain user data? Leave empty if you don't use Realtime Database. Enter the full paths, separated by commas. You can represent the User ID of the deleted user with `{UID}`. For example: `users/{UID},admins/{UID}`.\n- **Cloud Storage paths:**\n\n Where in Google Cloud Storage do you store user data? Leave empty if you don't use Cloud Storage. Enter the full paths to files or directories in your Storage buckets, separated by commas. Use `{UID}` to represent the User ID of the deleted user, and use `{DEFAULT}` to represent your default Storage bucket.\n\n Here's a series of examples:\n - To delete all the files in your default bucket with the file naming scheme `{UID}-pic.png`, enter `{DEFAULT}/{UID}-pic.png`.\n - To also delete all the files in another bucket called `my-app-logs` with the file naming scheme `{UID}-logs.txt`, enter `{DEFAULT}/{UID}-pic.png,my-app-logs/{UID}-logs.txt`.\n - To *also* delete a User ID-labeled directory and all its files (like `media/{UID}`), enter `{DEFAULT}/{UID}-pic.png,my-app-logs/{UID}-logs.txt,{DEFAULT}/media/{UID}`.\n\nDiscovering data for deletion\n\nThere are a few mechanisms that this extension uses to discover data for deletion. These mechanisms have to be explicitly configured for the extension to delete data. The extension will only delete data that is explicitly configured to delete based on the mechanisms provided.\n\nBe aware of the following behavioral differences between each service:\n\n- Cloud Firestore: the default behavior is to shallow delete a document (sub-collections will not be deleted). To recursively delete all sub-collections of a document, set the \"Cloud Firestore delete mode\" option to \"Recursive\".\n- Realtime Database: all data at the specified node will be deleted.\n- Storage: if a directory path is specified, all files and sub-directories will be deleted.\n\nBy path\n\nWhen configuring the Cloud Firestore, Realtime Database \\& Cloud Storage paths, it's possible to define a `UID` variable in the paths which will be replaced with the authenticated user's UID. When a user is deleted, the extension will delete all data keyed on that UID at the given paths, for example:\n\n- Cloud Firestore path(s): `users/{UID},admins/{UID}`\n- Realtime Database path(s): `likes/{UID}`\n- Cloud Storage path(s): `{DEFAULT}/uploads/{UID},{DEFAULT}/avatars/{UID}.jpeg`\n\nAuto Discovery (Cloud Firestore)\n\nTo enable the extension to automatically discover Firestore documents to delete, set the \"Enable auto discovery\" configuration parameter to \"Yes\".\n\nAuto-discovery works by automatically traversing the database to find collections and documents which should be deleted according to your configuration. The extension identifies those collections and documents with the following methodology:\n\n1. First, the extension finds all root collections in the database. If a collection's ID matches that of the user's UID, the entire collection is deleted (deletion is either recursive or shallow, depending on the extensions's configuration for \"Cloud Firestore delete mode\").\n2. Secondly, if the collection ID does not match, the extension will attempt to identify and delete a document if its document ID matches that of the user's UID.\n3. Finally, for each document: a. If the current search depth (see below) is less than or equal to the configured search depth, the process will be repeated for all of the current document's sub-collections. b. If search fields have been configured, the extension will check if the provided fields match the user's UID. If a match is found, the document will be deleted.\n\nSearch Depth\n\nThe extension offers a configurable search depth value (defaulting to 3). Traversal will only be executed if the current search depth is less than or equal to the configured search depth. The current search depth is based on the depth of the current collection or documents parent collection, for example \n\n /users = 1\n /users/\u003cdocument-id\u003e = 1\n /users/\u003cdocument-id\u003e/comments = 2\n /users/\u003cdocument-id\u003e/comments/\u003cdocument-id\u003e = 2\n\nThis extension will NOT automatically delete UIDs stored in arrays or maps, and it will not search for data keyed by user ID stored in deeply nested subcollections past the depth specified above.\n| **Note:** with large databases, traversal-based discovery may incur many reads and deletions since it reads all documents in the corresponding collections. Please be aware of Cloud Firestore billing prices and how this might impact you. Auto discovery is completely optional."]]