How can I prove that some data came from my app?

2019-05-18 16:34发布

问题:

I have a distributed application that sends and receives data from a specific service on the Internet. When a node receives data, sometimes it needs to validate that that data is correlated with data it or another node previously sent. The value also needs to be unique enough so that I can practically expect never to generate identical values within 24 hours.

In the current implementation I have been using a custom header containing a value of uuid.uuid1(). I can easily validate that that value comes from the one single node running by comparing the received uuid to uuid.getnode(), but this implementation was written before we had a requirement that this app should be multi-node.

I still think that some uuid version is the right answer, but I can't seem to figure out how to validate an incoming uuid value.

>>> received = uuid.uuid5(uuid.NAMESPACE_URL, 'http://example.org')
>>> received
UUID('c57c6902-3774-5f11-80e5-cf09f92b03ac')

Is there some way to validate that received was generated with 'http://example.org'?

  1. Is uuid the right approach at all? If not, what is?
  2. If so, should I even be using uuid5 here?

回答1:

If the goal is purely to create a unique value across your nodes couldn't you just give each node a unique name and append that to the uuid you are generating?

Wasn't clear to me if you are trying to do this for security reasons or you simply just want a guaranteed unique value across the nodes.