Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove default enabling of gravatar… #1036

Merged
merged 6 commits into from
Aug 19, 2016

Conversation

simonpoole
Copy link
Contributor

Remove default enabling of gravatar, check on initial confirmation of e-mail address and on any changes afterwards if a gravatar exists and enable then if the user hasn't uploaded a picture.

Works as is, however probably needs some refining: for example displaying messages what we are doing and so on.

@HolgerJeromin
Copy link
Contributor

The migration files seems to be named after the current date.
But I did not checked in detail.

@tomhughes
Copy link
Member

Hang on, this turns off all the existing gravatars!

@tomhughes
Copy link
Member

Oh no I see, it's just changing the default value.

@simonpoole
Copy link
Contributor Author

@tomhughes this fix will requires the frontend to make an outbound connection to gravatar.com/automattic.com, will that cause any issues? It does reduce the information leakage to gravatar.com a bit since it makes the actually client a bit less discoverable.

@tomhughes
Copy link
Member

What sort of issue would you expect it to cause? It's not something that bothers me...

@simonpoole
Copy link
Contributor Author

@tomhughes I was thinking of outbound FW rules etc.

In any case, the other part of this would be a script that (probably slowly) goes through all the existing accounts and disables gravatar for those without one, any preference/suggestion how that should be done, if at all?

@tomhughes
Copy link
Member

So by my reckoning that function is about ten times longer than it needs to be... Something like this should be all you need I think:

def gravatar_enable(user)
  return if user.image.present?
  hash = Digest::MD5.hexdigest(user.email.downcase)
  url = "https://www.gravatar.com/avatar/#{hash}?d=404"
  response - OSM.http_client.get(URI.parse(url))
  user.image_use_gravatar = response.success?
end

Obviously the tests also need to pass...

My only other comment would be, if the current behaviour violates the privacy policy then does this actually fix it? We are still automatically enabling it for anybody that has a gravatar after alll...

@simonpoole
Copy link
Contributor Author

@tomhughes the PR reduces exposure of the hash of the e-mail address for users that don't have a gravatar to third parties to zero, it further reduces the ability of automattic to fingerprint new OSM users to zero (because the check is done from the frontends), it further limits the ability of automattic to fingerprint and track third parties to those viewing the profile of a user that actually -has- a gravatar (instead of all and every profile). We still expose the hash of the e-mail address of new signups to automattic once, but that is the compromise to make the whole thing user friendly.

It simply does what should have been done from the beginning.

WRT verbosity: I didn't claim anything else, specifically as I mentioned it would be nice to give the user feedback on what has actually been set/changed and thats why I left some code to be able to do that. You will unlikely be able to get around the resuce though.

I believe the tests fail because there is a expectation that an image exists, which is likely no longer the case now.

@tomhughes
Copy link
Member

Why? We don't use the rescue anywhere else...

@simonpoole
Copy link
Contributor Author

@tomhughes at least on my local server I ended up with a rather ugly strack trace etc on the screen if there are network/DNS/server related issues that raise an exception which will likely happen in real life now and then, but I admit to having no idea what would happen running in a production env.

@tomhughes
Copy link
Member

@simonpoole But you were using a completely different HTTP client!

@simonpoole
Copy link
Contributor Author

@TomH wrt tests .... a proper test of this needs a new account without a gravatar enabled (which I believe we create during the tests) and one with, or put differently is it (with reasonable effort) possible to setup a dummy e-mail address in one of the OSM domains that we can use for obtaining a gravatar?

@tomhughes
Copy link
Member

@simonpoole I don't really want to test against the live gravatar servers, but if you use OSM.http_client for the web queries then you can mock the responses using with_http_stubs as the geocoder tests do.

@simonpoole simonpoole force-pushed the fix-gravatar branch 7 times, most recently from a8a0c13 to 3b68048 Compare February 26, 2016 00:02
@simonpoole
Copy link
Contributor Author

I've added two tests that cover the case of users changing their email, for what ever reason coverage has supposedly decreased, however in files which are not actually changed in this PR ........

In any case to make this work I had to rejig the http_stubs stuff so that you can specify the http status code in the config.

@simonpoole
Copy link
Contributor Author

Note wrt testing. While I use stubs for the test of the new functionality, all the other tests naturally actually hit the gravatar servers.

@simonpoole
Copy link
Contributor Author

oldsetting = user.image_use_gravatar
user.image_use_gravatar = response.success?
if oldsetting != user.image_use_gravatar
flash[:warning] = if user.image_use_gravatar
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think :notice would be more appropriate here - it's an informational message rather than a notification that anything is wrong as such.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC (its been a bit long) the problem was that there may be a notice already displayed which causes issues, but outside of that, I agree.

Copy link
Contributor Author

@simonpoole simonpoole Aug 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just jogged my memory a bit and retested on my instance.

The check if a gravatar is available or not takes place when the user uses the link from the confirmation mail, that in itself shows a notice that the e-mail has been changed which hides the one from changing the gravatar state. I suspect a work around would be to merge the messages / create two additional ones for the case when the gravatar enabled status has changed.

Merge message when Gravatar status has changed with email confirmation and make messages more verbose and friendly.
@tomhughes tomhughes merged commit c6fe828 into openstreetmap:master Aug 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants