The "subscribe to newsletters" permission is currently tied both to a subscription AND unsubscription of newsletters. There are situations where this has adverse effects.
Let's say someone doesn't want to allow the users to subscribe directly to newsletters: maybe the have to fill a form asking to be included in a newsletter first. The first step is to remove the "subscribe to newsletters" right from these users. The problem is that in this situation the users won't be able to opt out of newsletters either. Suddenly we have created a spamlike situation.
To fix this problem I propose to create a separate permission to control only the opting out of newsletters separating the permission managing the addition of a subscription from the permission managing the self removal of a subscription.
In the attached patch I created the 'opt out from newsletter' permission and used it to control the access to the 'newsletter/confirm/remove' path (the same path Simplenews already uses for self removal from subscriptions lists). It's very simple. Please consider merging it in Simplenews.
This patch is against version 6.x-1.x-dev from 2010-03-30.
Regards,
Rodrigo Severo
Comments
Comment #1
sutharsan commentedI vote against this patch as it is an edge case. Further it is not so easy as it seams since simplenews uses combined subscribe and unsubscribe forms. You want to prevent people from unchecking a checkbox.
Comment #2
rsevero commentedFirst of all I would like to thank you Sutharsan for your attention.
About being an edge case or not is entirely a subjective evaluation which I won't argue despite not agreeing with you.
You say it is not so easy as it seams since simplenews uses combined subscribe and unsubscribe forms. I'm not sure what you mean as AFAICT it's already done in my proposed patch, so by maintainers point of view, it couldn't be easier. Unless you mean my patch is wrong, incomplete, unfit or similar. Is it the case? If it is, please tell my in which way so I can try to fix it. BTW it was easy to implement it and it's already in production use in one site. I hope it's right!
I also don't understand what you mean by You want to prevent people from unchecking a checkbox. What checkbox are you referring to? How would unchecking any currently existent checkbox solve the situation I described when I opened this issue? I hope I didn't went into the trouble of writing this patch when unchecking a simple checkbox would fix my problem but anyway it is better to know late than never.
I believe there is a problem of miscommunication. If I'm the one who didn't understand your points please take the time to clarify me. Thanks again for your attention.
Comment #3
sutharsan commentedI refer to the form at /newsletter/subscriptions and at /user/nid/edit/newsletter. You only take care of anonymous users.
Comment #4
rsevero commentedNo, it's not about anonymous users only. Not at all. It's about all users that don't have the "subscribe to newsletters" permission. These users can't access any of the paths you mentioned but they should be able to unsubscribe themselves using the link available in every newsletter issue.
And these users don't have the "subscribe to newsletters" permission because these newsletters aren't open for anyone to subscribe: people interested got to ask for subscription. There are several reasons why a webmaster would like to forbid direct subscription but maintain the unsubscribe option:
and I'm sure there area several other possibilities where this kind of arrangement would be helpful.
The point is that:
Simplenews already provides point 1 above. My patch implements the possibility for point 2.
BTW, did you looked at the attached patch? Is it ok?
Thanks again for taking the time to evaluate this issue.
Comment #5
rsevero commentedComment #6
seanhead commentedI'm looking for a solution to this as well. Though in my instance I don't want to allow people to subscribe to newsletters generically because I have a few of them that I only add people to manually.
So an alternate fix for me would be to allow some kind of per newsletter permissioning.
Comment #7
rsevero commented@seanhead: I thought about a solution like this also. In my case I need to separate the subscribing permission from the unsubscribing one. We are talking about two different permission separations: per newsletter and subscribe X unsubscribe.
For complete flexibility the best solution seems to be separate subscribing and unsubscribing permission per newsletter.
To simplify adaptation of current configurations it might be nice to maintain current one-for-all permission also.
Unfortunately I got the impression Sutharsan was in a hurry when dealt with this issue and never took the time to really understand the issue at hand.
If there is any sign that maintainers are interested in such a patch I can make one that implements both permission separations.
Comment #8
rsevero commentedComment #9
fmjrey commentedrsevero: your patch is very similar to the one proposed in #776370: Unsubscribe link fails for non-administrators so it looks like you're going to get your way.
The patch provided there needs more polishing and testing, so your contribution would be a great help.
Comment #10
ohnobinki commentedTo make this patch more complete, perhaps it could rename the existing newsletter/confirm menu entry to newsletter/confirm/add, so that we can let more of the 404s be generated by drupal's menu system rather than manually in simplenews_confirm_subscription().
Also, the patch should remove the ``// @todo: open this permission -check later - allow unsubscribe'' comment from the newsletter/confirm menu entry as this patch _does_ that TODO.
I think that any newly created permission should be named 'unsubscribe from newsletters'. This appears somewhat more consistent with the existing 'subscribe to newsletters' permission. However, is such a permission even needed? Isn't it bad practice to disallow someone from unsubscribing from a mailing list? ideally, such a permission shouldn't exist.
However, requiring users to log in to unsubscribe (the current situation) does protect against one possible problem: the hash used to prove that the user is the one who received the particular email is both truncated from an MD5 and is always the same hash that user uses. Thus, if someone finds out someone's subscribe/unsubscribe hash and unsubscribing didn't require logging in, one could maliciously unsubscribe a certain user from the mailing list continuously when the user wants to remain subscribed. But for now, I think that getting anonymous unsubscriptions is much more important than this concern...
Comment #11
ohnobinki commentedHere's my take on the patch, simplifying its implementation and having an 'unsubscribe from newsletters' permission instead of 'opt out from newsletter' permission. This would allow an admin to give the anonymous user the 'unsubscribe from newsletters' permission and thus have a correct mailing list setup.
Comment #12
miro_dietikerJust wanted to refer to issues that are somehow related to this discussion:
#776370: Unsubscribe link fails for non-administrators
#927072: Unsubscribe link does not work
#891870: Unsubscribing doesn't work
And there have been many more duplicates.
I consider the unsubscribe issue a blocker for 6.x-2.x. Please help us make this work seamless somehow.
I'll go through all issues and provide my updated opinion soon (again).
Anyway, simply adding two callbacks is by far not enough. (think about the unpermitted links still appearing in mails and much more to come...)
Comment #13
rsevero commentedDo you mean the unsubscribe links shouldn't be present in the emails if the user has no "unsubscribe to newsletter" permission?
There could be code to only include the unsubscribe link if the user has this permission but do we really need this permission (unsubscribe from newsletter)? Shouldn't users be always allowed to unsubscribe from a newsletter?
I believe the "remove" callback should not check for any special permissions at all. Does anybody disagree? When would be reasonable to not allow a user to unsubscribe from a newsletter?
Besides this do you see any other problem to be dealt with on this issue?
Comment #14
miro_dietikerDuplicated by:
#966706: Allow anonymous users to opt-out to authenticated newsletters
Also switching this to 6.x-2.x
Comment #15
simon georges commented@Miro, since your commit from #776370: Unsubscribe link fails for non-administrators, there is no permission needed any more to unsubscribe, so I guess we can close this one too, what do you think ?
Comment #16
miro_dietikerI think we should leave this open... but push it to D7 queue.
I'd like to see a much more versatile permission setup in future releases.
Setting to active as we need to rethink the whole process then.
Comment #17
berdirI'm also thinking that unsubscribe should always be possible as it's even legally required to be able to do so in many countries.
*If* it's like that currently, then I think it's safe to set this to low and look at this later..
Comment #18
april26 commentedI agree this setting is needed.
My client adds hundreds of names via the import function, but legally these people still need to unsubscribe. However if I give anonymous users the permission to unsubscribe, then I get spammed by bots subscribing. Now that Google has stopped backlinks for search ranking, hopefully all of us will get less spam!
Comment #19
rfayThis is super important. *Nobody* on the web should be forced to sign into an account in order to unsubscribe from a newsletter.
Comment #20
giorgio79 commentedAlternative solution proposal #2063847: Improve unsubscription, bounce handling & their integration
Integrate with the Unsubscribe module for a global solution.
Comment #21
adamps commented@Berdir
However it is not like that currently. The URL /newsletter/confirm/remove/XXX is governed by the route simplenews.newsletter_confirm_subscription and requires permission 'subscribe to newsletters'.
@Berdir
Often that's true I agree. However I believe it is also permissible by law to say that users will receive certain emails as a condition of membership, in which case opt out is not allowed (the user would have to cancel membership). Hidden emails already don't have an unsubscribe link. So some sites might need more detailed control over access to unsubscribe.
This issue seems closely related to #1140606: Permissions Per-Newsletter: Limit subscription options by role which discusses detailed control over access to subscribe.
Comment #22
adamps commentedAnother aspect: we probably shouldn't insert an unsubscribe link into mails to users that won't have permission to use it.
Comment #23
anybodySadly I can confirm this issue still exists in Drupal 7. Should we perhaps set this back to 7.x and use #1140606: Permissions Per-Newsletter: Limit subscription options by role to document the requirement for separate permissions in Drupal 8 per newsletter?
Has anyone found a workaround or written a patch in the meantime for D7 we could use as starting point here?
Comment #24
adamps commented@Anybody Although the two issues are related I think there are two different cases and so it's worth keeping both open for D8 please.
My feeling is that on Drupal.org we generally allow one issue to cover both D7 and D8. We would most likely fix it in D8 first, then possibly backport if if someone is keen to provide a patch.
Comment #25
anybodyThank you for your quick reply, AdamPS!
I've written a quick and dirty patch for Drupal 7.
It does:
Provide a new permission: Unsubscribe from newsletters
Add a separate menu hook item for newsletter/confirm/remove:
It doesn't yet:
Add the set permissions for the roles from the "Subscribe to newsletters" permission
We can use this as starting point for Drupal 7 perhaps... I just needed a quick and dirty solution. Perhaps it may help others too.
Comment #26
anybodyPatch attached, sorry.
Comment #27
tr commentedPatch in #26 is vulnerable to CSRF and needs a token in the callback path.
There's some really minimal documentation at https://www.drupal.org/docs/7/security/writing-secure-code/create-forms-...
Regardless, as @AdamPS said in #24, this should be fixed in D8 first then backported if there is interest.
Comment #28
adamps commentedThe latest comments prompted me to think about this issue again. Here is my latest suggestion:
If a user clicks the unsubscribe link in an email footer, then it must always work - there should be no need to log in and no check against permissions. Therefore we should remove the access check on the URL /newsletter/confirm/remove/XXX is governed by the route simplenews.newsletter_confirm_subscription. The fact that someone received the email in their inbox is sufficient verification.
No other changes needed:
So it could be a 1-line fix - plus tests of course.
Comment #29
anybody@AdamPS: I completely agree! And we should fix it in D8 and D7 then... both versions are used very widely. What do you think about the #27 CSRF risk?
Comment #30
adamps commentedHere is a initial D8 patch for review please (without tests). I have removed access checks on all confirmation pages. My theory is that a user can only get a valid token if they are entitled to access, either
@Anybody I'm not a maintainer for D7, only D8, but I agree with @TR. The D8 codebase has the correct code including tokens in simplenews.routing.yml. Potentially the backport will require adding similar code back to D7. However please let's try and get D8 finished before starting the D7 discussion.
Comment #32
adamps commentedComment #33
tr commentedYes, that will work for D8, but instead of doing all the {hash} generation and checking explicitly, D8 supports using csrf tokens in the route, which will do this for you. That will simplify the code a bit.
Comment #34
berdirNo, standard csrf tokens can't replace our hashes, the csrf token is based on a session, our tokens are put in newsletters for all users who receive it, they are very different how they work.
Comment #35
tr commentedAh, OK. thanks for the clarification.
Comment #36
adamps commented@Berdir this is important security question so please can you comment whether the solution of this patch looks good? If you agree then I will write a quick test then we can commit. This is a non-BC change so it seems worth getting in before we release the first 2.x beta.
Comment #37
adamps commentedComment #38
adamps commentedComment #39
adamps commentedComment #41
adamps commentedComment #42
anybodyGreat great news, thank you very much for your work @AdamPS! :)
Comment #43
anybodyBTW should we backport this to Drupal 7?
Comment #44
adamps commentedThanks @Anybody. My view is that now it's so close to the end of D7, it's not worth backporting anything except perhaps major bug fixes. However I am only maintaining D8 so it's not up to me. But I believe the D7 maintainers are very busy people:-)