Jump to content

Secure PHP Dropbox uploading

BrownZeus

Hey Folks, 

 

I wanna create a client facing app in php where the user uploads a file and sends it to my dropbox.

I know the Dropbox API gives functionality to be able to do this, I just wanna know how to do it securely?

I don't want the app token to be visible to someone inspecting elements. I'm fairly new to PHP, if someone can privide steps NOT code, that'd be great! I'd like to learn on my own code-wise

 

TIA

Link to comment
Share on other sites

Link to post
Share on other sites

PHP is a language for web development not for creating apps. You need something like C++, C#, etc. 

CPU: AMD Ryzen 5 5600X | CPU Cooler: Stock AMD Cooler | Motherboard: Asus ROG STRIX B550-F GAMING (WI-FI) | RAM: Corsair Vengeance LPX 16 GB (2 x 8 GB) DDR4-3000 CL16 | GPU: Nvidia GTX 1060 6GB Zotac Mini | Case: K280 Case | PSU: Cooler Master B600 Power supply | SSD: 1TB  | HDDs: 1x 250GB & 1x 1TB WD Blue | Monitors: 24" Acer S240HLBID + 24" Samsung  | OS: Win 10 Pro

 

Audio: Behringer Q802USB Xenyx 8 Input Mixer |  U-PHORIA UMC204HD | Behringer XM8500 Dynamic Cardioid Vocal Microphone | Sound Blaster Audigy Fx PCI-E card.

 

Home Lab:  Lenovo ThinkCenter M82 ESXi 6.7 | Lenovo M93 Tiny Exchange 2019 | TP-LINK TL-SG1024D 24-Port Gigabit | Cisco ASA 5506 firewall  | Cisco Catalyst 3750 Gigabit Switch | Cisco 2960C-LL | HP MicroServer G8 NAS | Custom built SCCM Server.

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Store secret tokens on server-side in a secure storage, if it is your account. You could encrypt it, but then you need a place to store the key.

Use secure connections everywhere (HTTPS).

Watch out for XSS/CSRF and other potential web vulnerabilities. There's many.

 

PHP is for server-side code though. Web frontend is done in HTML/CSS/JavaScript, often with help from different JS libraries/frameworks.

HAL9000: AMD Ryzen 9 3900x | Noctua NH-D15 chromax.black | 32 GB Corsair Vengeance LPX DDR4 3200 MHz | Asus X570 Prime Pro | ASUS TUF 3080 Ti | 1 TB Samsung 970 Evo Plus + 1 TB Crucial MX500 + 6 TB WD RED | Corsair HX1000 | be quiet Pure Base 500DX | LG 34UM95 34" 3440x1440

Hydrogen server: Intel i3-10100 | Cryorig M9i | 64 GB Crucial Ballistix 3200MHz DDR4 | Gigabyte B560M-DS3H | 33 TB of storage | Fractal Design Define R5 | unRAID 6.9.2

Carbon server: Fujitsu PRIMERGY RX100 S7p | Xeon E3-1230 v2 | 16 GB DDR3 ECC | 60 GB Corsair SSD & 250 GB Samsung 850 Pro | Intel i340-T4 | ESXi 6.5.1

Big Mac cluster: 2x Raspberry Pi 2 Model B | 1x Raspberry Pi 3 Model B | 2x Raspberry Pi 3 Model B+

Link to comment
Share on other sites

Link to post
Share on other sites

php code isnt visible on the client side (unless you botch the server setup), only the html/text it generates

3 minutes ago, James Evens said:

why do you need dropbox? store them on your server and access them trough FTP.

thats a pretty bad advice there my man

MSI GX660 + i7 920XM @ 2.8GHz + GTX 970M + Samsung SSD 830 256GB

Link to comment
Share on other sites

Link to post
Share on other sites

@James Evens

he would have to take care of the disk space on his server, buying and installing hdds...

ftp isnt considered safe quite a while now

MSI GX660 + i7 920XM @ 2.8GHz + GTX 970M + Samsung SSD 830 256GB

Link to comment
Share on other sites

Link to post
Share on other sites

Php is one-sided so you shouldn't have to worry about sensitive information as long as your folder permissions are setup correctly. 

 

Here is a api for Dropbox and php

https://github.com/kunalvarma05/dropbox-php-sdk/wiki/Upload-and-Download-Files

 

I would personally do all of this in electron with nodejs. You could then compile it for different platforms from windows to Mac to Android ect. 

CPU:R9 3900x@4.5Ghz RAM:Vengeance Pro LPX @ 3200mhz MOBO:MSI Tomohawk B350 GPU:PNY GTX 1080 XLR8

DRIVES:500GB Samsung 970 Pro + Patriot Blast 480GB x2 + 12tb RAID10 NAS

MONITORS:Pixio PX329 32inch 1440p 165hz, LG 34UM68-p 1080p 75hz

 

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, James Evens said:

source? don't think that the encryption is broken.

ftp? what encryption dude ?

MSI GX660 + i7 920XM @ 2.8GHz + GTX 970M + Samsung SSD 830 256GB

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, James Evens said:

TLS

ftp isnt encrypted, ftps is

its still not what the OP would want anyway

MSI GX660 + i7 920XM @ 2.8GHz + GTX 970M + Samsung SSD 830 256GB

Link to comment
Share on other sites

Link to post
Share on other sites

5 hours ago, jj9987 said:

You could encrypt it, but then you need a place to store the key.

This is what you use environment variables for.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

Thank you all for your different pieces of advice! 

Much appreciated over the vultures at Stackoverflow.

 

My apologies for misclassifying it, its a webpage/webapp not an app.

 

I wanna upload to dropbox because its secure storage I can access anywhere seamlessly through the dropbox desktop integrations. Also I have a terabyte of storage, i don't have to worry about any overhead.

 

Thank you again!

Link to comment
Share on other sites

Link to post
Share on other sites

16 hours ago, vorticalbox said:

This is what you use environment variables for.

Env variables are not persisted over reboots. From where is the key loaded to env variable? That all depends on how OP is going to host the application.

HAL9000: AMD Ryzen 9 3900x | Noctua NH-D15 chromax.black | 32 GB Corsair Vengeance LPX DDR4 3200 MHz | Asus X570 Prime Pro | ASUS TUF 3080 Ti | 1 TB Samsung 970 Evo Plus + 1 TB Crucial MX500 + 6 TB WD RED | Corsair HX1000 | be quiet Pure Base 500DX | LG 34UM95 34" 3440x1440

Hydrogen server: Intel i3-10100 | Cryorig M9i | 64 GB Crucial Ballistix 3200MHz DDR4 | Gigabyte B560M-DS3H | 33 TB of storage | Fractal Design Define R5 | unRAID 6.9.2

Carbon server: Fujitsu PRIMERGY RX100 S7p | Xeon E3-1230 v2 | 16 GB DDR3 ECC | 60 GB Corsair SSD & 250 GB Samsung 850 Pro | Intel i340-T4 | ESXi 6.5.1

Big Mac cluster: 2x Raspberry Pi 2 Model B | 1x Raspberry Pi 3 Model B | 2x Raspberry Pi 3 Model B+

Link to comment
Share on other sites

Link to post
Share on other sites

8 minutes ago, jj9987 said:

Env variables are not persisted over reboots

...are you sure we're talking about the same env variables? It would be VERY annoying if you had to add maven/java/python/etc. to the PATH env var every single time you rebooted the machine.

Gaming build:

CPU: i7-7700k (5.0ghz, 1.312v)

GPU(s): Asus Strix 1080ti OC (~2063mhz)

Memory: 32GB (4x8) DDR4 G.Skill TridentZ RGB 3000mhz

Motherboard: Asus Prime z270-AR

PSU: Seasonic Prime Titanium 850W

Cooler: Custom water loop (420mm rad + 360mm rad)

Case: Be quiet! Dark base pro 900 (silver)
Primary storage: Samsung 960 evo m.2 SSD (500gb)

Secondary storage: Samsung 850 evo SSD (250gb)

 

Server build:

OS: Ubuntu server 16.04 LTS (though will probably upgrade to 17.04 for better ryzen support)

CPU: Ryzen R7 1700x

Memory: Ballistix Sport LT 16GB

Motherboard: Asrock B350 m4 pro

PSU: Corsair CX550M

Cooler: Cooler master hyper 212 evo

Storage: 2TB WD Red x1, 128gb OCZ SSD for OS

Case: HAF 932 adv

 

Link to comment
Share on other sites

Link to post
Share on other sites

52 minutes ago, jj9987 said:

Env variables are not persisted over reboots. From where is the key loaded to env variable? That all depends on how OP is going to host the application.

at work with use aws parameter and the aws credentials to load the envs for the app we are running.

 

45 minutes ago, reniat said:

...are you sure we're talking about the same env variables? It would be VERY annoying if you had to add maven/java/python/etc. to the PATH env var every single time you rebooted the machine.

depends, app level env like secrets, ports etc you probably don't want to set in the system path.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

10 minutes ago, vorticalbox said:

depends, app level env like secrets, ports etc you probably don't want to set in the system path.

I know, I was just pointing out that if he's referring to OS level env variables, they very much persist through reboot.

Gaming build:

CPU: i7-7700k (5.0ghz, 1.312v)

GPU(s): Asus Strix 1080ti OC (~2063mhz)

Memory: 32GB (4x8) DDR4 G.Skill TridentZ RGB 3000mhz

Motherboard: Asus Prime z270-AR

PSU: Seasonic Prime Titanium 850W

Cooler: Custom water loop (420mm rad + 360mm rad)

Case: Be quiet! Dark base pro 900 (silver)
Primary storage: Samsung 960 evo m.2 SSD (500gb)

Secondary storage: Samsung 850 evo SSD (250gb)

 

Server build:

OS: Ubuntu server 16.04 LTS (though will probably upgrade to 17.04 for better ryzen support)

CPU: Ryzen R7 1700x

Memory: Ballistix Sport LT 16GB

Motherboard: Asrock B350 m4 pro

PSU: Corsair CX550M

Cooler: Cooler master hyper 212 evo

Storage: 2TB WD Red x1, 128gb OCZ SSD for OS

Case: HAF 932 adv

 

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, reniat said:

...are you sure we're talking about the same env variables? It would be VERY annoying if you had to add maven/java/python/etc. to the PATH env var every single time you rebooted the machine.

 

3 hours ago, reniat said:

I know, I was just pointing out that if he's referring to OS level env variables, they very much persist through reboot.

Env variables are kept in the memory, you need to store them on the filesystem to get loaded there at all (be that automatically on boot or manually).

HAL9000: AMD Ryzen 9 3900x | Noctua NH-D15 chromax.black | 32 GB Corsair Vengeance LPX DDR4 3200 MHz | Asus X570 Prime Pro | ASUS TUF 3080 Ti | 1 TB Samsung 970 Evo Plus + 1 TB Crucial MX500 + 6 TB WD RED | Corsair HX1000 | be quiet Pure Base 500DX | LG 34UM95 34" 3440x1440

Hydrogen server: Intel i3-10100 | Cryorig M9i | 64 GB Crucial Ballistix 3200MHz DDR4 | Gigabyte B560M-DS3H | 33 TB of storage | Fractal Design Define R5 | unRAID 6.9.2

Carbon server: Fujitsu PRIMERGY RX100 S7p | Xeon E3-1230 v2 | 16 GB DDR3 ECC | 60 GB Corsair SSD & 250 GB Samsung 850 Pro | Intel i340-T4 | ESXi 6.5.1

Big Mac cluster: 2x Raspberry Pi 2 Model B | 1x Raspberry Pi 3 Model B | 2x Raspberry Pi 3 Model B+

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×