# CrushOIDC: a VFS from the sign-in

When somebody signs in through [CrushOIDC](Plugin-CrushOIDC.md), the provider can hand the server a token that opens that person's own cloud storage. The server can then show each user their Google Drive, their OneDrive or their Dropbox as a folder, with exactly the rights the person has there, and with no storage password kept anywhere.

The person signs in once. Their files, at their provider, appear in the server's web interface.

## What is needed

| At | Needed |
|---|---|
| the provider | the application you registered must be allowed to reach the storage: more **scopes** at Google and Dropbox, more **API permissions** at Microsoft |
| the plugin | **Get Refresh Token?** on, the storage scopes added to **Scope**, and **Custom VFS?** with a **Path** that is the address of the storage |
| the person | consents once, on the provider's page, to the server reaching their files |

**Get Refresh Token?** changes the address the browser is sent to, so that the provider gives a lasting token and shows the consent page.

## The address

**Path** is the address of the storage, written with parts in braces that the plugin fills in at each sign-in:

| Part | Is |
|---|---|
| `{oidc_client_id}` | the **Client ID** of the plugin |
| `{oidc_client_secret_decoded}` | the **Client Secret**, as it is |
| `{oidc_client_secret_encoded}` | the **Client Secret**, made safe for use inside an address |
| `{oidc_refresh_token}` | the token of the person who just signed in. It is only there with **Get Refresh Token?** on. |

| Storage | **Path** | Scope to add |
|---|---|---|
| Google Drive | `gdrive://{oidc_client_id}~{oidc_client_secret_decoded}:{oidc_refresh_token}@www.google.com/` | `https://www.googleapis.com/auth/drive` |
| Google Cloud Storage | `gstorage://{oidc_client_id}~{oidc_client_secret_decoded}:{oidc_refresh_token}@storage.googleapis.com/` | `https://www.googleapis.com/auth/devstorage.full_control` |
| OneDrive, personal | `onedrive://{oidc_client_id}~{oidc_client_secret_encoded}:{oidc_refresh_token}@graph.microsoft.com/` | none: API permissions in the app registration |
| SharePoint, as the person | `sharepoint://{oidc_client_id}~{oidc_client_secret_encoded}:{oidc_refresh_token}@graph.microsoft.com/` | none: API permissions |
| SharePoint, by its own interface | `sharepoint2://delegated_permission~{oidc_client_id}~{oidc_client_secret_encoded}:{oidc_refresh_token}@graph.microsoft.com/` | none: API permissions |
| Dropbox | `dropbox://{oidc_client_id}~{oidc_client_secret_decoded}:{oidc_refresh_token}@api.dropboxapi.com/` | `files.metadata.write files.content.write files.content.read` |

Leave **Append username to path?** off: the token already leads to that person's storage.

When **Path** is such an address, the screen shows the options that kind of storage has, the same as in a user's VFS: for SharePoint the tenant, the site, the site's path, the library and the folder. They are described with each kind of storage: [Google Drive](VFS-Google-Drive.md), [Google Cloud Storage](VFS-Google-Cloud-Storage.md), [OneDrive](VFS-OneDrive.md), [SharePoint](VFS-SharePoint.md), [Dropbox](VFS-Dropbox.md).

## Without the person: the application's own rights

For OneDrive for Business and SharePoint, the storage can also be reached with rights given to the application itself, by an administrator. No token of the person is used:

| Storage | **Path** |
|---|---|
| OneDrive for Business | `onedrive://app_permission~{oidc_client_id}:{oidc_client_secret_decoded}@graph.microsoft.com/` |
| SharePoint | `sharepoint://app_permission~{oidc_client_id}:{oidc_client_secret_decoded}@graph.microsoft.com/` |

For OneDrive, the options then ask whose drive: give `{user_name}`, so that each person gets their own.

Here the application can reach everybody's files, and the server decides whose are shown. Rights of the person at Microsoft do not limit it. Prefer the person's own token where you can.

## Things to know

- **The token is the person's key to their files.** The server keeps it for the length of the session and hands it back to the provider at the end, through the **Revocation Endpoint URL**. Leave that field as it is.
- **Consent is asked again at every sign-in** with **Get Refresh Token?**, because the address asks for it. That is the price of the lasting token.
- **Google reviews applications that ask for Drive.** Until the review is done, only test users can consent.
- **Rights are the provider's.** What the person may not open at the provider, they cannot open here. The **Privs** of the plugin can only take away more.
- **Speed.** Every listing is a call to the provider. A folder with thousands of items is slower than on a disk.
- **For a fixed storage that all users share**, none of this is needed: put the storage into a template user's [VFS](VFS.md) with its own login.

## Not tried for this page

No provider and no cloud storage was connected to the test server. The addresses are those of the earlier documentation; the rest is from the plugin's screen.
