Use Cloudflare Workers with Rclone to Deploy A Cloud Drive Index & List App - OnePoint - NETSEC

Latest

Learning, Sharing, Creating

Cybersecurity Memo

Saturday, May 28, 2022

Use Cloudflare Workers with Rclone to Deploy A Cloud Drive Index & List App - OnePoint

OnePoint is a lightweight, multi-platform, multi-net disk file directory index (and management) tool. Support cloud disk onedrive, googledrive, coding, teambition, node_fs, alidrive, etc.

My Github page: https://github.com/51sec/onepoint  Demo: https://od.51sec.org/

Original Github page: https://github.com/ukuq/onepoint  Demo: https://one.loc.workers.dev/

The nice part for this solution is the backend running on Cloudflare and you do not even need a server to host any configuration files or frontend web pages. 


Related Posts:



Demo

 Demo Page:


Related Posts:

Introduction

Project Features

Lightweight, multi-platform, multi-network disk

Support cloud disks

  • onedrive

  • googledrive

  • coding

  • teambition

  • node_fs

  • alidrive



Deploy on Cloudflare Worker

 

1 Create a new worker from Cloudflare website

image.png2 Paste the code

https://github.com/51sec/onepoint/blob/master/ncc/ncc_cf-worker.js

or https://raw.githubusercontent.com/51sec/onepoint/master/ncc/ncc_cf-worker.js

There are a lot of codes, it may take some time to save, don't worry!

image.png


3 Go back to the previous page and create a new KV bucket with any name.

image.png image.png


4 Bind the KV bucket and set the variable name to OPCONFIG

image.png

Note: If there is any setting you can't change from admin page, you will be able to find it from KV value for op-config. For example, the name of your cloud drive.



Deploy on your own server

github beta (2.0.0)

  
git clone https://github.com/ukuq/onepoint.git
cd onepoint && npm install

npm start
# pm2 lib/starters/node-http.js

Backend Admin Page Operations

Here I am using OneDrive as an example to show how to add your cloud drive into your own OnePoint project:

1 Generate OneDrive Share link: 


2 Log into OnePoint Admin page:


3 Click More Configuration - +Add



4 Add new cloud drive page 1:


5 Add Cloud Disk Page 2:

For refresh_token, you can get it by clicking the link "Click here acquire refresh_token"


Get the sharing url from OneDrive Web Portal:

You also can change #root configuration from / to a subfolder, such as above page's Sharing folder. In this case, you will only shows the content under Sharing folder from OnePoint web gui. 

Here is the page to generate refresh token. It is coming from https://point.onesrc.cn/oauth2/. You will need to enter your OneDrive account's credential to log in for this refresh token.
Note: the above link is not working anymore. To get the refresh token, you might want to check the section for manually using Rclone to get refresh-token.


6  Save the configuration



Using Rclone manually to get refresh-token from OneDrive

 It is also quite easy to use Rclone to get refresh token. Here is the output from one of my example to get OneDrive refresh-token:

D:\Tools\rclone-v1.60.1-windows-amd64>rclone config
Current remotes:

Name                 Type
====                 ====
yyyjjjj              drive

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> n

Enter name for new remote.
name> od-jyan

Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
 1 / 1Fichier
   \ (fichier)
 2 / Akamai NetStorage
   \ (netstorage)
 3 / Alias for an existing remote
   \ (alias)
 4 / Amazon Drive
   \ (amazon cloud drive)
 5 / Amazon S3 Compliant Storage Providers including AWS, Alibaba, Ceph, China Mobile, Cloudflare, ArvanCloud, Digital Ocean, Dreamhost, Huawei OBS, IBM COS, IDrive e2, IONOS Cloud, Lyve Cloud, Minio, Netease, RackCorp, Scaleway, SeaweedFS, StackPath, Storj, Tencent COS, Qiniu and Wasabi
   \ (s3)
 6 / Backblaze B2
   \ (b2)
 7 / Better checksums for other remotes
   \ (hasher)
 8 / Box
   \ (box)
 9 / Cache a remote
   \ (cache)
10 / Citrix Sharefile
   \ (sharefile)
11 / Combine several remotes into one
   \ (combine)
12 / Compress a remote
   \ (compress)
13 / Dropbox
   \ (dropbox)
14 / Encrypt/Decrypt a remote
   \ (crypt)
15 / Enterprise File Fabric
   \ (filefabric)
16 / FTP
   \ (ftp)
17 / Google Cloud Storage (this is not Google Drive)
   \ (google cloud storage)
18 / Google Drive
   \ (drive)
19 / Google Photos
   \ (google photos)
20 / HTTP
   \ (http)
21 / Hadoop distributed file system
   \ (hdfs)
22 / HiDrive
   \ (hidrive)
23 / In memory object storage system.
   \ (memory)
24 / Internet Archive
   \ (internetarchive)
25 / Jottacloud
   \ (jottacloud)
26 / Koofr, Digi Storage and other Koofr-compatible storage providers
   \ (koofr)
27 / Local Disk
   \ (local)
28 / Mail.ru Cloud
   \ (mailru)
29 / Mega
   \ (mega)
30 / Microsoft Azure Blob Storage
   \ (azureblob)
31 / Microsoft OneDrive
   \ (onedrive)
32 / OpenDrive
   \ (opendrive)
33 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ (swift)
34 / Oracle Cloud Infrastructure Object Storage
   \ (oracleobjectstorage)
35 / Pcloud
   \ (pcloud)
36 / Put.io
   \ (putio)
37 / QingCloud Object Storage
   \ (qingstor)
38 / SMB / CIFS
   \ (smb)
39 / SSH/SFTP
   \ (sftp)
40 / Sia Decentralized Cloud
   \ (sia)
41 / Storj Decentralized Cloud Storage
   \ (storj)
42 / Sugarsync
   \ (sugarsync)
43 / Transparently chunk/split large files
   \ (chunker)
44 / Union merges the contents of several upstream fs
   \ (union)
45 / Uptobox
   \ (uptobox)
46 / WebDAV
   \ (webdav)
47 / Yandex Disk
   \ (yandex)
48 / Zoho
   \ (zoho)
49 / premiumize.me
   \ (premiumizeme)
50 / seafile
   \ (seafile)
Storage> 31

Option client_id.
OAuth Client Id.
Leave blank normally.
Enter a value. Press Enter to leave empty.
client_id>

Option client_secret.
OAuth Client Secret.
Leave blank normally.
Enter a value. Press Enter to leave empty.
client_secret>

Option region.
Choose national cloud region for OneDrive.
Choose a number from below, or type in your own string value.
Press Enter for the default (global).
 1 / Microsoft Cloud Global
   \ (global)
 2 / Microsoft Cloud for US Government
   \ (us)
 3 / Microsoft Cloud Germany
   \ (de)
 4 / Azure and Office 365 operated by Vnet Group in China
   \ (cn)
region> 1

Edit advanced config?
y) Yes
n) No (default)
y/n> n

Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine

y) Yes (default)
n) No
y/n> y

2022/12/20 14:40:20 NOTICE: If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=tzNs37tODGuoaQrg79LACA
2022/12/20 14:40:20 NOTICE: Log in and authorize rclone for access
2022/12/20 14:40:20 NOTICE: Waiting for code...
2022/12/20 14:40:23 NOTICE: Got code
Option config_type.
Type of connection
Choose a number from below, or type in an existing string value.
Press Enter for the default (onedrive).
 1 / OneDrive Personal or Business
   \ (onedrive)
 2 / Root Sharepoint site
   \ (sharepoint)
   / Sharepoint site name or URL
 3 | E.g. mysite or https://contoso.sharepoint.com/sites/mysite
   \ (url)
 4 / Search for a Sharepoint site
   \ (search)
 5 / Type in driveID (advanced)
   \ (driveid)
 6 / Type in SiteID (advanced)
   \ (siteid)
   / Sharepoint server-relative path (advanced)
 7 | E.g. /teams/hr
   \ (path)
config_type> 1

Option config_driveid.
Select drive you want to use
Choose a number from below, or type in your own string value.
Press Enter for the default (b!N1gkmy8wjEiBQV4n_R5MYMzvMrxgNf9LmQPlqO9GBKaPZON4_835QKWrkfPvNnxF).
 1 / OneDrive (business)
   \ (b!N1gkmy8wjEiBQV4n_R5MYMzvMrxgNf9LQPlqO9GBKaPZON4_835QKWrkfPvNnxF)
config_driveid> 1

Drive OK?

Found drive "root" of type "business"
URL: https://51sec-my.sharepoint.com/personal/netsec_51sec_eu_org/Documents

y) Yes (default)
n) No
y/n> y

Configuration complete.
Options:
- type: onedrive
- token: {"access_token":"eyJ0eXAiOiJKV1QLCJub25jZSI6IkZUnczb2lyVGxiQ3VUbzRJeEdLNXYzdWZsWjNqd0h6TGJQYzZkQms4dkkiLCJhbGciOiJSUzI1NiIsIng1dCI6Ii1LSTNROW5OUjdiUm9meG1lWm9YcWJIWkdldyIsImtpZCI6Ii1LSTNROW5OUjdiUm9meG1lWm9YcWJIWkdldyJ9.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTAwMDAtYzAwMC0wMDAwMDAwMDAwMDAiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC84ZWQ4NjE3YS01ZGUzLTQ0ZDgtYThmNC03MzdjODlmYTliYmMvIiwiaWF0IjoxNjcxNTY0OTIzLCJuYmYiOjE2NzE1N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ddq_VlRAMg.AgABAAEAAAD--DLA3VO7QrddgJg7WevrAgDs_wQA9P9w7KXDqjtbStzDHeIY6aiWz3_wVptVT777YO3mjTD-twfgZRV9Bb-KeXfqE4geuu0X2Wm0xOaYJOfKYIHy6W5eVBi35LSNkrHP1-pmBKQ236jCqRXV8EyuaWZK1POERvMNrwg0cv27LqSMKtUw5jZTZZER9xXqFiYCnuLBXMinjv2_B_8tZsnxC58_sn8idB4KmtGcptzrX66AUT_kltKO7BL_dLatp7FJFdMCU9ufRPJ7MI77faMBwCqD27BiP_FgSBxk7-tv9sheANpyl7xR-8EWEHSFuU1sMVIkaK5qw6ciEHj-HB0d46wHCcJ5VlNAN6KGdLVR1voR28_Kb5CJTdGTfCYScyffXk38xkonVr2o-TnAS8GN1ql5OVeIi0dWgYczEnZdWFdHtF2rC1KaDFWCo4muA8RTUVpip7p25_KyAoOfJTiMas8KWritqcxhlKoNgT8iEYoS2dh6Q3IWz3v8Ts7ygBBb6jIMNmWd5gUNcPK3863ZJTgkFDmFYIEF6DaDSU9OSv58VU39rfo_vZyRefnMLX5Ui4Gl6fRvhhNPjeibmRQfvuKIMEmeY7NCQ9-Jo7-nWVHeqW_vREqaXx8jz5VxVWnskHAEtdOb8caVog7OfsiGxM_YVeMcj9KvY0_AqsmFfwa9Atyb-GHp7mDUR-trCqvNafK1MFVcm_G5-W5lORaTCBfTNQijv2VWbt7cCs_vVVMlD6d7hSYMgWff8A1ng1ZHM7ou-U","expiry":"2022-12-20T16:03:38.5637041-05:00"}
- drive_id: b!N1gkmy8wjEiBQV4n_R5MYMzvMrxgNf9LmQPlqO9GBKaPZON4_835QKWrkfPvNnxF
- drive_type: business
Keep this "od-jyan" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d>

Current remotes:

Name                 Type
====                 ====
od-jyan              onedrive
yyyjjjj              drive

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q>

Rclone configuration file can be copied to other machines :



D:\Tools\rclone-current-windows-amd64>rclone config file
Configuration file is stored at:
C:\Users\admin\AppData\Roaming\rclone\rclone.conf




Google Team Drives

 Some online Google Team Drive you can apply for free.

  • 英國老牌名校謝菲爾德大學 - Miami University :gdrive.zppcw.cn

But there is a risk those drives will not work one day and you will lose everything saved in those free drives.

No comments:

Post a Comment