From 8c96e80782423654d2b9f545a932888c10282408 Mon Sep 17 00:00:00 2001 From: Changaco Date: Sun, 3 Mar 2024 14:04:13 +0100 Subject: [PATCH] delete Facebook and Google user data I don't see any reason to keep this obsolete user data and source code. However, I'm keeping Youtube because the remaining connections made before the integration stopped working are still valuable proof that the person who created the Liberapay profile had control of the linked Youtube account at the time. --- js/10-base.js | 5 --- liberapay/elsewhere/__init__.py | 2 - liberapay/elsewhere/_paginators.py | 1 - liberapay/elsewhere/facebook.py | 35 ---------------- liberapay/elsewhere/google.py | 57 --------------------------- liberapay/models/account_elsewhere.py | 2 +- liberapay/testing/elsewhere.py | 55 -------------------------- liberapay/wireup.py | 3 -- sql/app-conf-defaults.sql | 3 -- sql/branch.sql | 2 + style/base/icons.scss | 1 - tests/py/test_elsewhere.py | 4 +- 12 files changed, 5 insertions(+), 165 deletions(-) delete mode 100644 liberapay/elsewhere/facebook.py delete mode 100644 liberapay/elsewhere/google.py create mode 100644 sql/branch.sql diff --git a/js/10-base.js b/js/10-base.js index f71fd552d3..439461a6ca 100644 --- a/js/10-base.js +++ b/js/10-base.js @@ -20,11 +20,6 @@ Liberapay.init = function() { Liberapay.forms.jsSubmit(); - // http://stackoverflow.com/questions/7131909/facebook-callback-appends-to-return-url - if (window.location.hash == '#_=_') { - window.location.hash = ''; // leaves a # behind - } - var success_re = /([?&])success=[^&]*/; if (success_re.test(location.search)) { history.replaceState(null, null, diff --git a/liberapay/elsewhere/__init__.py b/liberapay/elsewhere/__init__.py index 38bcc186c1..ed6c0b40f4 100644 --- a/liberapay/elsewhere/__init__.py +++ b/liberapay/elsewhere/__init__.py @@ -3,10 +3,8 @@ def _import(): from .bitbucket import Bitbucket # noqa - from .facebook import Facebook # noqa from .github import GitHub # noqa from .gitlab import GitLab # noqa - from .google import Google # noqa from .linuxfr import LinuxFr # noqa from .mastodon import Mastodon # noqa from .openstreetmap import OpenStreetMap # noqa diff --git a/liberapay/elsewhere/_paginators.py b/liberapay/elsewhere/_paginators.py index 87055c3a95..88cc6aa67e 100644 --- a/liberapay/elsewhere/_paginators.py +++ b/liberapay/elsewhere/_paginators.py @@ -107,7 +107,6 @@ def f(self, response, parsed): def keys_paginator(page_key, **kw): # https://confluence.atlassian.com/display/BITBUCKET/Version+2#Version2-Pagingthroughobjectcollections - # https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#paging paging_key = kw.get('paging') total_key = kw.get('total') links_keys_map = tuple((k, kw.get(k, k)) for k in links_keys) diff --git a/liberapay/elsewhere/facebook.py b/liberapay/elsewhere/facebook.py deleted file mode 100644 index 60ee6056e2..0000000000 --- a/liberapay/elsewhere/facebook.py +++ /dev/null @@ -1,35 +0,0 @@ -from liberapay.elsewhere._base import PlatformOAuth2 -from liberapay.elsewhere._extractors import key -from liberapay.elsewhere._paginators import keys_paginator - - -class Facebook(PlatformOAuth2): - - # Platform attributes - name = 'facebook' - display_name = 'Facebook' - fontawesome_name = 'facebook-square' - account_url = None - optional_user_name = True - - # Auth attributes - auth_url = 'https://www.facebook.com/v2.10/dialog/oauth' - access_token_url = 'https://graph.facebook.com/v2.10/oauth/access_token' - refresh_token_url = None - oauth_default_scope = ['public_profile'] - oauth_email_scope = 'email' - - # API attributes - api_format = 'json' - api_paginator = keys_paginator('data', paging='paging', prev='previous') - api_url = 'https://graph.facebook.com/v2.10' - api_user_self_info_path = '/me?fields=id,name,email' - - # User info extractors - x_user_id = key('id') - x_display_name = key('name') - x_email = key('email') - x_description = key('bio') - - def x_avatar_url(self, extracted, info, default): - return 'https://graph.facebook.com/' + extracted.user_id + '/picture?width=256&height=256' diff --git a/liberapay/elsewhere/google.py b/liberapay/elsewhere/google.py deleted file mode 100644 index e6aab499c0..0000000000 --- a/liberapay/elsewhere/google.py +++ /dev/null @@ -1,57 +0,0 @@ -from functools import partial - -from liberapay.elsewhere._base import PlatformOAuth2 -from liberapay.elsewhere._extractors import any_key, key -from liberapay.elsewhere._paginators import _strip_prefix, query_param_paginator - - -class Google(PlatformOAuth2): - - # Platform attributes - name = 'google' - display_name = 'Google' - account_url = None - optional_user_name = True - - # Auth attributes - # https://developers.google.com/identity/protocols/OAuth2WebServer - auth_url = 'https://accounts.google.com/o/oauth2/auth?access_type=offline&include_granted_scopes=true' - access_token_url = 'https://accounts.google.com/o/oauth2/token' - # https://developers.google.com/identity/protocols/googlescopes - oauth_default_scope = ['https://www.googleapis.com/auth/userinfo.profile'] - - # https://developers.google.com/people/api/rest/v1/people/get - person_fields = 'personFields=names,nicknames,photos,taglines' - - # API attributes - api_requires_user_token = True - api_format = 'json' - api_paginator = query_param_paginator('pageToken', - next='nextPageToken', - total='totalItems') - api_url = 'https://people.googleapis.com/v1' - api_user_info_path = '/people/{user_id}?%s' % person_fields - api_user_self_info_path = '/people/me?%s' % person_fields - - # User info extractors - x_user_id = key('resourceName', clean=partial(_strip_prefix, 'people/')) - x_display_name = any_key(('names', 'displayName')) - x_avatar_url = any_key( - 'coverPhotos', 'photos', - clean=lambda d: None if d.get('default') else d['url'] - ) - x_description = any_key(('taglines', 'value')) - - def x_user_info(self, extracted, info, *default): - """Reduce a Person object to its primary values. - - Docs: https://developers.google.com/people/api/rest/v1/people#Person - """ - for k, v in list(info.items()): - if type(v) is list: - info[k] = get_primary(v) - return info - - -def get_primary(l): - return next((d for d in l if d['metadata']['primary']), None) diff --git a/liberapay/models/account_elsewhere.py b/liberapay/models/account_elsewhere.py index da530d1092..895a3b7bae 100644 --- a/liberapay/models/account_elsewhere.py +++ b/liberapay/models/account_elsewhere.py @@ -393,7 +393,7 @@ def refetch_elsewhere_data(): AND (e.missing_since IS NULL OR e.missing_since > (current_timestamp - interval '30 days')) AND (e.last_fetch_attempt IS NULL OR e.last_fetch_attempt < (current_timestamp - interval '3 days')) AND (p.status = 'active' OR p.receiving > 0) - AND e.platform NOT IN ('facebook', 'google', 'youtube') + AND e.platform <> 'youtube' ORDER BY e.info_fetched_at ASC LIMIT 1 ) diff --git a/liberapay/testing/elsewhere.py b/liberapay/testing/elsewhere.py index 1baac4e58f..85ca06d354 100644 --- a/liberapay/testing/elsewhere.py +++ b/liberapay/testing/elsewhere.py @@ -218,61 +218,6 @@ "listed_count": 7 } -facebook = lambda: { - "id": "187701977", - "first_name": "Chad", - "gender": "male", - "last_name": "Whitacre", - "link": "https://www.facebook.com/whit537", - "locale": "en_US", - "name": "Chad Whitacre", - "username": "whit537" -} - -google = lambda: { - "resourceName": "people/110791859286178226496", - "etag": "%EgkBAj0DBgo1Ny4aDAECAwQFBgcICQoLDCIMVXJJdG5BdEg2eXc9", - "names": [ - { - "metadata": { - "primary": True, - "source": { - "type": "PROFILE", - "id": "110791859286178226496" - } - }, - "displayName": "Arthur Panda", - "familyName": "Panda", - "givenName": "Arthur", - "displayNameLastFirst": "Panda, Arthur" - } - ], - "nicknames": [ - { - "metadata": { - "primary": True, - "source": { - "type": "PROFILE", - "id": "110791859286178226496" - } - }, - "value": "Changaco" - } - ], - "photos": [ - { - "metadata": { - "primary": True, - "source": { - "type": "PROFILE", - "id": "110791859286178226496" - } - }, - "url": "https://lh6.googleusercontent.com/-JMfIhnfsuPw/AAAAAAAAAAI/AAAAAAAAABY/M5ldFOyJAPs/s100/photo.jpg" - } - ] -} - twitch = lambda: { "data": [{ "id": "44322889", diff --git a/liberapay/wireup.py b/liberapay/wireup.py index 584d67db10..14eba6b274 100644 --- a/liberapay/wireup.py +++ b/liberapay/wireup.py @@ -205,9 +205,6 @@ class AppConf: check_email_domains=bool, check_email_servers=bool, cron_intervals=dict, - facebook_callback=str, - facebook_id=str, - facebook_secret=str, github_callback=str, github_id=str, github_secret=str, diff --git a/sql/app-conf-defaults.sql b/sql/app-conf-defaults.sql index ecab807426..ed99a6c1a3 100644 --- a/sql/app-conf-defaults.sql +++ b/sql/app-conf-defaults.sql @@ -9,9 +9,6 @@ INSERT INTO app_conf (key, value) VALUES ('check_email_domains', 'true'::jsonb), ('check_email_servers', 'true'::jsonb), ('cron_intervals', jsonb_build_object()), - ('facebook_callback', '"http://localhost:8339/on/facebook/associate"'::jsonb), - ('facebook_id', '"1418954898427187"'::jsonb), - ('facebook_secret', '"3bcb5dc6ce821e5202870c1e6ef5bbc4"'::jsonb), ('github_callback', '"http://127.0.0.1:8339/on/github/associate"'::jsonb), ('github_id', '"18891d01e40e5aef93b8"'::jsonb), ('github_secret', '"46f75669895e96029d57b64832d6f2c8e6291a0e"'::jsonb), diff --git a/sql/branch.sql b/sql/branch.sql new file mode 100644 index 0000000000..024dfd9456 --- /dev/null +++ b/sql/branch.sql @@ -0,0 +1,2 @@ +DELETE FROM elsewhere WHERE platform in ('facebook', 'google'); +DELETE FROM app_conf WHERE key LIKE 'facebook_%'; diff --git a/style/base/icons.scss b/style/base/icons.scss index 7d458e571e..c00a257346 100644 --- a/style/base/icons.scss +++ b/style/base/icons.scss @@ -1,7 +1,6 @@ .fa-brand-color { // https://logo-colors.com/ &.fa-bitbucket { color: #0052cc; } - &.fa-facebook-square { color: #3c5598; } &.fa-github { color: #24292e; } &.fa-gitlab { color: #fca326; } &.fa-mastodon { color: #6364ff; } diff --git a/tests/py/test_elsewhere.py b/tests/py/test_elsewhere.py index 29a9528b93..5fa50faaef 100644 --- a/tests/py/test_elsewhere.py +++ b/tests/py/test_elsewhere.py @@ -80,10 +80,10 @@ def test_connect_might_need_confirmation(self, gui, gusi, ft): def test_connect_failure(self): alice = self.make_participant('alice') error = 'User canceled the Dialog flow' - url = '/on/facebook/associate?error_message=%s&state=deadbeef' % error + url = '/on/github/associate?error_message=%s&state=deadbeef' % error cookie = b64encode_s(json.dumps(['query_data', 'connect', '', '2'])) response = self.client.GxT(url, auth_as=alice, - cookies={'facebook_deadbeef': cookie}) + cookies={'github_deadbeef': cookie}) assert response.code == 502, response.text assert error in response.text