mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-30 05:23:05 +00:00
Small companion code and doc changes (#3586)
* move migration guide for companion * improve doc * add comment about session usage * remove unused options.multipleInstances
This commit is contained in:
parent
d729cc4caa
commit
c1407070fb
5 changed files with 41 additions and 38 deletions
|
|
@ -79,7 +79,7 @@ module.exports.app = (optionsArg = {}) => {
|
|||
if (options.redisUrl) {
|
||||
redis.client(merge({ url: options.redisUrl }, options.redisOptions || {}))
|
||||
}
|
||||
emitter(options.multipleInstances && options.redisUrl, options.redisPubSubScope)
|
||||
emitter(options.redisUrl, options.redisPubSubScope)
|
||||
|
||||
const app = express()
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@ const getConfigFromEnv = () => {
|
|||
allowLocalUrls: process.env.COMPANION_ALLOW_LOCAL_URLS === 'true',
|
||||
// cookieDomain is kind of a hack to support distributed systems. This should be improved but we never got so far.
|
||||
cookieDomain: process.env.COMPANION_COOKIE_DOMAIN,
|
||||
multipleInstances: true,
|
||||
streamingUpload: process.env.COMPANION_STREAMING_UPLOAD === 'true',
|
||||
maxFileSize: process.env.COMPANION_MAX_FILE_SIZE ? parseInt(process.env.COMPANION_MAX_FILE_SIZE, 10) : undefined,
|
||||
chunkSize: process.env.COMPANION_CHUNK_SIZE ? parseInt(process.env.COMPANION_CHUNK_SIZE, 10) : undefined,
|
||||
|
|
|
|||
|
|
@ -153,6 +153,10 @@ module.exports = function server (inputCompanionOptions = {}) {
|
|||
}
|
||||
}
|
||||
|
||||
// Session is used for grant redirects, so that we don't need to expose secret tokens in URLs
|
||||
// See https://github.com/transloadit/uppy/pull/1668
|
||||
// https://github.com/transloadit/uppy/issues/3538#issuecomment-1069232909
|
||||
// https://github.com/simov/grant#callback-session
|
||||
router.use(session(sessionOptions))
|
||||
|
||||
// Routes
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ const options = {
|
|||
|
||||
* `protocol` - `http | https` - even though companion itself always runs as http, you may want to set this to `https` if you are running a reverse https proxy in front of companion.
|
||||
* `host` (required) - your server’s publically facing hostname (for example `example.com`).
|
||||
* `oauthDomain` - if you have several instances of Companion with different (and perhaps dynamic) subdomains, you can set a single fixed domain (e.g `sub1.example.com`) to handle your OAuth authentication for you. This would then redirect back to the correct instance with the required credentials on completion. This way you only need to configure a single callback URL for OAuth providers.
|
||||
* `oauthDomain` - if you have several instances of Companion with different (and perhaps dynamic) subdomains, you can set a single fixed subdomain and server (e.g `sub1.example.com`) to handle your OAuth authentication for you. This would then redirect back to the correct instance with the required credentials on completion. This way you only need to configure a single callback URL for OAuth providers.
|
||||
* `path` - the server path to where the Uppy app is sitting (e.g if Companion is at `example.com/companion`, then the path would be `/companion`).
|
||||
* `implicitPath` - if the URL’s path in your reverse proxy is different from your Companion path in your express app, then you need to set this path as `implicitPath`. So if your Companion URL is `example.com/mypath/companion`. Where the path `/mypath` is defined in your NGINX server, while `/companion` is set in your express app. Then you need to set the option `implicitPath` to `/mypath`, and set the `path` option to `/companion`.
|
||||
* `validHosts` - if you are setting an `oauthDomain`, you need to set a list of valid hosts, so the oauth handler can validate the host of the Uppy instance requesting the authentication. This is essentially a list of valid domains running your Companion instances. The list may also contain regex patterns. e.g `['sub2.example.com', 'sub3.example.com', '(\\w+).example.com']`
|
||||
|
|
@ -541,41 +541,6 @@ See also [example code with a custom provider](https://github.com/transloadit/up
|
|||
}
|
||||
```
|
||||
|
||||
## Migrating v1 to v2
|
||||
|
||||
### Prerequisite
|
||||
|
||||
Since v2, you now need to be running `node.js >= v10.20.1` to use Companion.
|
||||
|
||||
### ProviderOptions
|
||||
|
||||
In v2 the `google` and `microsoft` [providerOptions](https://uppy.io/docs/companion/#Options) have been changed to `drive` and `onedrive` respectively.
|
||||
|
||||
### OAuth Redirect URIs
|
||||
|
||||
On your Providers’ respective developer platforms, the OAuth redirect URIs that you should supply has now changed from:
|
||||
|
||||
`http(s)://$COMPANION_HOST_NAME/connect/$AUTH_PROVIDER/callback` in v1
|
||||
|
||||
to:
|
||||
|
||||
`http(s)://$COMPANION_HOST_NAME/$PROVIDER_NAME/redirect` in v2
|
||||
|
||||
#### New Redirect URIs
|
||||
|
||||
<div class="table-responsive">
|
||||
|
||||
| Provider | New Redirect URI
|
||||
|-|-|
|
||||
| Dropbox | `https://$COMPANION_HOST_NAME/dropbox/redirect` |
|
||||
| Google Drive | `https://$COMPANION_HOST_NAME/drive/redirect` |
|
||||
| OneDrive | `https://$COMPANION_HOST_NAME/onedrive/redirect` |
|
||||
| Box | `https://$YOUR_COMPANION_HOST_NAME/box/redirect` |
|
||||
| Facebook | `https://$COMPANION_HOST_NAME/facebook/redirect` |
|
||||
| Instagram | `https://$COMPANION_HOST_NAME/instagram/redirect` |
|
||||
|
||||
</div>
|
||||
|
||||
## Development
|
||||
|
||||
1\. To set up Companion for local development, please clone the Uppy repo and install, like so:
|
||||
|
|
|
|||
|
|
@ -247,6 +247,41 @@ Uppy 1.0 will continue to receive bug fixes for three more months (until <time d
|
|||
|
||||
We hope you’ll waste no time in taking Uppy 2.0 out for a walk. When you do, please let us know what you thought of it on [Reddit](https://www.reddit.com/r/javascript/comments/penbr7/uppy_file_uploader_20_smaller_and_faster_modular/), [HN](https://news.ycombinator.com/item?id=28359287), ProductHunt, or [Twitter](https://twitter.com/uppy_io/status/1432399270846603264). We’re howling at the moon to hear from you!
|
||||
|
||||
## Migrating Companion v1 to v2
|
||||
|
||||
### Prerequisite
|
||||
|
||||
Since v2, you now need to be running `node.js >= v10.20.1` to use Companion.
|
||||
|
||||
### ProviderOptions
|
||||
|
||||
In v2 the `google` and `microsoft` [providerOptions](https://uppy.io/docs/companion/#Options) have been changed to `drive` and `onedrive` respectively.
|
||||
|
||||
### OAuth Redirect URIs
|
||||
|
||||
On your Providers’ respective developer platforms, the OAuth redirect URIs that you should supply has now changed from:
|
||||
|
||||
`http(s)://$COMPANION_HOST_NAME/connect/$AUTH_PROVIDER/callback` in v1
|
||||
|
||||
to:
|
||||
|
||||
`http(s)://$COMPANION_HOST_NAME/$PROVIDER_NAME/redirect` in v2
|
||||
|
||||
#### New Redirect URIs
|
||||
|
||||
<div class="table-responsive">
|
||||
|
||||
| Provider | New Redirect URI
|
||||
|-|-|
|
||||
| Dropbox | `https://$COMPANION_HOST_NAME/dropbox/redirect` |
|
||||
| Google Drive | `https://$COMPANION_HOST_NAME/drive/redirect` |
|
||||
| OneDrive | `https://$COMPANION_HOST_NAME/onedrive/redirect` |
|
||||
| Box | `https://$YOUR_COMPANION_HOST_NAME/box/redirect` |
|
||||
| Facebook | `https://$COMPANION_HOST_NAME/facebook/redirect` |
|
||||
| Instagram | `https://$COMPANION_HOST_NAME/instagram/redirect` |
|
||||
|
||||
</div>
|
||||
|
||||
<!-- definitions -->
|
||||
|
||||
[core]: /docs/uppy/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue