Optional cookie based voting authentication

bertboerland@ww... - December 10, 2004 - 10:50
Project:Drupal
Version:6.x-dev
Component:poll.module
Category:feature request
Priority:normal
Assigned:Unassigned
Status:won't fix
Description

The poll currently limts the users to be able to vote based on an IP address. It is better than a cookie since it is much harder to fake an ip address than to use a clean cookie. However, this causes that only one person of all the persons behind a NAT-ed IP addresses or people behind a corporate proxy will be able to vote, none of the others can vote ägain". This willbe a problem in huge intranets were all traffic is going via a proxy server. So I would like to see the IP address limitation as an option (default on) and I think it might be wise to take a look at the "x-forwarded-for" headers sent by most proxy servers. This makes it possible to let many people behind one proxy vote.

#1

mr700 - September 5, 2005 - 21:52

I was thinking about this just before I found this request. First I want to note there can't be perfect implementation (you can always trick the system - register 10 new users and use 10 votes) until you use certificates (which will maybe be almost perfect). Here are the problems I found when I was thinking of doing something about this (which make x-forwarded-for and via headers useless):

  1. You can just get a FireFox extension and add whatever 'x-forwarded-for' and 'via' you like.
  2. Many proxy servers, and all that I run, do send 'Unknown' or do not send this header (via also) at all.
  3. A proxy server is not limited to have a single IP.
  4. Some big sites use many proxy servers to do load balancing.
  5. ...

I was thinking about overloading the server with permanent cookies and allow voting only to users with olther than the poll cookies, but the user can have X browsers + X profiles. For me this was more than enough to forget about it and any tricks I can think of, at least for now.

PS: The 'register to vote' solution still works...

#2

bertboerland@ww... - January 24, 2006 - 19:16

could someone with knowledge about poll.module update this old one?

#5

ac - December 15, 2006 - 05:06
Version:x.y.z» 5.x-dev

An optional IP validation control in the poll admin would be a lovely feature. The option could disable the IP match and enable cookie authentication to check if a user has voted. I understand it is not secure but it is not like this is going to be used for elections. Currently the restriction based on IP is a show stopper for using poll.module on local networks and in situations where you need to survey a number of people (who do not want to register) within an organisation (that only has 1 IP)

#6

ac - December 17, 2006 - 09:09
Title:ip address and x-forwarded-for headers» Optional cookie based voting authentication

#9

robdinardo - July 20, 2007 - 19:33

I agree with AC. The module should allow the option of IP or cookie validation to test whether the user voted. Maybe add a description that Cookie validation is not secure.

In the poll_vote() function, I added:

setcookie("poll-$nid","1",time()+60*60*24*30*12);

and it works fine - the cookie gets added to the browser and expires in about a year.

In the poll_load() function, I replaced the $result if statement with:

if (isset($_COOKIE["poll-".$node->nid])) {
$poll->vote = $result->chorder;
} else {
$poll->vote = -1;
$poll->allowvotes = TRUE;
}

... the vote gets recorded, and the user cannot vote again without clearing the cookies, but the block shows the choices instead of the results. ???

#10

nektir - March 13, 2008 - 23:10

subscribe... i want same feature... cookie based voting

#11

FuN_ViT - March 21, 2008 - 12:16

i am wrote my own module, based on poll (Drupal 5.7) module see - http://drupal.org/node/237126

#12

fuquam - April 21, 2008 - 17:38

That made it so the poll results were not shown. Vote was recorded but results were not shown afterwards.

#13

Susurrus - April 21, 2008 - 18:40

Feature requests against HEAD. Also, see #237213: Fixed poll code for anonymous voting.

#14

greg.harvey - October 15, 2009 - 10:21
Version:5.x-dev» 6.x-dev
Priority:minor» normal
Status:active» needs review

Working patch attached. Please test and post feedback. It's a tidied up version of pash7ka's patch in comment #5 of #237213: Fixed poll code for anonymous voting - that is a D7 issue, so I've moved the patch here.

AttachmentSizeStatusTest resultOperations
14179-poll_module_cookie_voting-D6.patch3.78 KBIgnoredNoneNone

#15

domesticat - November 6, 2009 - 16:41

I'm giving this patch a try.

#16

domesticat - November 12, 2009 - 16:59
Status:needs review» reviewed & tested by the community

Patch in #14 did not apply cleanly for me, so I applied it by hand. The code worked, though; cookies are being set properly for anonymous votes, and users inside our network (who all appear to have the same IP address outside our network thanks to firewalling) are all able to vote anonymously without issue.

Marking RTBC. @greg_harvey -- thank you. This was a huge problem for us.

#17

greg.harvey - November 12, 2009 - 17:26

Welcome! Odd it didn't apply. I probably did something silly.

Thanks as well to pash7ka, who wrote the patch. I only really tidied it up. =)

Not sure what's going on with the D7 patch now - it seems to have stalled, but I've fixed all the issues Dries raised, except for the ones I think either aren't issues or I don't understand what he wants. Sadly, he hasn't come back since to expand on his comments...

#18

Gábor Hojtsy - November 16, 2009 - 16:36
Version:6.x-dev» 8.x-dev

New features are added to Drupal 8, not Drupal 6 or 7 anymore.

#19

greg.harvey - November 17, 2009 - 11:35
Version:8.x-dev» 6.x-dev
Status:reviewed & tested by the community» won't fix

@Gabor, we know that - this is for people who want the feature in D6. A more appropriate Status would be "won't fix" then, as the active D7 patch is here: #237213: Fixed poll code for anonymous voting

This needs bumping to D8 since it failed to make the cut. Will do it now. =)

All other comers, D6 patch in #14 works if you need this, otherwise please contribute to D8 patch in the issue above.

#20

yingtho - December 8, 2009 - 09:45

The code only seems to work partly for me. If i remove the cookie then i can see the poll form but when i submit then it just show the result and the poll choice is not submitted. I have make a small patch to make it work. Please see enclosed.

AttachmentSizeStatusTest resultOperations
poll.module.patch2.52 KBIgnoredNoneNone
 
 

Drupal is a registered trademark of Dries Buytaert.