firebase / firebase/firebase-js-sdk
FR: [storage] Download files with customer-supplied/managed encryption keys
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 37
Description
### [REQUIRED] Describe your environment
* Operating System version: macOS 11.2
* Browser version: Safari 14.0.3
* Firebase SDK version: 8.2.6
* Firebase Product: storage (auth, database, storage, etc)
### [REQUIRED] Describe the problem
I [asked about this on Stack Overflow](https://stackoverflow.com/q/65993276/3574) but got no reply in four days. I created a [companion request for FlutterFire](https://github.com/FirebaseExtended/flutterfire/discussions/4954) and [AngularFire](https://github.com/angular/angularfire/issues/2752). There I was told first [to start a discussion here](https://github.com/angular/angularfire/issues/2752#issuecomment-774727764). And then I was asked [to file an issue](https://github.com/firebase/firebase-js-sdk/discussions/4438#discussioncomment-354013).
My app stores files with Firebase Storage. I want to encrypt these files conveniently on the server. Firebase Storage uses Google Cloud Storage. And Google Cloud Storage offers two options for this: [Customer-supplied encryption keys](https://cloud.google.com/storage/docs/encryption/customer-supplied-keys), where the app provides a key, and [customer-managed encryption keys](https://cloud.google.com/storage/docs/encryption/customer-managed-keys), where the app provides the name of the server-side “encryption service account” in Google cloud storage.
I think my Java back-end that creates my files would be fine: The [Firebase Admin SDK uses the Java Cloud Storage library](https://firebase.google.com/docs/storage/admin/start#google_cloud_storage_client_libraries). And there [Storage.BlobTargetOption](https://googleapis.dev/java/google-cloud-storage/latest/com/google/cloud/storage/Storage.BlobTargetOption.html#method.summary) has an `encryptionKey()` method for the customer-supplied encryption key, and a `kmsKeyName()` method for the customer-managed encryption keys.
But I don’t see how I can download files with customer-supplied/managed encryption keys in the Firebase Javascript SDK. I can't specify a key or key name when [creating the reference to the file](https://github.com/firebase/firebase-js-sdk/blob/40a702eb2c92f37fd7bf3a18502d7d34cf4927a1/packages/storage/src/service.ts#L101). And I can't specify these [when getting the file's download URL](https://github.com/firebase/firebase-js-sdk/blob/40a702eb2c92f37fd7bf3a18502d7d34cf4927a1/packages/storage/src/reference.ts#L361), either.
So I suggest as a feature that Firebase Storage in the Firebase Javascript SDK supports both the customer-supplied & customer-managed encryption keys for Google Cloud Storage. As for the implementation of that feature, getting a download URL could be the place to specify either a customer-supplied encryption key or the name of a customer-managed encryption key.
Contributor guide
Assessment
This issue has not been assessed yet.