Skip to content

Commit d136ecf

Browse files
authored
Update file adapter docs (#780)
* Update file adapter docs * Add file adapter to postgres database docs * Fixed available versions * Add default file directory
1 parent 180c5d8 commit d136ecf

File tree

2 files changed

+39
-41
lines changed

2 files changed

+39
-41
lines changed

_includes/parse-server/database.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,18 @@ The postgres database adapter will be automatically loaded when you pass a valid
3434
postgres://localhost:5432/db?ssl=boolean&rejectUnauthorized=boolean&ca=/path/to/file&pfx=/path/to/file&cert=/path/to/file&key=/path/to/file&passphrase=string&secureOptions=number&client_encoding=string&application_name=string&fallback_application_name=string&max=number&query_timeout=idleTimeoutMillis=number&poolSize=number&binary=boolean&keepAlive=boolean
3535
```
3636

37+
When using Postgres with your Parse app, you need to manage your indexes yourself.
38+
3739
Details about the configuration options can be found on [pg-promise](https://github.com/vitaly-t/pg-promise/wiki/Connection-Syntax). Some useful combinations are below:
3840

3941
* SSL with verification - `postgres://localhost:5432/db?ca=/path/to/file`
4042
* SSL with no verification - `postgres://localhost:5432/db?ssl=true&rejectUnauthorized=false`
4143

4244
### Caveats
4345

46+
* You will need to configure a [file adapter](#configuring-file-adapters) in order to store files.
4447
* Join tables are resolved in memory, there is no performance improvements using Postgres over MongoDB for relations or pointers.
4548
* Mutating the schema implies running ALTER TABLE, therefore we recommend you setup your schema when your tables are not full.
46-
* Properly index your tables to maximize the performance.
4749
* The postgres URL for 4.2.0 and below only supports the following configuration options:
4850

4951
```

_includes/parse-server/file-adapters.md

+36-40
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@ When using `Postgres`, you will need to configure `S3Adapter`, `GCSAdapter`, or
1717

1818
If you are using `Mongo` and don't need file encryption, there are no additional steps needed to use the `GridStoreAdapter`. If you'd like to enable file encryption follow these instructions to configure Parse Server to use `GridStoreAdapter` with file encryption.
1919

20-
***Notice: If you are coming from an older version of Parse Server versions <= 4.2.0, you should remove `fileKey` from your configurations as it is not being used anyways since legacy parse.com. `fileKey` has been repurposed for file encryption.***
21-
22-
### Set up file encryption (available in parse-server 4.3.0+)
23-
The `GridStoreAdapter` can encrypt files at rest in `Mongo` using AES256-GCM, allowing the adapter to detect if files are tampered with.
20+
### Set up file encryption
21+
File encryption is available in parse-server 4.4.0+. The `GridStoreAdapter` can encrypt files at rest in `Mongo` using AES256-GCM, allowing the adapter to detect if files are tampered with.
2422

2523
To use, simply do any of the following:
26-
- Use the environment variable `PARSE_SERVER_FILE_KEY`
27-
- Pass in --fileKey in the command line when starting your server
28-
- Initialize ParseServer with `fileKey="Your file encryptionKey"`.
24+
- Use the environment variable `PARSE_SERVER_ENCRYPTION_KEY`
25+
- Pass in --encryptionKey in the command line when starting your server
26+
- Initialize ParseServer with `encryptionKey="Your file encryptionKey"`.
2927

3028
An example starting your Parse Server in `index.js` is below:
3129

@@ -35,61 +33,61 @@ const api = new ParseServer({
3533
cloud: process.env.PARSE_SERVER_CLOUD || __dirname + '/cloud/main.js',
3634
appId: process.env.PARSE_SERVER_APPLICATION_ID || 'myAppId',
3735
masterKey: process.env.PARSE_SERVER_MASTER_KEY || '',
38-
fileKey: process.env.PARSE_SERVER_FILE_KEY, //Add your file key here. Keep it secret
36+
encryptionKey: process.env.PARSE_SERVER_ENCRYPTION_KEY, //Add your file key here. Keep it secret
3937
...
4038
});
4139
```
4240

4341
Be sure not to lose your key or change it after encrypting files.
4442

45-
### Enabling encryption on a server that already has unencrypted files (available in parse-server 4.4.0+)
43+
### Enabling encryption on a server that already has unencrypted files
4644
When this is the case, it is recommended to start up a development parse-server (or a separate process from your main process) that has the same configuration as your production server. On the development server, initialize the file adapter as above with the new key and do the following after initialization in your `index.js`:
4745

4846
```javascript
4947
//You probably want to back up your unencrypted files before doing this.
5048
//This can take awhile depending on how many files and how large they are. It will attempt to rotate the key of all files in your filesSubDirectory
51-
const {rotated, notRotated} = await api.filesAdapter.rotateFileKey();
49+
const {rotated, notRotated} = await api.filesAdapter.rotateEncryptionKey();
5250
console.log('Files rotated to newKey: ' + rotated);
5351
console.log('Files that couldn't be rotated to newKey: ' + notRotated);
5452
```
5553
56-
### Rotating your encryption key (available in parse-server 4.4.0+)
57-
Periodically you may want to rotate your fileKey for security reasons. When this is the case, it is recommended to start up a development parse-server (or a separate process from your main process) that has the same configuration as your production server. On the development server, initialize the file adapter with the new key and do the following in your `index.js` (you will need your `oldKey`):
54+
### Rotating your encryption key
55+
Periodically you may want to rotate your encryptionKey for security reasons. When this is the case, it is recommended to start up a development parse-server (or a separate process from your main process) that has the same configuration as your production server. On the development server, initialize the file adapter with the new key and do the following in your `index.js` (you will need your `oldKey`):
5856
5957
```javascript
6058
//This can take awhile depending on how many files and how large they are. It will attempt to rotate the key of all files in your filesSubDirectory
61-
const {rotated, notRotated} = await api.filesAdapter.rotateFileKey({oldKey: oldKey});
59+
const {rotated, notRotated} = await api.filesAdapter.rotateEncryptionKey({oldKey: oldKey});
6260
console.log('Files rotated to newKey: ' + rotated);
6361
console.log('Files that couldn't be rotated to newKey: ' + notRotated);
6462
```
6563

66-
### Removing file encryption (available in parse-server 4.4.0+)
67-
When this is the case, it is recommended to start up a development parse-server (or a separate process from your main process) that has the same configuration as your production server. Different from the previous examples, don't initialize your fileAdapter with a `fileKey`. Pass in your `oldKey` to `rotateFileKey()`.
64+
### Removing file encryption
65+
When this is the case, it is recommended to start up a development parse-server (or a separate process from your main process) that has the same configuration as your production server. Different from the previous examples, don't initialize your fileAdapter with a `encryptionKey`. Pass in your `oldKey` to `rotateEncryptionKey()`.
6866

6967
```javascript
7068
const api = new ParseServer({
7169
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
7270
cloud: process.env.PARSE_SERVER_CLOUD || __dirname + '/cloud/main.js',
7371
appId: process.env.PARSE_SERVER_APPLICATION_ID || 'myAppId',
7472
masterKey: process.env.PARSE_SERVER_MASTER_KEY || '',
75-
//No fileKey here
73+
//No encryptionKey here
7674
...
7775
});
7876

7977
//This can take awhile depending on how many files and how larger they are. It will attempt to rotate the key of all files in your filesSubDirectory
8078
//It is not recommended to do this on the production server, deploy a development server to complete the process.
81-
const {rotated, notRotated} = await api.filesAdapter.rotateFileKey({oldKey: oldKey});
79+
const {rotated, notRotated} = await api.filesAdapter.rotateEncryptionKey({oldKey: oldKey});
8280
console.log('Files rotated to unencrypted with noKey: ' + rotated);
8381
console.log('Files that couldn't be rotated to unencrypted with noKey: ' + notRotated);
8482
8583
```
8684
8785
### Rotating the key for a subset of files
88-
This is useful if for some reason there were errors and some of the files weren't rotated and returned in `notRotated`. The process is the same as the previous examples, but pass in your `oldKey` along with the array of `fileNames` to `rotateFileKey()`.
86+
This is useful if for some reason there were errors and some of the files weren't rotated and returned in `notRotated`. The process is the same as the previous examples, but pass in your `oldKey` along with the array of `fileNames` to `rotateEncryptionKey()`.
8987

9088
```javascript
9189
//This can take awhile depending on how many files and how large they are. It will attempt to rotate the key of all files in your filesSubDirectory
92-
const {rotated, notRotated} = await api.filesAdapter.rotateFileKey({oldKey: oldKey, fileNames: ["fileName1.png","fileName2.png"]});
90+
const {rotated, notRotated} = await api.filesAdapter.rotateEncryptionKey({oldKey: oldKey, fileNames: ["fileName1.png","fileName2.png"]});
9391
console.log('Files rotated to newKey: ' + rotated);
9492
console.log('Files that couldn't be rotated to newKey: ' + notRotated);
9593
```
@@ -308,13 +306,13 @@ new GCSAdapter(projectId, keyfilePath, bucket, options)
308306

309307
## Configuring `FSAdapter`
310308

311-
To use the `FSAdapter`, simply initialize your Parse Server in `index.js` by doing the following:
309+
To use the [FSAdapter](https://github.com/parse-community/parse-server-fs-adapter), simply initialize your Parse Server in `index.js` by doing the following:
312310

313311
```javascript
314312
var FSFilesAdapter = require('@parse/fs-files-adapter');
315313

316314
var fsAdapter = new FSFilesAdapter({
317-
"filesSubDirectory": "my/files/folder" // optional
315+
"filesSubDirectory": "my/files/folder" // optional, defaults to ./files
318316
});
319317

320318
var api = new ParseServer({
@@ -324,22 +322,20 @@ var api = new ParseServer({
324322
})
325323
```
326324

327-
***Notice: If used with Parse Server versions <= 4.2.0, DO NOT PASS in `PARSE_SERVER_FILE_KEY` or `fileKey` from parse-server. Instead pass your key directly to `FSFilesAdapter` using your own environment variable or hardcoding the string. Parse Server versions 4.3.0+ can pass in `PARSE_SERVER_FILE_KEY` or `fileKey`.***
328-
329325
### Using `FSAdapter` with multiple instances of Parse Server
330-
When using parse-server-fs-adapter across multiple Parse Server instances it's important to establish "centralization" of your file storage (this is the same premise as the other file adapters, you are sending/recieving files through a dedicated link). You can accomplish this at the file storage level by Samba mounting (or any other type of mounting) your storage to each of your parse-server instances, e.g if you are using Parse Server via docker (volume mount your SMB drive to `- /Volumes/SMB-Drive/MyParseApp1/files:/parse-server/files`). All Parse Server instances need to be able to read/write to the same storage in order for parse-server-fs-adapter to work properly with parse-server. If the file storage isn't centralized, parse-server will have trouble locating files and you will get random behavior on client-side.
326+
When using [parse-server-fs-adapter](https://github.com/parse-community/parse-server-fs-adapter) across multiple Parse Server instances it's important to establish "centralization" of your file storage (this is the same premise as the other file adapters, you are sending/recieving files through a dedicated link). You can accomplish this at the file storage level by Samba mounting (or any other type of mounting) your storage to each of your parse-server instances, e.g if you are using Parse Server via docker (volume mount your SMB drive to `- /Volumes/SMB-Drive/MyParseApp1/files:/parse-server/files`). All Parse Server instances need to be able to read/write to the same storage in order for parse-server-fs-adapter to work properly with parse-server. If the file storage isn't centralized, parse-server will have trouble locating files and you will get random behavior on client-side.
331327

332-
### Set up file encryption (available in parse-server-fs-adapter 1.1.0+)
333-
The `FSAdapter` can encrypt files at rest for local storage using AES256-GCM, allowing the adapter to detect if files are tampered with.
328+
### Set up file encryption
329+
File encryption is available in parse-server-fs-adapter 1.1.0+. The `FSAdapter` can encrypt files at rest for local storage using AES256-GCM, allowing the adapter to detect if files are tampered with.
334330

335-
To use, simply do the same as above, but add a `fileKey`:
331+
To use, simply do the same as above, but add a `encryptionKey`:
336332

337333
```javascript
338334
var FSFilesAdapter = require('@parse/fs-files-adapter');
339335

340336
var fsAdapter = new FSFilesAdapter({
341-
"filesSubDirectory": "my/files/folder", // optional
342-
"fileKey": "someKey" //mandatory if you want to encrypt files
337+
"filesSubDirectory": "my/files/folder", // optional, defaults to ./files
338+
"encryptionKey": "someKey" //mandatory if you want to encrypt files
343339
});
344340

345341
var api = new ParseServer({
@@ -351,54 +347,54 @@ var api = new ParseServer({
351347

352348
Be sure not to lose your key or change it after encrypting files.
353349

354-
### Enabling encryption on a server that already has unencrypted files (available in parse-server-fs-adapter 1.1.0+)
350+
### Enabling encryption on a server that already has unencrypted files
355351
When this is the case, it is recommended to start up a development parse-server (or a separate process from your main process) that has the same configuration as your production server. On the development server, initialize the file adapter as above with the new key and do the following after initialization in your `index.js`:
356352

357353
```javascript
358354
//You probably want to back up your unencrypted files before doing this.
359355
//This can take awhile depending on how many files and how large they are. It will attempt to rotate the key of all files in your filesSubDirectory
360-
const {rotated, notRotated} = await api.filesAdapter.rotateFileKey();
356+
const {rotated, notRotated} = await api.filesAdapter.rotateEncryptionKey();
361357
console.log('Files rotated to newKey: ' + rotated);
362358
console.log('Files that couldn't be rotated to newKey: ' + notRotated);
363359
```
364360
365-
### Rotating your encryption key (available in parse-server-fs-adapter 1.1.0+)
366-
Periodically you may want to rotate your `fileKey` for security reasons. When this is the case, it is recommended to start up a development parse-server (or a separate process from your main process) that has the same configuration as your production server. On the development server, initialize the file adapter with the new key and do the following in your `index.js` (you will need your `oldKey`):
361+
### Rotating your encryption key
362+
Periodically you may want to rotate your `encryptionKey` for security reasons. When this is the case, it is recommended to start up a development parse-server (or a separate process from your main process) that has the same configuration as your production server. On the development server, initialize the file adapter with the new key and do the following in your `index.js` (you will need your `oldKey`):
367363
368364
```javascript
369365
//This can take awhile depending on how many files and how large they are. It will attempt to rotate the key of all files in your filesSubDirectory
370-
const {rotated, notRotated} = await api.filesAdapter.rotateFileKey({oldKey: oldKey});
366+
const {rotated, notRotated} = await api.filesAdapter.rotateEncryptionKey({oldKey: oldKey});
371367
console.log('Files rotated to newKey: ' + rotated);
372368
console.log('Files that couldn't be rotated to newKey: ' + notRotated);
373369
```
374370

375-
### Removing file encryption (available in parse-server-fs-adapter 1.1.0+)
376-
When this is the case, it is recommended to start up a development parse-server (or a separate process from your main process) that has the same configuration as your production server. Different from the previous examples, don't initialize your fileAdapter with a `fileKey`. Pass in your `oldKey` to `rotateFileKey()`.
371+
### Removing file encryption
372+
When this is the case, it is recommended to start up a development parse-server (or a separate process from your main process) that has the same configuration as your production server. Different from the previous examples, don't initialize your fileAdapter with a `encryptionKey`. Pass in your `oldKey` to `rotateEncryptionKey()`.
377373

378374
```javascript
379375
const api = new ParseServer({
380376
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
381377
cloud: process.env.PARSE_SERVER_CLOUD || __dirname + '/cloud/main.js',
382378
appId: process.env.PARSE_SERVER_APPLICATION_ID || 'myAppId',
383379
masterKey: process.env.PARSE_SERVER_MASTER_KEY || '',
384-
filesAdapter: new FSFilesAdapter(), //No fileKey supplied
380+
filesAdapter: new FSFilesAdapter(), //No encryptionKey supplied
385381
...
386382
});
387383

388384
//This can take awhile depending on how many files and how larger they are. It will attempt to rotate the key of all files in your filesSubDirectory
389385
//It is not recommended to do this on the production server, deploy a development server to complete the process.
390-
const {rotated, notRotated} = await api.filesAdapter.rotateFileKey({oldKey: oldKey});
386+
const {rotated, notRotated} = await api.filesAdapter.rotateEncryptionKey({oldKey: oldKey});
391387
console.log('Files rotated to unencrypted with noKey: ' + rotated);
392388
console.log('Files that couldn't be rotated to unencrypted with noKey: ' + notRotated);
393389
394390
```
395391
396392
### Rotating the key for a subset of files
397-
This is useful if for some reason there were errors and some of the files weren't rotated and returned in `notRotated`. The process is the same as the previous examples, but pass in your `oldKey` along with the array of `fileNames` to `rotateFileKey()`.
393+
This is useful if for some reason there were errors and some of the files weren't rotated and returned in `notRotated`. The process is the same as the previous examples, but pass in your `oldKey` along with the array of `fileNames` to `rotateEncryptionKey()`.
398394

399395
```javascript
400396
//This can take awhile depending on how many files and how large they are. It will attempt to rotate the key of all files in your filesSubDirectory
401-
const {rotated, notRotated} = await api.filesAdapter.rotateFileKey({oldKey: oldKey, fileNames: ["fileName1.png","fileName2.png"]});
397+
const {rotated, notRotated} = await api.filesAdapter.rotateEncryptionKey({oldKey: oldKey, fileNames: ["fileName1.png","fileName2.png"]});
402398
console.log('Files rotated to newKey: ' + rotated);
403399
console.log('Files that couldn't be rotated to newKey: ' + notRotated);
404400
```

0 commit comments

Comments
 (0)