Django: creating a unique identifier for a user based on request.META parameters

I am looking for an anonymous survey. However, I want users not to vote twice. I was thinking of hashing some request.META values, for example:

 from hashlib import md5 request_id_keys = ( 'HTTP_ACCEPT_CHARSET', 'HTTP_ACCEPT', 'HTTP_ACCEPT_ENCODING', 'HTTP_ACCEPT_LANGUAGE', 'HTTP_CONNECTION', 'HTTP_USER_AGENT', 'REMOTE_ADDR', ) request_id = md5('|'.join([request.META.get(k, '') for k in requst_id_keys])).hexdigest() 

My questions:

  • A good idea? Bad idea? Why?
  • Are some of these keys redundant or just redundant? Why?
  • Are some of them easy to change? For example, I am considering removing HTTP_USER_AGENT because I know that it is just a configuration change.
  • Know the best way to execute this semi-unique identifier, which is flexible enough to handle people using IP (NAT), but that just changing the configuration won't create a new hash?
+2
source share
1 answer

All of these options are pretty easy to change. Why not just use cookies for this purpose? I think something like evercookie

evercookie is a javascript API that creates extremely persistent cookies in the browser. Its purpose is to identify the client even after deleting standard cookies, Flash cookies (local shared objects or LSOs) and others.

+3
source

Source: https://habr.com/ru/post/1386036/


All Articles