From 926b3ee4fa6b39df759958f6c2da14d7f078dcc9 Mon Sep 17 00:00:00 2001 From: "Ifedapo .A. Olarewaju" Date: Mon, 13 May 2019 15:46:52 +0100 Subject: [PATCH] docs: document Companions Auth and Token mechanism (#1540) --- website/src/docs/companion.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/website/src/docs/companion.md b/website/src/docs/companion.md index 7f1109249..863098892 100644 --- a/website/src/docs/companion.md +++ b/website/src/docs/companion.md @@ -333,3 +333,22 @@ This would get the Companion instance running on `http://localhost:3020`. It use ## Live example An example server is running at https://companion.uppy.io, which is deployed with [Kubernetes](https://github.com/transloadit/uppy/blob/master/packages/%40uppy/companion/KUBERNETES.md) + + +## How the Authentication and Token mechanism works + +This section describes how Authentication works between Companion and Providers. While this behaviour is the same for all Providers (Dropbox, Instagram, Google Drive), we are going to be referring to Dropbox in place of any Provider throughout this section. + +The following steps describe the actions that take place when a user Authenticates and Uploads from Dropbox through Companion: + +- The visitor to a website with Uppy clicks "Connect to Dropbox". +- Uppy sends a request to Companion, which in turn sends an OAuth request to Dropbox (Requires that OAuth credentials from Dropbox have been added to Companion). +- Dropbox asks the visitor to log in, and whether the Website should be allowed to access your files +- If the visitor agrees, Companion will receive a token from Dropbox, with which we can temporarily download files. +- Companion encrypts the token with a secret key and sends the encrypted token to Uppy (client) +- Every time the visitor clicks on a folder in Uppy, it asks Companion for the new list of files, with this question, the token (still encrypted by Companion) is sent along. +- Companion decrypts the token, requests the list of files from Dropbox and sends it to Uppy. +- When a file is selected for upload, Companion receives the token again according to this procedure, decrypts it again, and thereby downloads the file from Dropbox. +- As the bytes arrive, Companion uploads the bytes to the final destination (depending on the configuration: Apache, a Tus server, S3 bucket, etc). +- Companion reports progress to Uppy, as if it were a local upload. +- Completed!