send data from a local PC with php to a online php webpage

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.

Answers


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

Need Your Help

How to create XElement with default namespace for children without using XNamespace in all child nodes

c# .net xml namespaces linq-to-xml

I'm trying to use System.Xml.Linq to create XHTML documents. Thus, the vast majority of the nodes in my trees ought to use this namespace:

check if multiple keys are present in a JSON String - Java

java json validation key schema

I have a complicated JSON String (Array/Object) and I have to check whether it contains some keys.Its basically a validation for the JSON String I got.