Following situation: a RaspberryPI is in the local network, and has a webserver on it. it contains a local webpage where the user has to log in.

This local Raspberry is connected to a sensor that reads data. Additionally the user can make some changes to the local page's settings.

When done there is a button, the user clicks and the data is transfered from the local PI to the online webserver. Obviously only if he is logged in. (Online and local have the same accounts)

problems:

  • how to update the local username/passwords in a safe way? The local raspberry could be stolen, and that should not put all the user accounts to risk. Ideally the accounts stay stored online only, and when the user logs in locally he actually logs in online and the session is valid remotely and locally.

  • how to send the informations online in a safe way? we are talking of roughly 50 variables to send online.

有帮助吗?

解决方案

After a lengthy chat it became clear that the Pi devices would need to be accessed by clients using a smartphone or a web-browser.

Each Pi device would have a set of settings, and be able to read GPIO data. Each device would have to be secure (with authentication and authorization). There are several options to go about this, but using a central relay server offers a lot of advantages.

Basically, a relay server (remote, shared by everyone in the system) would maintain a list of Pi devices along with their UUIDs and owners, employees, permissions. Once booted up the device would make a persistent connection over to the server using TCP, identify itself, and be able to send and receive data (configuration, sensor data). Look into Twisted, 0MQ (zeromq), and other TCP server/client stacks.

Clients would be able to use the relay server by logging in, and reading/writing (depending on permissions) to their Pi devices. Registering devices would be simple, by adding their UUID the relay server knows who it belongs to. Discarding devices due to theft, etc. (by the way, since the Pi will contact the server, if it's reported as stolen, it can relay its IP and other data when it comes online again).

Use properly configured SSL to secure your connections.

Advantages of this approach:

  1. Works without a NAT, no need for unique IPs per device.
  2. Simple UUID-based configuration, without addresses, etc.
  3. Centralized data, secure (if properly configured)

Disadvantages:

  1. Internet connection is a must.
  2. More work required to implement than a simple decentralized stack
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top