itead / Sonoff_Devices_DIY_Tools

BSD 3-Clause "New" or "Revised" License
548 stars 168 forks source link

DIY mode: add api token #59

Open shell1986 opened 4 years ago

shell1986 commented 4 years ago

Hi, having studied the documentation for DIY mode, I noticed that requests that are sent as json do not have an authorization method. Modern api use tokens to authorize owners, I think adding a similar one for your devices is a pretty good idea!

For example, you can make an elementary token by encrypting SHA256 ("secret word" + ip adreess), this will allow access to the device safely, and will not allow token to be replaced from another source.

example secret word=blablabla ip=192.168.1.20

.../?token=ba03114d354ff5bc21f13383631222536fee160c9249b20a257c7b997e716468&...